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

205
Visualizações
Problem with javascript discord bot involving sending empty messages

I am making a discord bot and I am trying to save strings into an array and send it if the right command is sent. Here is the code:

client.on('messageCreate', (msg) => {
if(!msg.content.startsWith(commandChar)) return;
const args = msg.content.slice(1).split(' ');
const cmdBody = msg.content.slice(msg.content.indexOf(' '));
const cmd = args.shift().toLowerCase();
switch(cmd) {
    case 'new':
        quotes.push(cmdBody);
        msg.channel.send('Quote added! The Quote Number is ' + quotes.length);
        break;
    case 'find':
        if(isNaN(cmdBody))
            cmdBody--; 
            try {
                text = quotes[cmdBody]
                msg.channel.send(text);
            }
            catch {
                msg.channel.send('There is no quote corresponding to the number' + (cmdBody + 1) + '.');
            }
        break;
    case 'changeCommandChar':
        if(cmdBody.length === 1) {
            commandChar = cmdBody;
            msg.channel.send('Command Character changed! The new command Character is ' + commandChar);
        }
        break;
}

});

Here is the error:

RequestHandler.js:350 throw new DiscordAPIError(data, res.status, request);

DiscordAPIError: Cannot send an empty message

about 4 years ago · Juan Pablo Isaza
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