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

203
Views
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
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!