Add get sticker pack endpoint (#3844)

This commit is contained in:
Fleny
2024-08-11 02:36:29 +02:00
committed by GitHub
parent 895cc17106
commit bb6b8df2cf
5 changed files with 21 additions and 0 deletions

View File

@@ -406,6 +406,9 @@ export function createBotHelpers(bot: Bot): BotHelpers {
getMessages: async (channelId, options) => {
return (await bot.rest.getMessages(channelId, options)).map((res) => bot.transformers.message(bot, snakelize(res)))
},
getStickerPack: async (stickerPackId) => {
return bot.transformers.stickerPack(bot, snakelize(await bot.rest.getStickerPack(stickerPackId)))
},
getStickerPacks: async () => {
return (await bot.rest.getStickerPacks()).map((res) => bot.transformers.stickerPack(bot, snakelize(res)))
},
@@ -864,6 +867,7 @@ export interface BotHelpers {
getInvites: (guildId: BigString) => Promise<Invite[]>
getMessage: (channelId: BigString, messageId: BigString) => Promise<Message>
getMessages: (channelId: BigString, options?: GetMessagesOptions) => Promise<Message[]>
getStickerPack: (stickerPackId: BigString) => Promise<StickerPack>
getStickerPacks: () => Promise<StickerPack[]>
getOriginalInteractionResponse: (token: string) => Promise<Message>
getPinnedMessages: (channelId: BigString) => Promise<Message[]>

View File

@@ -1257,6 +1257,10 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage
return await rest.get<DiscordMessage[]>(rest.routes.channels.messages(channelId, options))
},
async getStickerPack(stickerPackId) {
return await rest.get<DiscordStickerPack>(rest.routes.stickerPack(stickerPackId))
},
async getStickerPacks() {
return await rest.get<DiscordStickerPack[]>(rest.routes.stickerPacks())
},

View File

@@ -620,6 +620,10 @@ export function createRoutes(): RestRoutes {
return '/gateway/bot'
},
stickerPack(stickerPackId) {
return `/sticker-packs/${stickerPackId}`
},
stickerPacks() {
return '/sticker-packs'
},

View File

@@ -2045,6 +2045,14 @@ export interface RestManager {
* @see {@link https://discord.com/developers/docs/resources/channel#get-channel-messages}
*/
getMessages: (channelId: BigString, options?: GetMessagesOptions) => Promise<CamelizedDiscordMessage[]>
/**
* Returns a sticker pack for the given ID.
*
* @returns A {@link CamelizedDiscordStickerPack} object.
*
* @see {@link https://discord.com/developers/docs/resources/sticker#get-sticker-pack}
*/
getStickerPack: (stickerPackId: BigString) => Promise<CamelizedDiscordStickerPack>
/**
* Returns the list of sticker packs available.
*

View File

@@ -21,6 +21,7 @@ export interface RestRoutes {
gatewayBot: () => string
// Standard Sticker Packs
stickerPacks: () => string
stickerPack: (stickerPackId: BigString) => string
/** Routes for webhook related routes. */
webhooks: {
/** Route for managing the original message sent by a webhook. */