feat(channel)!: New pinned messages routes (#10988)

* feat(channel): new pinned messages routes

* fix: `query` is optional

Co-authored-by: Almeida <github@almeidx.dev>

---------

Co-authored-by: Almeida <github@almeidx.dev>
This commit is contained in:
Jiralite
2025-07-14 22:11:04 +01:00
committed by GitHub
parent 7e3d4e536c
commit 1105ec9abc

View File

@@ -10,9 +10,10 @@ import {
type RESTGetAPIChannelMessageReactionUsersQuery, type RESTGetAPIChannelMessageReactionUsersQuery,
type RESTGetAPIChannelMessageReactionUsersResult, type RESTGetAPIChannelMessageReactionUsersResult,
type RESTGetAPIChannelMessageResult, type RESTGetAPIChannelMessageResult,
type RESTGetAPIChannelMessagesPinsQuery,
type RESTGetAPIChannelMessagesPinsResult,
type RESTGetAPIChannelMessagesQuery, type RESTGetAPIChannelMessagesQuery,
type RESTGetAPIChannelMessagesResult, type RESTGetAPIChannelMessagesResult,
type RESTGetAPIChannelPinsResult,
type RESTGetAPIChannelResult, type RESTGetAPIChannelResult,
type RESTGetAPIChannelThreadsArchivedQuery, type RESTGetAPIChannelThreadsArchivedQuery,
type RESTGetAPIChannelUsersThreadsArchivedResult, 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 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<RequestData, 'auth' | 'signal'> = {}) { public async getPins(
return this.rest.get(Routes.channelPins(channelId), { auth, signal }) as Promise<RESTGetAPIChannelPinsResult>; channelId: Snowflake,
query: RESTGetAPIChannelMessagesPinsQuery = {},
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
) {
return this.rest.get(Routes.channelMessagesPins(channelId), {
auth,
query: makeURLSearchParams(query),
signal,
}) as Promise<RESTGetAPIChannelMessagesPinsResult>;
} }
/** /**
* Pins a message in a channel * 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 channelId - The id of the channel to pin the message in
* @param messageId - The id of the message to pin * @param messageId - The id of the message to pin
* @param options - The options for pinning the message * @param options - The options for pinning the message
@@ -363,7 +373,7 @@ export class ChannelsAPI {
messageId: Snowflake, messageId: Snowflake,
{ auth, reason, signal }: Pick<RequestData, 'auth' | 'reason' | 'signal'> = {}, { auth, reason, signal }: Pick<RequestData, 'auth' | 'reason' | 'signal'> = {},
) { ) {
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 * 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 channelId - The id of the channel to unpin the message in
* @param messageId - The id of the message to unpin * @param messageId - The id of the message to unpin
* @param options - The options for unpinning the message * @param options - The options for unpinning the message
@@ -449,7 +459,7 @@ export class ChannelsAPI {
messageId: Snowflake, messageId: Snowflake,
{ auth, reason, signal }: Pick<RequestData, 'auth' | 'reason' | 'signal'> = {}, { auth, reason, signal }: Pick<RequestData, 'auth' | 'reason' | 'signal'> = {},
) { ) {
await this.rest.delete(Routes.channelPin(channelId, messageId), { auth, reason, signal }); await this.rest.delete(Routes.channelMessagesPin(channelId, messageId), { auth, reason, signal });
} }
/** /**