I’m making a command that sends a specific message every 1.5 seconds. I have also made a command to stop the interval. It works as i expected. But if the interval is not running and someone executes the stop command, the whole bot crashes. I want to stop that
Here’s the code –
else if (command === prefix + "spam" && args[0] !== undefined) {
message.reply("Quick tip: Use `stopspam` command to stop this")
spamInterval = setInterval(() => {
message.channel.send(`${args.slice(0).join(" ")}`)
}, 1500)
}
else if (command === prefix + "stopspam") {
clearInterval(spamInterval);
message.reply("Stopped the spamming. Hope it created some chaos :skull:")
}