mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
delete: removeUserReaction
This commit is contained in:
@@ -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),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Removes a reaction from the specified user on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */
|
||||
export async function removeUserReaction(
|
||||
channelId: string,
|
||||
messageId: string,
|
||||
reaction: string,
|
||||
userId: string,
|
||||
) {
|
||||
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",
|
||||
endpoints.CHANNEL_MESSAGE_REACTION_USER(
|
||||
channelId,
|
||||
messageId,
|
||||
reaction,
|
||||
userId,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -93,7 +93,6 @@ import { publishMessage } from "./messages/publish_message.ts";
|
||||
import { removeAllReactions } from "./messages/remove_all_reactions.ts";
|
||||
import { removeReaction } from "./messages/remove_reaction.ts";
|
||||
import { removeReactionEmoji } from "./messages/remove_reaction_emoji.ts";
|
||||
import { removeUserReaction } from "./messages/remove_user_reaction.ts";
|
||||
import { sendMessage } from "./messages/send_message.ts";
|
||||
import { unpin, unpinMessage } from "./messages/unpin_message.ts";
|
||||
import { editBotStatus } from "./misc/edit_bot_status.ts";
|
||||
@@ -240,7 +239,6 @@ export {
|
||||
removeReaction,
|
||||
removeReactionEmoji,
|
||||
removeRole,
|
||||
removeUserReaction,
|
||||
sendDirectMessage,
|
||||
sendInteractionResponse,
|
||||
sendMessage,
|
||||
@@ -361,7 +359,6 @@ export let helpers = {
|
||||
removeAllReactions,
|
||||
removeReactionEmoji,
|
||||
removeReaction,
|
||||
removeUserReaction,
|
||||
sendMessage,
|
||||
unpinMessage,
|
||||
// misc
|
||||
|
||||
Reference in New Issue
Block a user