I am updating a field in an embed every time a reaction gets added to a message
But when another reaction gets added aka when the field should update the count it says Cannot set properties of undefined (setting '0')
SentMessage console log:
embeds: [
MessageEmbed {
type: 'rich',
title: 'Starboard',
description: null,
url: null,
color: 16705372,
timestamp: 1660557096258,
fields: [Array],
thumbnail: [Object],
image: null,
video: null,
author: [Object],
provider: null,
footer: [Object]
}
],
Code:
const msgs = await SBChannel.messages.fetch({ limit: 100 })
const SentMessage = msgs.find(msg =>
msg.embeds.length === 1 ?
(msg.embeds[0].footer.text.startsWith(reaction.message.id) ? true : false) : false)
if (SentMessage) SentMessage.embeds.fields[0] = { name: "Reaction Count", value: `**${reaction.count}**`, inline: true }
// embed ---------
const embed = new Discord.MessageEmbed()
.setColor('YELLOW')
.setTitle('Starboard')
.addFields(
{
name: 'Reaction Count',
value: `**${reaction.count}**`,
inline: true
},
)
Edit: I have also tried SentMessage.embeds.MessageEmbed.fields[2] but it returns Cannot read properties of undefined (reading 'fields')