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
|
||||
from utils.emoji import CROSS, DISABLE, ENABLE, TICK, TICK_ALT
|
||||
@@ -113,7 +113,7 @@ class Automod(commands.Cog):
|
||||
self.bot.loop.create_task(self.init_db())
|
||||
|
||||
async def get_exempt_roles_channels(self, guild_id):
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
roles_cursor = await db.execute("SELECT id FROM automod_ignored WHERE guild_id = ? AND type = 'role'", (guild_id,))
|
||||
channels_cursor = await db.execute("SELECT id FROM automod_ignored WHERE guild_id = ? AND type = 'channel'", (guild_id,))
|
||||
|
||||
@@ -124,18 +124,18 @@ class Automod(commands.Cog):
|
||||
|
||||
|
||||
async def is_automod_enabled(self, guild_id):
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
cursor = await db.execute("SELECT enabled FROM automod WHERE guild_id = ?", (guild_id,))
|
||||
result = await cursor.fetchone()
|
||||
return result is not None and result[0] == 1
|
||||
|
||||
async def update_punishments(self, guild_id, event, punishment):
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
await db.execute("INSERT OR REPLACE INTO automod_punishments (guild_id, event, punishment) VALUES (?, ?, ?)", (guild_id, event, punishment))
|
||||
await db.commit()
|
||||
|
||||
async def get_current_punishments(self, guild_id):
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
async with db.execute(
|
||||
"SELECT event, punishment FROM automod_punishments WHERE guild_id = ? AND event != 'Anti NSFW link'",
|
||||
(guild_id,)
|
||||
@@ -143,7 +143,7 @@ class Automod(commands.Cog):
|
||||
return await cursor.fetchall()
|
||||
|
||||
async def is_anti_nsfw_enabled(self, guild_id):
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
cursor = await db.execute("SELECT punishment FROM automod_punishments WHERE guild_id = ? AND event = 'Anti NSFW link'", (guild_id,))
|
||||
result = await cursor.fetchone()
|
||||
return result is not None
|
||||
@@ -151,7 +151,7 @@ class Automod(commands.Cog):
|
||||
|
||||
|
||||
async def init_db(self):
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
await db.execute("""
|
||||
CREATE TABLE IF NOT EXISTS automod (
|
||||
guild_id INTEGER PRIMARY KEY,
|
||||
@@ -271,7 +271,7 @@ class Automod(commands.Cog):
|
||||
|
||||
async def enable_automod(self, ctx, guild_id, selected_events, interaction):
|
||||
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
await db.execute("INSERT OR REPLACE INTO automod (guild_id, enabled) VALUES (?, 1)", (guild_id,))
|
||||
for event in selected_events:
|
||||
await db.execute("INSERT OR REPLACE INTO automod_punishments (guild_id, event, punishment) VALUES (?, ?, ?)", (guild_id, event, self.default_punishment))
|
||||
@@ -328,7 +328,7 @@ class Automod(commands.Cog):
|
||||
log_channel = await interaction.guild.create_text_channel(f"{BRAND_NAME.lower()}-automod", overwrites=overwrites)
|
||||
guild_id = interaction.guild.id
|
||||
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
await db.execute("INSERT OR REPLACE INTO automod_logging (guild_id, log_channel) VALUES (?, ?)", (guild_id, log_channel.id))
|
||||
await db.commit()
|
||||
|
||||
@@ -440,7 +440,7 @@ class Automod(commands.Cog):
|
||||
await ctx.send(view=CV2(f"Automod Settings for {ctx.guild.name}", f"Uhh, looks like your server hasn\'t enabled Automoderation.\n\nCurrent Status: {DISABLE} Disabled\nTo Enable use `{ctx.prefix}automod enable`"))
|
||||
return
|
||||
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
cursor = await db.execute("SELECT 1 FROM automod_ignored WHERE guild_id = ? AND type = 'channel' AND id = ?", (guild_id, channel.id))
|
||||
if await cursor.fetchone() is not None:
|
||||
await ctx.send(view=CV2("__Channel Already Whitelisted!__", f"{CROSS} The channel {channel.mention} is already in the ignore list.\n\n➜ Use **{ctx.prefix}automod unignore channel {channel.mention}** to remove it."))
|
||||
@@ -491,7 +491,7 @@ class Automod(commands.Cog):
|
||||
await ctx.send(view=CV2(f"Automod Settings for {ctx.guild.name}", f"Uhh, looks like your server hasn\'t enabled Automoderation.\n\nCurrent Status: {DISABLE} Disabled\nTo Enable use `{ctx.prefix}automod enable`"))
|
||||
return
|
||||
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
cursor = await db.execute("SELECT 1 FROM automod_ignored WHERE guild_id = ? AND type = 'role' AND id = ?", (guild_id, role.id))
|
||||
|
||||
if await cursor.fetchone() is not None:
|
||||
@@ -545,7 +545,7 @@ class Automod(commands.Cog):
|
||||
return
|
||||
|
||||
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
cursor = await db.execute("SELECT type, id FROM automod_ignored WHERE guild_id = ?", (guild_id,))
|
||||
ignored_items = await cursor.fetchall()
|
||||
|
||||
@@ -592,7 +592,7 @@ class Automod(commands.Cog):
|
||||
await ctx.send(view=CV2(f"Automod Settings for {ctx.guild.name}", f"Uhh, looks like your server hasn\'t enabled Automoderation.\n\nCurrent Status: {DISABLE} Disabled\nTo Enable use `{ctx.prefix}automod enable`"))
|
||||
return
|
||||
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
await db.execute("DELETE FROM automod_ignored WHERE guild_id = ?", (guild_id,))
|
||||
await db.commit()
|
||||
await ctx.send(view=CV2(f"Automod Settings for {ctx.guild.name}", f"** {TICK} | All ignored channels and roles have been reset!**\n\nTo view current Automod settings use `{ctx.prefix}automod config`"))
|
||||
@@ -639,7 +639,7 @@ class Automod(commands.Cog):
|
||||
except discord.HTTPException:
|
||||
pass
|
||||
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
result = await db.execute("DELETE FROM automod_ignored WHERE guild_id = ? AND type = 'channel' AND id = ?", (guild_id, channel.id))
|
||||
await db.commit()
|
||||
|
||||
@@ -682,7 +682,7 @@ class Automod(commands.Cog):
|
||||
pass
|
||||
|
||||
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
result = await db.execute("DELETE FROM automod_ignored WHERE guild_id = ? AND type = 'role' AND id = ?", (guild_id, role.id))
|
||||
await db.commit()
|
||||
|
||||
@@ -719,7 +719,7 @@ class Automod(commands.Cog):
|
||||
|
||||
elif view.value:
|
||||
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
await db.execute("DELETE FROM automod WHERE guild_id = ?", (guild_id,))
|
||||
await db.execute("DELETE FROM automod_punishments WHERE guild_id = ?", (guild_id,))
|
||||
await db.execute("DELETE FROM automod_ignored WHERE guild_id = ?", (guild_id,))
|
||||
@@ -768,7 +768,7 @@ class Automod(commands.Cog):
|
||||
items_str.append(f"**{event}**: {punishment or 'None'}")
|
||||
if await self.is_anti_nsfw_enabled(guild_id):
|
||||
items_str.append("**Anti NSFW Links**: Block Message")
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
cursor = await db.execute("SELECT log_channel FROM automod_logging WHERE guild_id = ?", (guild_id,))
|
||||
log_channel_id = await cursor.fetchone()
|
||||
if log_channel_id and log_channel_id[0]:
|
||||
@@ -799,7 +799,7 @@ class Automod(commands.Cog):
|
||||
await ctx.send(view=CV2(f"Automod Settings for {ctx.guild.name}", f"Uhh, looks like your server hasn\'t enabled Automoderation.\n\nCurrent Status: {DISABLE} Disabled\nTo Enable use `{ctx.prefix}automod enable`"))
|
||||
return
|
||||
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
await db.execute("INSERT OR REPLACE INTO automod_logging (guild_id, log_channel) VALUES (?, ?)", (guild_id, channel.id))
|
||||
await db.commit()
|
||||
await ctx.send(view=CV2(f"Automod Settings for {ctx.guild.name}", f"**{TICK} | Automoderation Logging channel set to {channel.mention}.**\n\n➜ Use `{ctx.prefix}automod config` to view current Automod settings."))
|
||||
@@ -809,7 +809,7 @@ class Automod(commands.Cog):
|
||||
async def on_guild_remove(self, guild):
|
||||
guild_id = guild.id
|
||||
|
||||
async with aiosqlite.connect("db/automod.db") as db:
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
await db.execute("DELETE FROM automod WHERE guild_id = ?", (guild_id,))
|
||||
await db.execute("DELETE FROM automod_punishments WHERE guild_id = ?", (guild_id,))
|
||||
await db.execute("DELETE FROM automod_ignored WHERE guild_id = ?", (guild_id,))
|
||||
|
||||
Reference in New Issue
Block a user