简体   繁体   中英

Embed Issue: “RichEmbed field values may not be empty.”

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.

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}`);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM