setInterval and clearInterval doesn't work

I don’t understand why setInterval and clearInterval doesn’t work…

//On to starting my commmand
//Off to stopping my command

const { MESSAGES } = require('../../Data/constants')

module.exports.run = (client, message, args) => {

    switch (args[0]) {

        case 'on': {

            var interval = setInterval (function() {
                
                console.log('coucou')}, 2000);
        };
 
        case 'off': {

            clearInterval(interval);
        };

        break;
    };
};

module.exports.help = MESSAGES.COMMANDS.INFO.SPAM

3 thoughts on “setInterval and clearInterval doesn't work”

Leave a Comment