mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 18:13:29 +01:00
fix(MessageReaction): fetching a removed partial custom emoji (#3955)
* fix: handling GuildEmoji within fetch() * refactor: remove unused "private" methods * refactor: make use of Message#fetch() to patch
This commit is contained in:
@@ -64,32 +64,6 @@ class ReactionManager extends BaseManager {
|
||||
.reactions.delete()
|
||||
.then(() => this.message);
|
||||
}
|
||||
|
||||
_partial(emoji) {
|
||||
const id = emoji.id || emoji.name;
|
||||
const existing = this.cache.get(id);
|
||||
return !existing || existing.partial;
|
||||
}
|
||||
|
||||
async _fetchReaction(reactionEmoji, cache) {
|
||||
const id = reactionEmoji.id || reactionEmoji.name;
|
||||
const existing = this.cache.get(id);
|
||||
if (!this._partial(reactionEmoji)) return existing;
|
||||
const data = await this.client.api
|
||||
.channels(this.message.channel.id)
|
||||
.messages(this.message.id)
|
||||
.get();
|
||||
if (this.message.partial) this.message._patch(data);
|
||||
if (!data.reactions || !data.reactions.some(r => (r.emoji.id || r.emoji.name) === id)) {
|
||||
reactionEmoji.reaction._patch({ count: 0 });
|
||||
this.message.reactions.cache.delete(id);
|
||||
return existing;
|
||||
}
|
||||
for (const reaction of data.reactions) {
|
||||
if (this._partial(reaction.emoji)) this.add(reaction, cache);
|
||||
}
|
||||
return existing;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ReactionManager;
|
||||
|
||||
Reference in New Issue
Block a user