From 1105ec9abc35f0e95b91174b0e88833f52d0efeb Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Mon, 14 Jul 2025 22:11:04 +0100 Subject: [PATCH] feat(channel)!: New pinned messages routes (#10988) * feat(channel): new pinned messages routes * fix: `query` is optional Co-authored-by: Almeida --------- Co-authored-by: Almeida --- packages/core/src/api/channel.ts | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/core/src/api/channel.ts b/packages/core/src/api/channel.ts index 9f038d0f3..a25f948e3 100644 --- a/packages/core/src/api/channel.ts +++ b/packages/core/src/api/channel.ts @@ -10,9 +10,10 @@ import { type RESTGetAPIChannelMessageReactionUsersQuery, type RESTGetAPIChannelMessageReactionUsersResult, type RESTGetAPIChannelMessageResult, + type RESTGetAPIChannelMessagesPinsQuery, + type RESTGetAPIChannelMessagesPinsResult, type RESTGetAPIChannelMessagesQuery, type RESTGetAPIChannelMessagesResult, - type RESTGetAPIChannelPinsResult, type RESTGetAPIChannelResult, type RESTGetAPIChannelThreadsArchivedQuery, type RESTGetAPIChannelUsersThreadsArchivedResult, @@ -340,20 +341,29 @@ export class ChannelsAPI { } /** - * Fetches the pinned messages of a channel + * Fetches pinned messages of a channel * - * @see {@link https://discord.com/developers/docs/resources/channel#get-pinned-messages} + * @see {@link https://discord.com/developers/docs/resources/message#get-channel-pins} * @param channelId - The id of the channel to fetch pinned messages from - * @param options - The options for fetching the pinned messages + * @param query - The query options for fetching pinned messages + * @param options - The options for fetching pinned messages */ - public async getPins(channelId: Snowflake, { auth, signal }: Pick = {}) { - return this.rest.get(Routes.channelPins(channelId), { auth, signal }) as Promise; + public async getPins( + channelId: Snowflake, + query: RESTGetAPIChannelMessagesPinsQuery = {}, + { auth, signal }: Pick = {}, + ) { + return this.rest.get(Routes.channelMessagesPins(channelId), { + auth, + query: makeURLSearchParams(query), + signal, + }) as Promise; } /** * Pins a message in a channel * - * @see {@link https://discord.com/developers/docs/resources/channel#pin-message} + * @see {@link https://discord.com/developers/docs/resources/message#pin-message} * @param channelId - The id of the channel to pin the message in * @param messageId - The id of the message to pin * @param options - The options for pinning the message @@ -363,7 +373,7 @@ export class ChannelsAPI { messageId: Snowflake, { auth, reason, signal }: Pick = {}, ) { - await this.rest.put(Routes.channelPin(channelId, messageId), { auth, reason, signal }); + await this.rest.put(Routes.channelMessagesPin(channelId, messageId), { auth, reason, signal }); } /** @@ -439,7 +449,7 @@ export class ChannelsAPI { /** * Unpins a message in a channel * - * @see {@link https://discord.com/developers/docs/resources/channel#unpin-message} + * @see {@link https://discord.com/developers/docs/resources/message#unpin-message} * @param channelId - The id of the channel to unpin the message in * @param messageId - The id of the message to unpin * @param options - The options for unpinning the message @@ -449,7 +459,7 @@ export class ChannelsAPI { messageId: Snowflake, { auth, reason, signal }: Pick = {}, ) { - await this.rest.delete(Routes.channelPin(channelId, messageId), { auth, reason, signal }); + await this.rest.delete(Routes.channelMessagesPin(channelId, messageId), { auth, reason, signal }); } /**