Make it so you can't reset while it's busy
This commit is contained in:
parent
df46266c2e
commit
4af21dc2e6
13
index.js
13
index.js
|
@ -67,8 +67,12 @@ client.on('interactionCreate', async (interaction) => {
|
||||||
switch (interaction.commandName) {
|
switch (interaction.commandName) {
|
||||||
case "reset":
|
case "reset":
|
||||||
// Remove the session
|
// Remove the session
|
||||||
await resetSession(interaction.channelId);
|
if (!sessions[interaction.channelId].processing) {
|
||||||
interaction.reply(lang.reset);
|
await resetSession(interaction.channelId);
|
||||||
|
interaction.reply(lang.reset);
|
||||||
|
} else {
|
||||||
|
interaction.reply(lang.busy);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "info": // Info about the current session
|
case "info": // Info about the current session
|
||||||
// If the session is empty other than the base prompt, say so
|
// If the session is empty other than the base prompt, say so
|
||||||
|
@ -130,11 +134,13 @@ client.on('messageCreate', async (message) => {
|
||||||
await clearTimeout(timers[message.channelId]);
|
await clearTimeout(timers[message.channelId]);
|
||||||
delete timers[message.channelId];
|
delete timers[message.channelId];
|
||||||
}
|
}
|
||||||
|
// Set the timer
|
||||||
message.channel.sendTyping();
|
message.channel.sendTyping();
|
||||||
var typing = setInterval(() => {
|
var typing = setInterval(() => {
|
||||||
message.channel.sendTyping();
|
message.channel.sendTyping();
|
||||||
}, 5000)
|
}, 5000)
|
||||||
|
// Set processing to true
|
||||||
|
sessions[message.channelId].processing = true;
|
||||||
// Add the message to the session
|
// Add the message to the session
|
||||||
sessions[message.channelId].messages.push({
|
sessions[message.channelId].messages.push({
|
||||||
"name": `${message.author.id}`,
|
"name": `${message.author.id}`,
|
||||||
|
@ -171,6 +177,7 @@ client.on('messageCreate', async (message) => {
|
||||||
} else {
|
} else {
|
||||||
message.channel.send(output.content);
|
message.channel.send(output.content);
|
||||||
}
|
}
|
||||||
|
sessions[message.channelId].processing = false;
|
||||||
// Set the reset timer
|
// Set the reset timer
|
||||||
timers[message.channelId] = setTimeout(() => {
|
timers[message.channelId] = setTimeout(() => {
|
||||||
resetSession(message.channelId);
|
resetSession(message.channelId);
|
||||||
|
|
Loading…
Reference in a new issue