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

144
Visualizações
Having trouble getting a command that sends based on the amount entered to work

I'm trying to make a command that repeats a message based on the number that you input. For example, if I did -ping 4 it would say pong back 4 times. My code for the functionality of the command at the moment (separate from the main file) is:

async execute(message, args) {
    if(!args[1]) return message.channel.send("`Command Usage:\n-rqplay (amount)`");
    if(isNaN(args[1])) return message.channel.send("Please enter an actual number idiot :rolling_eyes:");
    
    if(args[1] > 15) return message.channel.send("I don't want to send that many messages :nauseated_face:");
    if(args[1] < 1) return message.reply("Bro come on, are this stupid?");
    
    await message.channel.messages.fetch({limit: args[1]}).then(_messages =>{
        message.channel.send('@everyone play');
    });
}

However the bot only returns with one command. Help would be much appreciated, thanks!

I'm using the latest Discord.js, VSCode, and node.js.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

With await message.channel.messages.fetch({limit: args[1]}) you are fetching the channel's messages with a limit of whatever number they provided.

If you would like to send a message to the channel however many times they provided, you could use this:

async execute(message, args) {
        if(!args[1]) return message.channel.send("`Command Usage:\n-rqplay (amount)`");
        if(isNaN(args[1])) return message.channel.send("Please enter an actual number idiot :rolling_eyes:");

        if(args[1] > 15) return message.channel.send("I don't want to send that many messages :nauseated_face:");
        if(args[1] < 1) return message.reply("Bro come on, are this stupid?");

        for (let i = 0; i < args[1]; i++) {
           message.channel.send('@everyone play');
        }
    }
}

Notice the for loop at the bottom used to send the messages.

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