Update project configuration files, and API routes accordingly. Add SQLite runtime file ignores to .gitignore for better file management.
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
# ╔══════════════════════════════════════════════════════════════════╗
|
||||
# ║ ║
|
||||
# ║ ░█▀▀░█▀█░█▀▄░█▀▀░█░█ ░█▀▄░█▀▀░█░█░█▀▀ ║
|
||||
# ║ ░█░░░█░█░█░█░█▀▀░▄▀▄ ░█░█░█▀▀░▀▄▀░▀▀█ ║
|
||||
# ║ ░▀▀▀░▀▀▀░▀▀░░▀▀▀░▀░▀ ░▀▀░░▀▀▀░░▀░░▀▀▀ ║
|
||||
# ║ +-+-+-+-+-+-+-+-+ ║
|
||||
# ║ |H|e|x|a|H|o|s|t| ║
|
||||
# ║ +-+-+-+-+-+-+-+-+ ║
|
||||
# ║ ║
|
||||
# ║ © 2026 CodeX Devs — All Rights Reserved ║
|
||||
# ║ © 2026 HexaHost — All Rights Reserved ║
|
||||
# ║ ║
|
||||
# ║ discord ── https://discord.gg/codexdev ║
|
||||
# ║ youtube ── https://youtube.com/@CodeXDevs ║
|
||||
# ║ github ── https://github.com/RayExo ║
|
||||
# ║ discord ── https://discord.gg/hexahost ║
|
||||
# ║ github ── https://github.com/theoneandonlymace ║
|
||||
# ║ ║
|
||||
# ╚══════════════════════════════════════════════════════════════════╝
|
||||
from utils.db_paths import db_path
|
||||
|
||||
import discord
|
||||
import aiosqlite
|
||||
@@ -31,7 +31,7 @@ class StickyMessage(commands.Cog):
|
||||
if not os.path.exists("db"):
|
||||
os.makedirs("db")
|
||||
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
await db.execute("""
|
||||
CREATE TABLE IF NOT EXISTS sticky_messages (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -58,7 +58,7 @@ class StickyMessage(commands.Cog):
|
||||
if not message.guild or (message.author.bot and message.author.id != self.bot.user.id):
|
||||
return
|
||||
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
db.row_factory = aiosqlite.Row
|
||||
cursor = await db.execute(
|
||||
"SELECT * FROM sticky_messages WHERE channel_id = ? AND enabled = 1",
|
||||
@@ -81,7 +81,7 @@ class StickyMessage(commands.Cog):
|
||||
|
||||
new_count = sticky_data['current_count'] + 1
|
||||
if new_count < sticky_data['trigger_count']:
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
await db.execute(
|
||||
"UPDATE sticky_messages SET current_count = ? WHERE id = ?",
|
||||
(new_count, sticky_data['id'])
|
||||
@@ -89,7 +89,7 @@ class StickyMessage(commands.Cog):
|
||||
await db.commit()
|
||||
return
|
||||
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
await db.execute("UPDATE sticky_messages SET current_count = 0 WHERE id = ?", (sticky_data['id'],))
|
||||
await db.commit()
|
||||
|
||||
@@ -123,7 +123,7 @@ class StickyMessage(commands.Cog):
|
||||
|
||||
new_sticky = await message.channel.send(content=content, embed=embed, delete_after=delete_after)
|
||||
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
await db.execute(
|
||||
"UPDATE sticky_messages SET last_message_id = ? WHERE id = ?",
|
||||
(new_sticky.id, sticky_data['id'])
|
||||
@@ -140,7 +140,7 @@ class StickyMessage(commands.Cog):
|
||||
@commands.has_permissions(manage_messages=True)
|
||||
async def sticky_setup(self, ctx: commands.Context, channel: Optional[discord.TextChannel] = None):
|
||||
channel = channel or ctx.channel
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
cursor = await db.execute("SELECT 1 FROM sticky_messages WHERE channel_id = ?", (channel.id,))
|
||||
if await cursor.fetchone():
|
||||
embed = discord.Embed(title="Setup Error", description=f"A sticky message already exists in {channel.mention}.", color=RED_THEME_COLOR)
|
||||
@@ -153,7 +153,7 @@ class StickyMessage(commands.Cog):
|
||||
@commands.has_permissions(manage_messages=True)
|
||||
async def sticky_remove(self, ctx: commands.Context, channel: Optional[discord.TextChannel] = None):
|
||||
channel = channel or ctx.channel
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
cursor = await db.execute("SELECT last_message_id FROM sticky_messages WHERE channel_id = ?", (channel.id,))
|
||||
data = await cursor.fetchone()
|
||||
if not data:
|
||||
@@ -175,7 +175,7 @@ class StickyMessage(commands.Cog):
|
||||
@stickymessage.command(name='list')
|
||||
@commands.has_permissions(manage_messages=True)
|
||||
async def sticky_list(self, ctx: commands.Context):
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
db.row_factory = aiosqlite.Row
|
||||
cursor = await db.execute("SELECT * FROM sticky_messages WHERE guild_id = ?", (ctx.guild.id,))
|
||||
stickies = await cursor.fetchall()
|
||||
@@ -198,7 +198,7 @@ class StickyMessage(commands.Cog):
|
||||
@commands.has_permissions(manage_messages=True)
|
||||
async def sticky_edit(self, ctx: commands.Context, channel: Optional[discord.TextChannel] = None):
|
||||
channel = channel or ctx.channel
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
db.row_factory = aiosqlite.Row
|
||||
cursor = await db.execute("SELECT * FROM sticky_messages WHERE channel_id = ?", (channel.id,))
|
||||
sticky_data = await cursor.fetchone()
|
||||
@@ -262,7 +262,7 @@ class PlainTextModal(discord.ui.Modal, title='Plain Text Sticky Message'):
|
||||
except ValueError:
|
||||
delay = 2
|
||||
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
await db.execute(
|
||||
"INSERT INTO sticky_messages (guild_id, channel_id, message_type, message_content, delay_seconds) VALUES (?, ?, ?, ?, ?)",
|
||||
(self.ctx.guild.id, self.channel.id, 'plain', self.message_content.value, delay)
|
||||
@@ -296,7 +296,7 @@ class EmbedModal(discord.ui.Modal, title='Embed Sticky Message'):
|
||||
"footer": self.footer.value
|
||||
}
|
||||
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
await db.execute(
|
||||
"INSERT INTO sticky_messages (guild_id, channel_id, message_type, embed_data, delay_seconds) VALUES (?, ?, ?, ?, ?)",
|
||||
(self.ctx.guild.id, self.channel.id, 'embed', json.dumps(embed_data), delay)
|
||||
@@ -342,7 +342,7 @@ class EditPlainTextModal(discord.ui.Modal, title='Edit Plain Text Content'):
|
||||
self.add_item(self.message_content)
|
||||
|
||||
async def on_submit(self, interaction: discord.Interaction):
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
await db.execute(
|
||||
"UPDATE sticky_messages SET message_content = ? WHERE channel_id = ?",
|
||||
(self.message_content.value, self.channel.id)
|
||||
@@ -371,7 +371,7 @@ class EditEmbedModal(discord.ui.Modal, title='Edit Embed Content'):
|
||||
"title": self.title.value, "description": self.description.value,
|
||||
"color": f"#{RED_THEME_COLOR:06x}", "footer": self.footer.value
|
||||
}
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
await db.execute(
|
||||
"UPDATE sticky_messages SET embed_data = ? WHERE channel_id = ?",
|
||||
(json.dumps(embed_data), self.channel.id)
|
||||
@@ -402,7 +402,7 @@ class EditSettingsModal(discord.ui.Modal, title='Edit Sticky Settings'):
|
||||
except ValueError:
|
||||
return await interaction.response.send_message("Please enter valid numbers.", ephemeral=True)
|
||||
|
||||
async with aiosqlite.connect("db/stickymessages.db") as db:
|
||||
async with aiosqlite.connect(db_path("stickymessages.db")) as db:
|
||||
await db.execute(
|
||||
"UPDATE sticky_messages SET delay_seconds = ?, auto_delete_after = ?, trigger_count = ? WHERE channel_id = ?",
|
||||
(delay, auto_del, trigger, self.channel.id)
|
||||
|
||||
Reference in New Issue
Block a user