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

197
Views
how do i make my bot send random generated messages after some time?

Ive been trying to make my bot send random messages after some time. Here is the code that i tryed

    randommessage = bot.SendMessage
    randommessage({
                        to: channelID,
        message: "I like turtles!"
    wait (10)});
    
    randommessage({
                        to: channelID,
        message: "I like ponies!"
});

but to no avail it didnt work. I tried asking in a discord server but no one knew how to do it. Could somebody help me?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This doesn't look like a DiscordJS error, but instead a syntax error. The variable randommessage contains the function from bot.SendMessage without the value of bot. This is just how JavaScript works. This means that when you call randommessage, the function within it will have no instance of bot bound to it. In your error messages, you might see something regarding a value being undefined.

It is a simple fix for this error:

randommessage = bot.SendMessage.bind(bot)

When written this way, now the randommessage function has an instance of bot bound to it and can be executed successfully

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!