From c6ccbc8e76caa0dd7104a0194f8ad385dfeff173 Mon Sep 17 00:00:00 2001 From: NekoMonci12 Date: Tue, 3 Jun 2025 06:35:36 +0700 Subject: [PATCH] "/debugmode" commands --- index.js | 34 ++++++++++++++++++++++++++++++++-- package-lock.json | 2 +- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b4f9f66..1e82d26 100644 --- a/index.js +++ b/index.js @@ -65,6 +65,10 @@ const pastebin = new PastebinClient(process.env.PASTEBIN_DEV_KEY); new SlashCommandBuilder() .setName('invite') .setDescription('Invite RakunNakun Into Your Server!'), + + new SlashCommandBuilder() + .setName('debugmode') + .setDescription('Toggle Debug Mode!'), new SlashCommandBuilder() .setName('setpersona') @@ -131,7 +135,7 @@ const pastebin = new PastebinClient(process.env.PASTEBIN_DEV_KEY); const { commandName, guildId, user, options } = interaction; // Only run permission check for certain commands - const commandsRequiringOwnership = ['generate-api', 'list-api', 'delete-api', 'setpersona']; + const commandsRequiringOwnership = ['generate-api', 'list-api', 'delete-api', 'setpersona', 'debugmode']; if (commandsRequiringOwnership.includes(commandName)) { const [guildRows] = await db.pool.query( 'SELECT GUILD_OWNER_ID FROM Guilds WHERE GUILD_ID = ?', @@ -264,6 +268,32 @@ const pastebin = new PastebinClient(process.env.PASTEBIN_DEV_KEY); }); } } + + else if (commandName === 'debugmode') { + // Check if user has permission (optional, similar to other commands) + const [guildRows] = await db.pool.query( + 'SELECT GUILD_OWNER_ID FROM Guilds WHERE GUILD_ID = ?', + [guildId] + ); + + // Toggle DEBUG value + const [rows] = await db.pool.query( + 'SELECT DEBUG FROM Guilds WHERE GUILD_ID = ?', + [guildId] + ); + const currentDebug = rows.length ? rows[0].DEBUG : 0; + const newDebug = currentDebug === 1 ? 0 : 1; + + await db.pool.query( + 'UPDATE Guilds SET DEBUG = ? WHERE GUILD_ID = ?', + [newDebug, guildId] + ); + + await interaction.reply({ + content: `✅ Debug mode is now ${newDebug === 1 ? 'enabled' : 'disabled'}.`, + ephemeral: true + }); + } }); client.login(process.env.DISCORD_TOKEN); @@ -332,7 +362,7 @@ async function processMessage({ if (!guildRows.length) return { error: 'Guild not registered' }; let { CHAT_MODELS, CHAT_TOKENS, DEBUG, CHAT_PERSONA } = guildRows[0]; let currentTokens = Number(CHAT_TOKENS) || 0; - if (currentTokens < MIN_TOKEN_THRESH) return { error: 'Insufficient tokens' }; + if (currentTokens < MIN_TOKEN_THRESH) return { reply: 'Insufficient tokens' }; let modelIdToUse = CHAT_MODELS || defaultModelId; let personaToUse = CHAT_PERSONA || defaultPersona; diff --git a/package-lock.json b/package-lock.json index 5139090..da4091a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "container", + "name": "RakunNakun-AI", "lockfileVersion": 3, "requires": true, "packages": {