Skip to content

Commit 1105ec9

Browse files
Jiralitealmeidx
andauthored
feat(channel)!: New pinned messages routes (#10988)
* feat(channel): new pinned messages routes * fix: `query` is optional Co-authored-by: Almeida <[email protected]> --------- Co-authored-by: Almeida <[email protected]>
1 parent 7e3d4e5 commit 1105ec9

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

packages/core/src/api/channel.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import {
1010
type RESTGetAPIChannelMessageReactionUsersQuery,
1111
type RESTGetAPIChannelMessageReactionUsersResult,
1212
type RESTGetAPIChannelMessageResult,
13+
type RESTGetAPIChannelMessagesPinsQuery,
14+
type RESTGetAPIChannelMessagesPinsResult,
1315
type RESTGetAPIChannelMessagesQuery,
1416
type RESTGetAPIChannelMessagesResult,
15-
type RESTGetAPIChannelPinsResult,
1617
type RESTGetAPIChannelResult,
1718
type RESTGetAPIChannelThreadsArchivedQuery,
1819
type RESTGetAPIChannelUsersThreadsArchivedResult,
@@ -340,20 +341,29 @@ export class ChannelsAPI {
340341
}
341342

342343
/**
343-
* Fetches the pinned messages of a channel
344+
* Fetches pinned messages of a channel
344345
*
345-
* @see {@link https://discord.com/developers/docs/resources/channel#get-pinned-messages}
346+
* @see {@link https://discord.com/developers/docs/resources/message#get-channel-pins}
346347
* @param channelId - The id of the channel to fetch pinned messages from
347-
* @param options - The options for fetching the pinned messages
348+
* @param query - The query options for fetching pinned messages
349+
* @param options - The options for fetching pinned messages
348350
*/
349-
public async getPins(channelId: Snowflake, { auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {}) {
350-
return this.rest.get(Routes.channelPins(channelId), { auth, signal }) as Promise<RESTGetAPIChannelPinsResult>;
351+
public async getPins(
352+
channelId: Snowflake,
353+
query: RESTGetAPIChannelMessagesPinsQuery = {},
354+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
355+
) {
356+
return this.rest.get(Routes.channelMessagesPins(channelId), {
357+
auth,
358+
query: makeURLSearchParams(query),
359+
signal,
360+
}) as Promise<RESTGetAPIChannelMessagesPinsResult>;
351361
}
352362

353363
/**
354364
* Pins a message in a channel
355365
*
356-
* @see {@link https://discord.com/developers/docs/resources/channel#pin-message}
366+
* @see {@link https://discord.com/developers/docs/resources/message#pin-message}
357367
* @param channelId - The id of the channel to pin the message in
358368
* @param messageId - The id of the message to pin
359369
* @param options - The options for pinning the message
@@ -363,7 +373,7 @@ export class ChannelsAPI {
363373
messageId: Snowflake,
364374
{ auth, reason, signal }: Pick<RequestData, 'auth' | 'reason' | 'signal'> = {},
365375
) {
366-
await this.rest.put(Routes.channelPin(channelId, messageId), { auth, reason, signal });
376+
await this.rest.put(Routes.channelMessagesPin(channelId, messageId), { auth, reason, signal });
367377
}
368378

369379
/**
@@ -439,7 +449,7 @@ export class ChannelsAPI {
439449
/**
440450
* Unpins a message in a channel
441451
*
442-
* @see {@link https://discord.com/developers/docs/resources/channel#unpin-message}
452+
* @see {@link https://discord.com/developers/docs/resources/message#unpin-message}
443453
* @param channelId - The id of the channel to unpin the message in
444454
* @param messageId - The id of the message to unpin
445455
* @param options - The options for unpinning the message
@@ -449,7 +459,7 @@ export class ChannelsAPI {
449459
messageId: Snowflake,
450460
{ auth, reason, signal }: Pick<RequestData, 'auth' | 'reason' | 'signal'> = {},
451461
) {
452-
await this.rest.delete(Routes.channelPin(channelId, messageId), { auth, reason, signal });
462+
await this.rest.delete(Routes.channelMessagesPin(channelId, messageId), { auth, reason, signal });
453463
}
454464

455465
/**

0 commit comments

Comments
 (0)