Files
discordeno/helpers/messages/removeReaction.ts
ITOH 03996c5f58 refactor: revert "feat: base plugin lib idea (#2308)" (#2336)
* Revert "feat: base plugin lib idea (#2308)"

This reverts commit ffe7cdbc6f.

* fmt
2022-07-02 14:24:43 +01:00

30 lines
890 B
TypeScript

import type { Bot } from "../../bot.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(
bot: Bot,
channelId: bigint,
messageId: bigint,
reaction: string,
options?: { userId?: bigint },
) {
if (reaction.startsWith("<:")) {
reaction = reaction.substring(2, reaction.length - 1);
} else if (reaction.startsWith("<a:")) {
reaction = reaction.substring(3, reaction.length - 1);
}
await bot.rest.runMethod<undefined>(
bot.rest,
"DELETE",
options?.userId
? bot.constants.routes.CHANNEL_MESSAGE_REACTION_USER(
channelId,
messageId,
reaction,
options.userId,
)
: bot.constants.routes.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction),
);
}