Reputation: 11
I have a piece of code that logs if someone has edited their message. It works perfectly, it shows the old message, the new one, the channel and more. But, I still get an error that says that my RichEmbed fields are empty. They aren't empty and they work! The error apparently occurs on line 198 - .addField('Original:',
${oldMessage.content})
This is for a bot I am making for Discord. I can't find any help anywhere.
Here is my code:
bot.on('messageUpdate', async(oldMessage, newMessage) => {
const emb8 = new Discord.RichEmbed()
.setTitle(':pencil: Message Edited')
.setDescription('A user has edited a message.')
.addField('Guild:', `${newMessage.guild.name}`)
.addField('User:', `${newMessage.author.tag}`)
.addField('Original:', `${oldMessage.content}`)
.addField('Edited to:', `${newMessage.content}`)
.addField('Channel:', `<#${newMessage.channel.id}>`)
.addField('Time:', `${newMessage.createdAt}`)
.setColor(0xFF9800)
.setFooter('Sublime | Logs', 'https://file.coffee/WdTuqTwGF.PNG')
bot.channels.get(`603943993348325392`).send(emb8)
});
It looks exactly how I want it to look, but for some reason I get this error:
js (node:162592) UnhandledPromiseRejectionWarning: RangeError: RichEmbed field values may not be empty. at RichEmbed.addField (E:\Sublime-Project\node_modules\discord.js\src\structures\RichEmbed.js:166:34) at CommandoClient.bot.on (E:\Sublime-Project\index.js:193:3) at CommandoClient.emit (events.js:202:15) at MessageUpdateAction.handle (E:\Sublime-Project\node_modules\discord.js\src\client\actions\MessageUpdate.js:13:16) at MessageUpdateHandler.handle (E:\Sublime-Project\node_modules\discord.js\src\client\websocket\packets\handlers\MessageUpdate.js:7:34) at WebSocketPacketManager.handle (E:\Sublime-Project\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65) at WebSocketConnection.onPacket (E:\Sublime-Project\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35) at WebSocketConnection.onMessage (E:\Sublime-Project\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17) at WebSocket.onMessage (E:\Sublime-Project\node_modules\ws\lib\event-target.js:120:16) at WebSocket.emit (events.js:197:13) (node:162592) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 85)
Upvotes: 1
Views: 252
Reputation: 884
I met same error some months ago, please check your relevant Promises. The reason is that you've called a reject function in your promise, but you didn't handle it.
Upvotes: 1