Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

82
Views
I want bot to send first message only

I'm making a spam command. I want users to enter a message to spam but only the first message should be spam. No other message should be registered if 1 spam is already running. My 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);
      }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Define outside an status variable

let spamrunning=0

Then add the condition of that status variable, and the change of it.

else if (command === prefix + "spam" && args[0] !== undefined && spamrunning==0) {
            message.reply("Quick tip: Use `stopspam` command to stop this")
            spamrunning=1
            spamInterval = setInterval(() => {
              message.channel.send(`${args.slice(0).join(" ")}`);
            }, 1500);
          }

and change status again when you clear the interval

else if (command === prefix + "stopspam") {
         ...
         spamrunning=0
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!