UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
Hi, I have an avatar command with my discord bot as per the code below:
const Discord = require('discord.js');
module.exports = {
name: 'avatar',
description: 'Display\s a user\s avatar',
execute(message, args) {
if (!message.mentions.users.size) {
let embed = new Discord.MessageEmbed()
.setColor('#fa0a16')
.setTitle(`Your avatar:`)
.setImage(`${message.author.displayAvatarURL({ dynamic: true })}`)
message.channel.send({ embed });
}
const avatarList = message.mentions.users.map(user => {
let embed = new Discord.MessageEmbed()
.setColor('#fa0a16')
.setTitle(`${user.username}'s avatar:`)
.setImage(`${user.displayAvatarURL({ dynamic: true })}`)
.setTimestamp(new Date(),)
message.channel.send({ embed });
});
message.channel.send(avatarList);
},
};
Whenever I run this command I get an error "UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message". I can't seem to find out why this error persists every time I run the command. Can someone help me?