fix(handlers): support for custom emoji in reaction remove functions (#400)

This commit is contained in:
Ayyan
2021-01-19 18:10:28 +04:00
committed by GitHub
parent e56d67a138
commit 4c9171e72a
+19
View File
@@ -152,6 +152,12 @@ export function removeReaction(
messageID: string, messageID: string,
reaction: string, reaction: string,
) { ) {
if (reaction.startsWith("<:")) {
reaction = reaction.substring(2, reaction.length - 1);
} else if (reaction.startsWith("<a:")) {
reaction = reaction.substring(3, reaction.length - 1);
}
return RequestManager.delete( return RequestManager.delete(
endpoints.CHANNEL_MESSAGE_REACTION_ME( endpoints.CHANNEL_MESSAGE_REACTION_ME(
channelID, channelID,
@@ -176,6 +182,12 @@ export async function removeUserReaction(
throw new Error(Errors.MISSING_MANAGE_MESSAGES); throw new Error(Errors.MISSING_MANAGE_MESSAGES);
} }
if (reaction.startsWith("<:")) {
reaction = reaction.substring(2, reaction.length - 1);
} else if (reaction.startsWith("<a:")) {
reaction = reaction.substring(3, reaction.length - 1);
}
return RequestManager.delete( return RequestManager.delete(
endpoints.CHANNEL_MESSAGE_REACTION_USER( endpoints.CHANNEL_MESSAGE_REACTION_USER(
channelID, channelID,
@@ -217,6 +229,13 @@ export async function removeReactionEmoji(
) { ) {
throw new Error(Errors.MISSING_MANAGE_MESSAGES); throw new Error(Errors.MISSING_MANAGE_MESSAGES);
} }
if (reaction.startsWith("<:")) {
reaction = reaction.substring(2, reaction.length - 1);
} else if (reaction.startsWith("<a:")) {
reaction = reaction.substring(3, reaction.length - 1);
}
return RequestManager.delete( return RequestManager.delete(
endpoints.CHANNEL_MESSAGE_REACTION(channelID, messageID, reaction), endpoints.CHANNEL_MESSAGE_REACTION(channelID, messageID, reaction),
); );