From c1b1c7bd3fb628e5055f4ae96b9f08befaa35537 Mon Sep 17 00:00:00 2001 From: pakkographic <41129374+pakkographic@users.noreply.github.com> Date: Sun, 7 Jul 2024 14:53:14 +0200 Subject: [PATCH] Add missing query string to deleteReaction method Select user to delete reaction from instead of deleting application bot's own reactions (only works on Channel Messages) --- lib/routes/Channels.ts | 11 +++++++++-- lib/structures/Client.ts | 8 ++++++-- lib/structures/Message.ts | 7 +++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/routes/Channels.ts b/lib/routes/Channels.ts index b1907fd..754b530 100644 --- a/lib/routes/Channels.ts +++ b/lib/routes/Channels.ts @@ -541,12 +541,15 @@ export class Channels { * @param channelType Type of the selected channel. (e.g: "ChannelMessage") * @param targetID ID of the target you'd like to add the reaction to. (e.g: a message ID) * @param reaction ID of the reaction. + * @param targetUserID ID of the user to remove reaction from. + * (works only on Channel Messages | default: @me) */ async deleteReaction( channelID: string, channelType: ChannelReactionTypes, targetID: string | number, - reaction: number + reaction: number, + targetUserID?: "@me" | string ): Promise { if (channelType !== "ChannelMessage" && channelType !== "ForumThread" @@ -567,9 +570,13 @@ export class Channels { if (channelType === "Doc") endpointType = "CHANNEL_DOC_EMOTE"; if (channelType === "ChannelAnnouncement") endpointType = "CHANNEL_ANNOUNCEMENT_EMOTE"; + const query = new URLSearchParams(); + if (targetUserID && channelType === "ChannelMessage") query.set("userId", targetUserID); + return this.#manager.authRequest({ method: "DELETE", - path: endpoints[endpointType as keyof typeof endpoints](channelID, targetID as never, reaction as never, 0) + path: endpoints[endpointType as keyof typeof endpoints](channelID, targetID as never, reaction as never, 0), + query }); } diff --git a/lib/structures/Client.ts b/lib/structures/Client.ts index 15d226b..0dc2b41 100644 --- a/lib/structures/Client.ts +++ b/lib/structures/Client.ts @@ -650,18 +650,22 @@ export class Client extends TypedEmitter { * @param channelType Type of the selected channel. (e.g: "ChannelMessage") * @param targetID ID of the target you'd like to add the reaction from. (e.g: a message id) * @param reaction ID of the reaction. + * @param targetUserID ID of the user to remove reaction from. + * (works only on Channel Messages | default: @me) */ async deleteReaction( channelID: string, channelType: ChannelReactionTypes, targetID: string | number, - reaction: number + reaction: number, + targetUserID?: "@me" | string ): Promise { return this.rest.channels.deleteReaction( channelID, channelType, targetID, - reaction + reaction, + targetUserID ); } diff --git a/lib/structures/Message.ts b/lib/structures/Message.ts index 2131982..f51821d 100644 --- a/lib/structures/Message.ts +++ b/lib/structures/Message.ts @@ -320,13 +320,16 @@ export class Message extends Base { /** Remove a reaction from this message. * @param reaction ID of a reaction/emote. + * @param targetUserID ID of the user to remove reaction from. + * (works only on Channel Messages | default: @me) */ - async deleteReaction(reaction: number): Promise{ + async deleteReaction(reaction: number, targetUserID?: "@me" | string): Promise{ return this.client.rest.channels.deleteReaction( this.channelID, "ChannelMessage", this.id as string, - reaction + reaction, + targetUserID ); }