How to access a const outside of a method (Discord.js Bot development)

So basically, my bot comes with reaction roles and it works pretty efficiently by using partials. One of the checks before assigning the given role, Is to check whether the reaction role is reacted upon the msgID that I defined in my code. (This is useful for servers that have a channel like #reaction-roles and there is always 1 message that stays there for people to react with)

That is working fine. However, I was trying to do something new with my bot where I need the msgID to be saved (because the bot repeats the msg over and over to different people), however since the const of msgID is in the method called bot.on(message) I cannot access the const anywhere outside the method. Is there any way to get around this? Perhaps a way to temp store it in a config file?

Read more here:

Content Attribution

This content was originally published by Shreyas007 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: