0

I'm trying to dynamically check for reactions on the message that was replied to, and it works fine when I paste the literal message id, but when I assign it to a variable, it gives a TypeError: Cannot read properties of null (reading 'users').

I used msg.fetchReference() to get the reference message, and it's assigned to repliedTo. I've confirmed that repliedTo.id gives the id that worked when I pasted it in, and that the variable returns a string.

cacheChannel.messages.fetch(repliedTo.id).then(reactionMessage => {
    reactionMessage.reactions.resolve('').users.fetch().then(userList => {
        userList.map((user) => {
            if (user.id === 'testID') {
                console.log('already reacted');
            }
        });
    });
});

Side note: I originally tried this without trying to fetch the message as it is now, and just using repliedTo instead of reactionMessage, but I had the same issue.

Dkunk7
  • 1

1 Answers1

0

In your code you are using === which also checks if x1 and x2 have the same data types! As you said, variable returns you a String, when user.id is a Number, so I'd recommend to try changing === to ==, which only checks value! Also here is an explanation how it works!

MegaMix_Craft
  • 1,853
  • 2
  • 6
  • 26
  • That doesn't fix my problem. I think the issue occurs before it gets to the user.id part. I'm almost positive that it doesn't like something about using repliedTo.id instead of the id itself, which I was copying from the message in discord. – Dkunk7 Jun 04 '22 at 20:57