Failing to get message.reactions.cache "undefined"
Hi, I'm trying to understand why this code is giving me an errror:
The error:
await interaction.deferReply({ ephemeral: true });
//Collect Upvotes/individual rankings
const x = 0;
let messageReacted;
for (const msgID of UpvoteContainer.msgID){
//fetch message(s) of ID UpvoteContainer.msgID
messageReacted = interaction.client.channels.cache.get(interaction.channelId).messages.fetch(msgID);
//const messageReacted = client.channels.cache.get('channelId').messages.fetch('messageId')
console.log("messageReacted achievd");
//For Each Reaction on the message(s)
ERROR ==> await messageReacted.reactions.cache.forEach(async(reaction) => { <== ERROR
//const emojiName = reaction._emoji.name
//const emojiCount = reaction.count
//const reactionUsers = await reaction.users.fetch();
if (reaction.emoji.id == UpvoteContainer.emojiUpvoteID){
x += reaction.count;
}
else if (reaction.emoji.id == UpvoteContainer.emojiDownvoteID){
x =- reaction.count;
}
});
}await interaction.deferReply({ ephemeral: true });
//Collect Upvotes/individual rankings
const x = 0;
let messageReacted;
for (const msgID of UpvoteContainer.msgID){
//fetch message(s) of ID UpvoteContainer.msgID
messageReacted = interaction.client.channels.cache.get(interaction.channelId).messages.fetch(msgID);
//const messageReacted = client.channels.cache.get('channelId').messages.fetch('messageId')
console.log("messageReacted achievd");
//For Each Reaction on the message(s)
ERROR ==> await messageReacted.reactions.cache.forEach(async(reaction) => { <== ERROR
//const emojiName = reaction._emoji.name
//const emojiCount = reaction.count
//const reactionUsers = await reaction.users.fetch();
if (reaction.emoji.id == UpvoteContainer.emojiUpvoteID){
x += reaction.count;
}
else if (reaction.emoji.id == UpvoteContainer.emojiDownvoteID){
x =- reaction.count;
}
});
}The error:
TypeError: Cannot read properties of undefined (reading 'cache')TypeError: Cannot read properties of undefined (reading 'cache')