Skip to content
Advertisement

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?

Advertisement

Answer

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement