Javascript – Fetch message from the client Discord.js

discorddiscord.jsjavascriptnode.js

I have searched for this question and the hundreds of responses that I've found only speak of this in the terms of within the message event
E.G.

client.on('message', message => {
   message.id // <<< I don't think this is the right code for it but that's not the point I'm making so....
});

However, I need to access a message via its id without using the message event. Specifically, I need to within the messageReactionAdd event however I would much rather learn how to get it from the client because I've needed to do the same thing in the past as well (but instead I was forced to redesign my original plans).
This is the code that I've tried using but it just won't work:

client.channels.cache.get("Channel_Id").messages.fetch("Message_Id");

I was led to this code string from a different project where I found the first message in a channel:

client.channels.cache.get("Channel_Id").messages.fetch({ limit: 1 }).then(messages => {var lastMessage = messages.first();});

Is this even possible? I find it a little strange that there isn't an easy way to just target a message directly without jumping through a bunch of hoops (like client.messages.fetch("Message_Id")). Any help would be much appreciated.

Best Answer

The first version of fetching should work. Note however, that messageReactionAdd event is emitted only for messages that are cached by your bot. Cached messages are those that are received after you start up your bot, up to (by default) 200 messages per channel.

If you want to fetch only one specific message to receive reaction events for, this should work, as long as it's in a channel that you don't have to worry about mentioned earlier limit.

However, as you are using v12, there is a feature that allows to receive events for uncached structure called Partials (here is the guide page for it). If you enable partials, you can receive events for your message without the need to fetch it beforehand. Just remember that you receive only IDs this way, but with ability to fetch if needed.