From 678db465bf88396ccc8278fb2705792dfcd76996 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Thu, 9 Mar 2023 09:20:31 -0700 Subject: [PATCH] Do some stuff --- .gitignore | 3 ++- basePrompt.txt | 5 ++--- index.js | 27 +++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 4c298a9..e872a71 100644 --- a/.gitignore +++ b/.gitignore @@ -133,4 +133,5 @@ config.json config.json.old config.json.disabled .ssh/* -!.ssh/.gitkeep \ No newline at end of file +!.ssh/.gitkeep +testing/ \ No newline at end of file diff --git a/basePrompt.txt b/basePrompt.txt index fa4a9ff..f7bed6a 100644 --- a/basePrompt.txt +++ b/basePrompt.txt @@ -1,5 +1,4 @@ You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible. -Knowledge cutoff: 2021 -You do not have access to the current date or time. -The maximum number of characters in your response is exactly 2000 characters, which is a limitation of Discord. \ No newline at end of file +Your knowledge cutoff is the year 2021, but the current time is in the future. +You do not have access to the current date or time. \ No newline at end of file diff --git a/index.js b/index.js index 7de3540..f7debfd 100644 --- a/index.js +++ b/index.js @@ -93,13 +93,13 @@ client.on('interactionCreate', async (interaction) => { title: lang.info, description: lang.infoDesc.replace("{userCount}", userCount).replace("{botCount}", botCount).replace("{total}", userCount + botCount), color: 0x00FFFF, - + // This is broken, I don't know why, footer: { text: lang.infoFooter }, timestamp: sessions[interaction.channelId].started - + }] }); } @@ -118,9 +118,10 @@ client.on('messageCreate', async (message) => { started: new Date(), }; } + message.channel.sendTyping(); var typing = setInterval(() => { message.channel.sendTyping(); - }, 1000) + }, 5000) // Add the message to the session sessions[message.channelId].messages.push({ "name": `${message.author.id}`, @@ -138,7 +139,25 @@ client.on('messageCreate', async (message) => { sessions[message.channelId].messages.push(output); // Send the bot's response clearInterval(typing); - message.reply(output.content); + // If output.content is longer than 2000 characters, upload it as a txt file + if (output.content.length > 2000) { + message.channel.send({ + files: [{ + attachment: Buffer.from(output.content), + name: "output.txt" + }] + }); + } else { + message.channel.send(output.content); + } + }).catch((err) => { + message.channel.send({ + "embeds": [{ + "title": "Error", + "description": err, + "color": 0xFF0000 + }] + }) }); });