Reputation: 21
Ayo! I'm having issues with outputting an embed. The only issue that puzzles me is I don't have a field without anything and it goes through and sends it in Discord and THEN errors out.
It does the same thing when I'm detecting edits, this code is within my bot.on("message", async message => {})
. Maybe that's the issue but I don't see why and where I would put it if else.
//-- Logging Deleted Messages --\\
bot.on("messageDelete", (messageDelete) => {
let deletionEmbed = new Discord.RichEmbed()
.setDescription("📝 Deleted Message 📝")
.setColor("#e56b00")
.addField("User:", `${message.author}`)
.addField("Message:", `${messageDelete}`);
let logchannel = message.guild.channels.find(`name`, "server-log");
if (!logchannel) return message.channel.send("Couldn't find a logging channel!");
logchannel.send(deletionEmbed);
});
This is the error message:
if (!/\S/.test(value)) throw new RangeError('RichEmbed field values may not be empty.');
RangeError: RichEmbed field values may not be empty.
Upvotes: 1
Views: 6600
Reputation: 2785
The most important issue first: you have the messageDelete
event handler inside your message
event. That will make a new event listener for each message that your bot receives: it'll either crash your bot because of memory issues or spam like crazy.
You need to use this outside of your message
event:
bot.on("messageDelete", (oldMessage, newMessage) => {...});
Inside that handler, use these:
.addField("User:", `${newMessage.author.tag}`)
.addField("Message:", `${oldMessage.content}`);
Upvotes: 2