mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
fix: reaction remove tests (#811)
This commit is contained in:
@@ -11,12 +11,16 @@ export async function handleMessageReactionRemove(
|
||||
|
||||
if (message) {
|
||||
const reaction = message.reactions?.find((reaction) =>
|
||||
reaction.emoji.id === payload.emoji.id &&
|
||||
// MUST USE == because discord sends null and we use undefined
|
||||
reaction.emoji.id == payload.emoji.id &&
|
||||
reaction.emoji.name === payload.emoji.name
|
||||
);
|
||||
|
||||
if (reaction) {
|
||||
reaction.count--;
|
||||
if (reaction.count === 0) message.reactions = message.reactions?.filter(r => r.count !== 0);
|
||||
if (!message.reactions?.length) message.reactions = undefined;
|
||||
|
||||
await cacheHandlers.set("messages", payload.message_id, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,16 @@ export async function handleMessageReactionRemoveEmoji(
|
||||
const message = await cacheHandlers.get("messages", payload.message_id);
|
||||
|
||||
if (message?.reactions) {
|
||||
message.reactions = message.reactions?.filter(
|
||||
message.reactions = message.reactions.filter(
|
||||
(reaction) =>
|
||||
!(
|
||||
reaction.emoji.id === payload.emoji.id &&
|
||||
// MUST USE == because discord sends null and we use undefined
|
||||
reaction.emoji.id == payload.emoji.id &&
|
||||
reaction.emoji.name === payload.emoji.name
|
||||
),
|
||||
);
|
||||
|
||||
if (!message.reactions.length) message.reactions = undefined
|
||||
|
||||
await cacheHandlers.set("messages", payload.message_id, message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user