mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
fix: messageReactionRemove not emitting for partial messages (#3125)
This commit is contained in:
@@ -43,6 +43,19 @@ class GenericAction {
|
|||||||
}) :
|
}) :
|
||||||
channel.messages.get(id));
|
channel.messages.get(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getReaction(data, message, user) {
|
||||||
|
const emojiID = data.emoji.id || decodeURIComponent(data.emoji.name);
|
||||||
|
const existing = message.reactions.get(emojiID);
|
||||||
|
if (!existing && this.client.options.partials.includes(PartialTypes.MESSAGE)) {
|
||||||
|
return message.reactions.add({
|
||||||
|
emoji: data.emoji,
|
||||||
|
count: 0,
|
||||||
|
me: user.id === this.client.user.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return existing;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = GenericAction;
|
module.exports = GenericAction;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
|
const { Events } = require('../../util/Constants');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
{ user_id: 'id',
|
{ user_id: 'id',
|
||||||
@@ -31,6 +32,14 @@ class MessageReactionAdd extends Action {
|
|||||||
me: user.id === this.client.user.id,
|
me: user.id === this.client.user.id,
|
||||||
});
|
});
|
||||||
reaction._add(user);
|
reaction._add(user);
|
||||||
|
/**
|
||||||
|
* Emitted whenever a reaction is added to a cached message.
|
||||||
|
* @event Client#messageReactionAdd
|
||||||
|
* @param {MessageReaction} messageReaction The reaction object
|
||||||
|
* @param {User} user The user that applied the guild or reaction emoji
|
||||||
|
*/
|
||||||
|
this.client.emit(Events.MESSAGE_REACTION_ADD, reaction, user);
|
||||||
|
|
||||||
return { message, reaction, user };
|
return { message, reaction, user };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ class MessageReactionRemove extends Action {
|
|||||||
if (!message) return false;
|
if (!message) return false;
|
||||||
|
|
||||||
// Verify reaction
|
// Verify reaction
|
||||||
const emojiID = data.emoji.id || decodeURIComponent(data.emoji.name);
|
const reaction = this.getReaction(data, message, user);
|
||||||
const reaction = message.reactions.get(emojiID);
|
|
||||||
if (!reaction) return false;
|
if (!reaction) return false;
|
||||||
reaction._remove(user);
|
reaction._remove(user);
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,14 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Events } = require('../../../util/Constants');
|
|
||||||
|
|
||||||
module.exports = (client, packet) => {
|
module.exports = (client, packet) => {
|
||||||
const { user, reaction } = client.actions.MessageReactionAdd.handle(packet.d);
|
client.actions.MessageReactionAdd.handle(packet.d);
|
||||||
/**
|
|
||||||
* Emitted whenever a reaction is added to a cached message.
|
|
||||||
* @event Client#messageReactionAdd
|
|
||||||
* @param {MessageReaction} messageReaction The reaction object
|
|
||||||
* @param {User} user The user that applied the guild or reaction emoji
|
|
||||||
*/
|
|
||||||
if (reaction) client.emit(Events.MESSAGE_REACTION_ADD, reaction, user);
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user