1

I'm making a discord bot, and I created a command where whenever someone executes the command "!ping @ example", then it would ping @example once every minute until @example stops it. I have created the loop successfully, however, I can't terminate the loop.

var interval = setInterval (function () {
  const user = message.mentions.users.first();
            message.channel.send('You have been pinged!' + '\n' + '<@' + user + '>')

        }, 1 * 60000);

1 Answer 1

1

Use clearInterval() method which clears a timer set with the setInterval() method.

clearInterval(interval);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.