Add the ability for the AI to self-terminate the session
This commit is contained in:
parent
9009899d0c
commit
8e244a203e
8
index.js
8
index.js
|
@ -148,6 +148,10 @@ client.on('messageCreate', async (message) => {
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
output = data.data.choices[0].message;
|
output = data.data.choices[0].message;
|
||||||
output.name = "Bot";
|
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
|
// Add the bot's response to the session
|
||||||
sessions[message.channelId].messages.push(output);
|
sessions[message.channelId].messages.push(output);
|
||||||
// Send the bot's response
|
// Send the bot's response
|
||||||
|
@ -166,10 +170,10 @@ client.on('messageCreate', async (message) => {
|
||||||
// Set the reset timer
|
// Set the reset timer
|
||||||
timers[message.channelId] = setTimeout(() => {
|
timers[message.channelId] = setTimeout(() => {
|
||||||
resetSession(message.channelId);
|
resetSession(message.channelId);
|
||||||
message.channel.send(lang.timeout)
|
return message.channel.send(lang.timeout)
|
||||||
}, config.openai.resetTime);
|
}, config.openai.resetTime);
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
message.channel.send({
|
return message.channel.send({
|
||||||
"embeds": [{
|
"embeds": [{
|
||||||
"title": "Error",
|
"title": "Error",
|
||||||
"description": err,
|
"description": err,
|
||||||
|
|
|
@ -10,5 +10,12 @@
|
||||||
"empty": "There isn't a session here.",
|
"empty": "There isn't a session here.",
|
||||||
"info": "Current Session",
|
"info": "Current Session",
|
||||||
"infoDesc": "AI Messages: {botCount}\nUser Messages: {userCount}\nTotal Messages: {total}",
|
"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
|
||||||
|
}]
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue