Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

201
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda