DiscordAPIError on Embed message command

Hi, i will make a discord bot with an command (!ping). But i have an Error and i need help pls.

The Code


const Discord = require(‘discord.js’)

const client = new Discord.Client({ intents: [“GUILDS”, “GUILD_MESSAGES”] });

const prefix = ‘!’;

const fs = require(‘fs’);

client.commands = new Discord.Collection();

const commandFiles = fs.readdirSync(’./commands/’).filter(file => file.endsWith(’.js’));

for(const file of commandFiles){

const command = require(`./commands/${file}`);

client.commands.set(command.name, command);


client.once(‘ready’, () => {

console.log('YU91 BOT ONLINE');


client.on(‘messageCreate’, message =>{

if(!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);

const command = args.shift().toLowerCase();

if(command === 'ping'){

    client.commands.get('ping').execute(message, args, Discord);





module.exports = {

name: ‘ping’,

description: “Ping command”,

execute(message, args, Discord) {

  const newEmbed = new Discord.MessageEmbed()



  .setDescription(`${Date.now() - message.createdTimestamp}ms`)




-----THE ERROR-----

throw new DiscordAPIError(data, res.status, request);

DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (C:\Users\Marc-\Desktop\DiscordBot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\Marc-\Desktop\DiscordBot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async TextChannel.send (C:\Users\Marc-\Desktop\DiscordBot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:175:15) {
method: ‘post’,
path: ‘/channels/929385752297615453/messages’,
code: 50006,
httpStatus: 400,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined


As of recently it is depreciated to send messages like this. Now you need to send an object containing the content you wished sent.


is now

Channel.send({content: 'message'});

Like wise for embeds, you now provide a list of embeds for the object’s embeds atribute:

Channel.send({embeds: [newEmbed]});

Thank you, now i has a new Question…

How i can in a Embed write the ping?

I want the ping In the Embed description but it doesn’t work with ( Latency is ${Date.now() - message.createdTimestamp}ms); } in description.

The best way I’ve found to do this is in the past is actually to edit the message you sent based on it’s timestamp. You can do this with an async function.

For example, something like this might work:

const ping = async msg => {
  const sent = await msg.channel.send({content: 'Pong!'});
  sent.edit(`Pong! ${sent.createdTimestamp - msg.createdTimestamp}`);

Thank you for the help!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.