From 19ce0b0c0ab71e8c01c27227ec456bf5eed33f28 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sun, 12 Mar 2023 21:00:40 -0600 Subject: [PATCH] add some debug fuckery --- commands.json | 17 +++++++++++++++++ index.js | 20 +++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/commands.json b/commands.json index fbb0c62..258c6bd 100644 --- a/commands.json +++ b/commands.json @@ -8,5 +8,22 @@ "name": "info", "description": "Info about the current session", "type": 1 + }, + { + "name": "debug", + "description": "Uploads some debug information", + "type": 1, + "options": [ + { + "name": "config", + "description": "Upload the config file", + "type": 5 + }, + { + "name": "client", + "description": "Upload the client object", + "type": 5 + } + ] } ] \ No newline at end of file diff --git a/index.js b/index.js index d9f18a8..43bdddd 100644 --- a/index.js +++ b/index.js @@ -151,6 +151,20 @@ client.on('interactionCreate', async (interaction) => { }); } break; + case "debug": // Upload debug info such as the session + + // Generate files array based on options + var files = []; + if (interaction.options.getBoolean("config")) files.push({name: "config.json", attachment: Buffer.from(JSON.stringify(config, null, "\t"))}); + if (interaction.options.getBoolean("client")) files.push({name: "client.json", attachment: Buffer.from(JSON.stringify(client, null, "\t"))}); + // if the object size of sessions isn't 0, push the sessions file + if (Object.keys(sessions).length !== 0) files.push({name: "sessions.json", attachment: Buffer.from(JSON.stringify(sessions, null, "\t"))}); + // Upload the session + interaction.reply({ + content: files.length == 0 ? "No files to upload." : null, + ephemeral: true, + files: files + }); } }); @@ -273,7 +287,11 @@ if (fs.existsSync(path.join(__dirname, "modPrompt.txt"))) { basePrompt.content = fs.readFileSync("./basePrompt.txt", "utf8").toString(); } -var nsfwPrompt = {"role": "system", "name": "System", "content": fs.readFileSync("./nsfwPrompt.txt", "utf8").toString()}; // NSFW prompt for NSFW channels +var nsfwPrompt = { + "role": "system", + "name": "System", + "content": fs.readFileSync("./nsfwPrompt.txt", "utf8").toString() +}; // NSFW prompt for NSFW channels // Handle SIGINT gracefully process.on('SIGINT', async () => {