I am making a spam command, i want the spam command executer to only be able to stop it. I am confused to how do so. Here's my code (i have tried nothing by by myself yet)
else if (command === prefix + "spam") {spamText = setInterval(() => {message.channel.send(${args.slice(0).join(" ")})}, 1500);} else if (command === prefix + "stopspam"{ clearInterval(spamText); message.reply("Stopped the spamming. Hope it created some chaos :skull:")}
you need to extract your interval to be able to stop it
function Spam(){
message.channel.send(${args.slice(0).join(" ")})
}
let myInterval;
if (command === prefix + "spam") {
myInterval = setInterval(Spam, 1500);
}
else if (command === prefix + "stopspam"){
clearInterval(spamText);
message.reply("Stopped the spamming. Hope it created some chaos :skull:");
}
and be carefull with the use. nobody like spammer