Update project configuration files, and API routes accordingly. Add SQLite runtime file ignores to .gitignore for better file management.
Some checks failed
CI / Bot (Python) (push) Failing after 49s
CI / Dashboard (Next.js) (push) Failing after 11s

This commit is contained in:
TheOnlyMace
2026-07-21 17:11:38 +02:00
parent 5f34db4f3b
commit b4110c3d66
297 changed files with 2657 additions and 2768 deletions

View File

@@ -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, TICK, ZWARNING
@@ -212,7 +212,7 @@ class LevelConfigModal (discord .ui .Modal ,title ="Leveling System Configuratio
try :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute ("SELECT guild_id FROM leveling_settings WHERE guild_id = ?",(interaction .guild .id ,))as cursor :
exists =await cursor .fetchone ()
@@ -291,7 +291,7 @@ class Leveling (commands .Cog ):
self .bot =bot
self .message_cooldowns ={}
self .last_level_cache ={}
self .db_path ="db/leveling.db"
self .db_path =db_path("leveling.db")
@commands.group (name ="level",invoke_without_command =True ,description ="Leveling system")
async def level (self ,ctx ):
@@ -310,7 +310,7 @@ class Leveling (commands .Cog ):
async def init_database (self ):
"""Initialize all required database tables"""
try :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
await db .execute ("""
CREATE TABLE IF NOT EXISTS user_xp (
@@ -411,13 +411,13 @@ class Leveling (commands .Cog ):
max_retries =5
for attempt in range (max_retries ):
try :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute ("SELECT * FROM leveling_settings WHERE guild_id = ?",(guild_id ,))as cursor :
row =await cursor .fetchone ()
if not row :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
await db .execute ("INSERT INTO leveling_settings (guild_id, enabled) VALUES (?, 0)",(guild_id ,))
await db .commit ()
return {
@@ -474,7 +474,7 @@ class Leveling (commands .Cog ):
async def is_blacklisted (self ,guild_id :int ,user_id :int ,channel_id :int )->bool :
"""Check if user or channel is blacklisted"""
try :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .cursor ()as cursor :
await cursor .execute ("PRAGMA table_info(leveling_blacklist)")
@@ -522,7 +522,7 @@ class Leveling (commands .Cog ):
return 1.0
total_multiplier =1.0
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute (
"SELECT target_id, multiplier FROM xp_multipliers WHERE guild_id = ? AND target_type = 'role'",
@@ -593,7 +593,7 @@ class Leveling (commands .Cog ):
final_xp =int (final_xp *multiplier )
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute (
"SELECT xp, messages FROM user_xp WHERE guild_id = ? AND user_id = ?",
(guild_id ,user_id )
@@ -713,7 +713,7 @@ class Leveling (commands .Cog ):
async def give_level_rewards (self ,guild ,member ,level ):
"""Give role rewards for reaching a level"""
try :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute (
"SELECT role_id, remove_previous FROM level_rewards WHERE guild_id = ? AND level <= ? ORDER BY level DESC",
(guild .id ,level )
@@ -727,7 +727,7 @@ class Leveling (commands .Cog ):
if remove_previous :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute (
"SELECT role_id FROM level_rewards WHERE guild_id = ? AND level < ?",
(guild .id ,level )
@@ -745,7 +745,7 @@ class Leveling (commands .Cog ):
async def apply_level_roles (self ,guild ,member ,level ):
"""Apply level roles for reaching a level"""
try :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute (
"SELECT role_id FROM level_roles WHERE guild_id = ? AND level <= ? ORDER BY level DESC",
(guild .id ,level )
@@ -768,7 +768,7 @@ class Leveling (commands .Cog ):
async def get_user_data (self ,guild_id :int ,user_id :int )->tuple :
"""Get user XP and level data"""
try :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute (
"SELECT xp, messages FROM user_xp WHERE guild_id = ? AND user_id = ?",
(guild_id ,user_id )
@@ -786,7 +786,7 @@ class Leveling (commands .Cog ):
async def get_user_rank (self ,guild_id :int ,user_id :int )->int :
"""Get user's rank in the guild"""
try :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute (
"SELECT COUNT(*) + 1 FROM user_xp WHERE guild_id = ? AND xp > (SELECT COALESCE(xp, 0) FROM user_xp WHERE guild_id = ? AND user_id = ?)",
(guild_id ,guild_id ,user_id )
@@ -1751,7 +1751,7 @@ class Leveling (commands .Cog ):
embed_color_int =hex_to_int (embed_color )
level_image_final =level_image if level_image and level_image .strip ()else None
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute ("SELECT guild_id FROM leveling_settings WHERE guild_id = ?",(ctx .guild .id ,))as cursor :
exists =await cursor .fetchone ()
@@ -2014,7 +2014,7 @@ class Leveling (commands .Cog ):
await ctx .send ("Level must be greater than 0.")
return
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
await db .execute (
"INSERT OR REPLACE INTO level_rewards (guild_id, level, role_id, remove_previous) VALUES (?, ?, ?, ?)",
(ctx .guild .id ,level ,role .id ,int (remove_previous ))
@@ -2031,7 +2031,7 @@ class Leveling (commands .Cog ):
async def rewards_remove (self ,ctx ,level :int ):
"""Remove level reward"""
try :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
await db .execute (
"DELETE FROM level_rewards WHERE guild_id = ? AND level = ?",
(ctx .guild .id ,level )
@@ -2048,7 +2048,7 @@ class Leveling (commands .Cog ):
async def rewards_list (self ,ctx ):
"""List level rewards"""
try :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute (
"SELECT level, role_id, remove_previous FROM level_rewards WHERE guild_id = ? ORDER BY level",
(ctx .guild .id ,)
@@ -2104,7 +2104,7 @@ class Leveling (commands .Cog ):
await ctx .send ("Invalid channel ID.")
return
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
await db .execute (
"INSERT OR REPLACE INTO xp_multipliers (guild_id, target_id, target_type, multiplier) VALUES (?, ?, ?, ?)",
(ctx .guild .id ,target_id ,target_type ,multiplier )
@@ -2140,7 +2140,7 @@ class Leveling (commands .Cog ):
await ctx .send ("Invalid channel ID.")
return
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
await db .execute (
"DELETE FROM xp_multipliers WHERE guild_id = ? AND target_id = ? AND target_type = ?",
(ctx .guild .id ,target_id ,target_type )
@@ -2157,7 +2157,7 @@ class Leveling (commands .Cog ):
async def multiplier_list (self ,ctx ):
"""List XP multipliers"""
try :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute (
"SELECT target_id, target_type, multiplier FROM xp_multipliers WHERE guild_id = ?",
(ctx .guild .id ,)
@@ -2213,7 +2213,7 @@ class Leveling (commands .Cog ):
await ctx .send ("Invalid channel ID.")
return
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
await db .execute (
"INSERT OR REPLACE INTO leveling_blacklist (guild_id, target_id, target_type) VALUES (?, ?, ?)",
(ctx .guild .id ,target_id ,target_type )
@@ -2249,7 +2249,7 @@ class Leveling (commands .Cog ):
await ctx .send ("Invalid channel ID.")
return
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
await db .execute (
"DELETE FROM leveling_blacklist WHERE guild_id = ? AND target_id = ? AND target_type = ?",
(ctx .guild .id ,target_id ,target_type )
@@ -2266,7 +2266,7 @@ class Leveling (commands .Cog ):
async def blacklist_list (self ,ctx ):
"""List leveling blacklist"""
try :
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute (
"SELECT target_id, target_type FROM leveling_blacklist WHERE guild_id = ?",
(ctx .guild .id ,)
@@ -2422,7 +2422,7 @@ class Leveling (commands .Cog ):
if isinstance (ctx ,discord .Interaction ):
await ctx .response .defer ()
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
cursor =await db .execute ('''
SELECT user_id, xp, messages FROM user_xp
@@ -3013,7 +3013,7 @@ class Leveling (commands .Cog ):
percentage =(progress /needed *100 )if needed >0 else 100
async with aiosqlite .connect ("db/leveling.db")as db :
async with aiosqlite .connect (db_path("leveling.db"))as db :
async with db .execute (
"SELECT COUNT(*) FROM user_xp WHERE guild_id = ? AND xp > 0",
(guild_id ,)