So, I've been looking at this for a while now and haven't been able to understand what's up with it. Most people with problems forget to assign a variable to the setInterval and try to clear the function as oppose to the variable but that isn't the case for me.
My code:
Setting the interval (Works fine):
if (message.author.id === "266315986100027394") {
if (cmd === prefix && messageArray.length > 1 && messageArray.length < 3
&& messageArray[1] === "DavidJS") {
var DavidJSTimer = setInterval(DavidJSFunc, 5000);
function DavidJSFunc() {
return message.channel.send("Message");
//console.log("Works");
}
}
}
And clearing the interval (Not working):
if(cmd === prefix && messageArray.length > 1 && messageArray[1] === "stopDavidJS") {
clearInterval(DavidJSTimer);
}
They're both in the same .js file both they have more code between them that is unrelated.
Thanks to anyone who suggests anything.