forewarning: okay, i spent like 2 hours figuring out why my reaction abstraction for my chat bot didn't work, and my head is aching
I'll keep it as concise as possible:
problem: the "messageReactionAdd" isn't called
probable cause: (as a list of events that leads to the bug)
if (this.reactions.has(emojiID)) {if (reaction.users.has(user.id)) {propsed solution: can't make a pull request atm, but you'd have to somehow preserve the list of users of all reactions AND fix up the encodeURIComponent calls
This should be fixed in my pr #1236 , if you have a moment can you try npm i bdistin/discord.js to insure that pr fixed all issues listed here? If it doesnt let me know, so i can fix any remaining issues.
after removing my detour of Message.patch and installing your fork of discord.js, the issue is still unresolved.
I'll go debug later today for you and see what's going wrong
for reference, here's my hacky runtime detour to solve the problem
// !!! UNSAFE !!!
try {
let oldPatch:Function = Discord.Message.prototype["patch"];
let detouredPatch:(this: Discord.Message,data: any) => void = function(data) {
let self = this;
this.reactions["oldClear"] = this.reactions["oldClear"] || this.reactions.clear;
let reactUsers = {};
this.reactions.clear = function() {
this.forEach((reaction,key) => {
reactUsers[key] = reaction.users;
});
self.reactions["oldClear"].apply(this,[]);
} as (this: Discord.Collection<string,Discord.MessageReaction>) => void;
if(data.reactions) {
for(let reaction of data.reactions) {
reaction.emoji._name = reaction.emoji.name;
reaction.emoji.name = encodeURIComponent(reaction.emoji.name);
}
}
oldPatch.apply(this,[data]);
if(data.reactions) {
for(let reaction of data.reactions) {
reaction.emoji.name = reaction.emoji._name;
}
}
this.reactions.clear = this.reactions["oldClear"];
this.reactions.forEach((reaction,key) => {
if(reactUsers[key]) {
reaction.users = reactUsers[key];
}
});
}
Discord.Message.prototype["patch"] = detouredPatch;
}
catch(e) {
io.error("discord detours failed: " + e.toString());
}
Most helpful comment
This should be fixed in my pr #1236 , if you have a moment can you try
npm i bdistin/discord.jsto insure that pr fixed all issues listed here? If it doesnt let me know, so i can fix any remaining issues.