Whenever a message is pinned in discord, it causes the bot to crash with the following error (although it can recover with forever but that's beside the point). The pinned message can be of any type (regular or embed).
if (!value) throw new RangeError('EMBED_FIELD_VALUE');
^
RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values may not be empty.
at Function.normalizeField (..........................................\node_modules\discord.js\src\structures\MessageEmbed.js:432:23)
at ..........................................\node_modules\discord.js\src\structures\MessageEmbed.js:452:14
at Array.map (<anonymous>)
at Function.normalizeFields (..........................................\node_modules\discord.js\src\structures\MessageEmbed.js:451:8)
at MessageEmbed.addFields (..........................................\node_modules\discord.js\src\structures\MessageEmbed.js:266:42)
at Client.<anonymous> (..........................................\index.js:323:10)
at Client.emit (node:events:378:20)
at MessageCreateAction.handle (..........................................\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (..........................................\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (..........................................\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31) {
[Symbol(code)]: 'EMBED_FIELD_VALUE'
Does anyone have an idea why this happens?
Code starting from line 318 to 336 is requested.
const logs = bot.channels.cache.find(channel => channel.name === 'logs');
const notifyAdminEmbed = new Discord.MessageEmbed()
.setColor('#ff6600')
.setTitle('Keyword Used in Message')
.setDescription('@here, A member mentioned a keyword you wished to be notified about. Please investigate immediately.')
.addFields({
name: 'Message Author',
value: `<@` + message.author.id + `>`,
inline: true
}, {
name: 'Channel',
value: `<#` + message.channel.id + `>`,
inline: true
}, {
name: 'Message',
value: message.content,
inline: false
})
.setTimestamp()