Discord.js UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot Send An Empty Message

- 1 answer

Ok, so I just started working on a discord bot and implemented a command handler, and I immediately ran into some problems.

const Discord = require("discord.js");
module.exports = {
  name: "kick",
  description: "Kicks the mentioned user",
  execute(message, args) {
    const user = message.mentions.users.first();

    if (user) {
      const member = message.guild.member(user);
      try {
        const kickEmbed = new Discord.RichEmbed()
          .setTitle("You were Kicked")
          .setDescription("You were kicked from Bot Testing Server.");
        user.send({ kickEmbed }).then(() => {
      } catch (err) {
        console.log("failed to kick user");

when i execute the kick command in my server, I get the following error

UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message

I can't seem to find anything wrong with the code so, where's the error



When sending an embed that uses the Discord Rich Embed builder you don't need to use the curly brackets. Instead of user.send({ kickEmbed }) you should do user.send(kickEmbed). I ran into that issue before and it helped in my case.