You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be very cool if we could execute a function that would go through the existing reactions on the configured messages, and assign any roles that are missing based on those. Use case is that our bot may have been offline for some time, or we're migrating from another bot that missed many reactions. This could ensure there's nothing missing, I think it would make sense to have such an option
The text was updated successfully, but these errors were encountered:
Yeah, I've been thinking about something like this too. Our bot doesn't have downtime issues, but there are cases such as reactions from people who isn't anymore in the server that could be removed with a catchUp() function to sync the roles to the reactions.
Would be good if removing the reactions of missing people was optional. And while bot may not have downtime issues, the Discord API having ones isn't that rare, and then these reactions may quickly get missed.
Here is an example code snippet on how I did this if that helps (I just put it quickly together to get the job done, so it's ugly and not safe against edge cases, but TS will catch all of these):
msg.guild.channels.resolve("CHAN_ID").messages.fetch("MSG_ID").then(message=>{message.reactions.cache.find(r=>r.emoji.name==="🖥️").users.fetch({after:"LAST_USER_ID"}).then(r=>{r.each(u=>{letgm=msg.guild.members.resolve(u.id);if(gm&&!gm.roles.cache.has("ROLE_ID")){gm.roles.add("ROLE_ID");msg.reply('adding missing role to:'+gm.user.tag);};});msg.reply('last: '+r.last().id+', size: '+r.size);});});
Generally users.fetch() should initially have no params, but it returns up to 100 users at once, so then you gotta use the r.last().id to supply to the after param to get the next ones. If returned amount is <100 or is 0, then it was the last portion. Checking against roles.cache is important, because otherwise rate limits are hit very frequently, and even if something isn't in the cache, it doesn't hurt to check it in this case (different story with removal...)
It would be very cool if we could execute a function that would go through the existing reactions on the configured messages, and assign any roles that are missing based on those. Use case is that our bot may have been offline for some time, or we're migrating from another bot that missed many reactions. This could ensure there's nothing missing, I think it would make sense to have such an option
The text was updated successfully, but these errors were encountered: