mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { rest } from "../../rest/rest.ts";
|
|
import { endpoints } from "../../util/constants.ts";
|
|
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
|
|
|
/** 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:")) {
|
|
reaction = reaction.substring(3, reaction.length - 1);
|
|
}
|
|
|
|
return await rest.runMethod<undefined>(
|
|
"delete",
|
|
userId
|
|
? endpoints.CHANNEL_MESSAGE_REACTION_USER(
|
|
channelId,
|
|
messageId,
|
|
reaction,
|
|
userId,
|
|
)
|
|
: endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction),
|
|
);
|
|
}
|