Adding error checking for stat message removal

This commit is contained in:
Raven Scott 2023-11-14 18:18:37 -05:00
parent 1f3ff44317
commit a5d2530456
1 changed files with 11 additions and 5 deletions

View File

@ -504,11 +504,17 @@ async function generateResponse(conversation, message) {
// clear the interval, replace the "please wait" message with the response, and update the message
console.log(responseText);
try {
if (time > 2) {
await botMessage.delete()
clearInterval(refreshInterval);
botMessage = null;
}
await botMessage.delete();
clearInterval(refreshInterval);
botMessage = null;
console.log("Time limit reached. Message deleted.");
}
} catch (err) {
console.log("Error deleting message: ", err);
}
return responseText;
@ -521,4 +527,4 @@ async function generateResponse(conversation, message) {
}
}
client.login(process.env.THE_TOKEN); // Replace with your bot token
client.login(process.env.THE_TOKEN); // Replace with your bot token