From 8e244a203e342addba8e28ec1c1062450817b488 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Fri, 10 Mar 2023 10:26:04 -0700 Subject: [PATCH] Add the ability for the AI to self-terminate the session --- index.js | 8 ++++++-- lang.json | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 74c4dde..e40fe0f 100644 --- a/index.js +++ b/index.js @@ -148,6 +148,10 @@ client.on('messageCreate', async (message) => { }).then((data) => { output = data.data.choices[0].message; output.name = "Bot"; + if (output.content == "!!!TERM1234!!!") { // This can allow a self-termination command + resetSession(message.channelId); + return message.channel.send(lang.terminated); + } // Add the bot's response to the session sessions[message.channelId].messages.push(output); // Send the bot's response @@ -166,10 +170,10 @@ client.on('messageCreate', async (message) => { // Set the reset timer timers[message.channelId] = setTimeout(() => { resetSession(message.channelId); - message.channel.send(lang.timeout) + return message.channel.send(lang.timeout) }, config.openai.resetTime); }).catch((err) => { - message.channel.send({ + return message.channel.send({ "embeds": [{ "title": "Error", "description": err, diff --git a/lang.json b/lang.json index cab67f6..566074e 100644 --- a/lang.json +++ b/lang.json @@ -10,5 +10,12 @@ "empty": "There isn't a session here.", "info": "Current Session", "infoDesc": "AI Messages: {botCount}\nUser Messages: {userCount}\nTotal Messages: {total}", - "infoFooter": "Session Started" + "infoFooter": "Session Started", + "terminated": { + "embeds": [{ + "title": "Self-Terminated", + "description": "The AI has decided to terminate the session.", + "color": 16711680 + }] + } } \ No newline at end of file