delete: removeUserReaction

This commit is contained in:
ITOH
2021-04-30 15:22:48 +02:00
parent a7de104b9a
commit 8c347747dd
5 changed files with 24 additions and 45 deletions
+15 -2
View File
@@ -1,12 +1,18 @@
import { rest } from "../../rest/rest.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotChannelPermissions } from "../../util/permissions.ts";
/** Removes a reaction from the bot on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */
/** Removes a reaction from the given user on this message, defaults to bot. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */
export async function removeReaction(
channelId: string,
messageId: string,
reaction: string,
userId?: string,
) {
if (userId) {
await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]);
}
if (reaction.startsWith("<:")) {
reaction = reaction.substring(2, reaction.length - 1);
} else if (reaction.startsWith("<a:")) {
@@ -15,6 +21,13 @@ export async function removeReaction(
return await rest.runMethod<undefined>(
"delete",
endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction),
userId
? endpoints.CHANNEL_MESSAGE_REACTION_USER(
channelId,
messageId,
reaction,
userId,
)
: endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction),
);
}