Files
discordeno/helpers/misc/getNitroStickerPacks.ts
LTS20050703 17132aaf61 feat(helpers): add stickers helpers (#2466)
* helpers: add stickers helpers

* deno fmt

* undo move getNitroStickerPack to stickers

* helpers/stickers: fix jsdocs

* plugins/permissions: check stickers permissions

* plugins/validations: validate stickers stuff

* tests: stickers unit tests

* helpers/stickers: add support for reason

* plugins/permissions: MANAGE_EMOJIS -> MANAGE_EMOJIS_AND_STICKERS

* tests/stickers: delete sticker after test
createGuildSticker: add send sticker test
getGuildStickers: create another sticker then test > 1 stickers
2022-09-22 11:31:41 -04:00

28 lines
935 B
TypeScript

import { Bot } from "../../bot.ts";
import { StickerPack } from "../../transformers/sticker.ts";
import { DiscordStickerPack } from "../../types/discord.ts";
import { Collection } from "../../util/collection.ts";
/**
* Returns the list of sticker packs available to Nitro subscribers.
*
* @param bot The bot instance to use to make the request.
* @returns A collection of {@link StickerPack} objects assorted by sticker ID.
*
* @see {@link https://discord.com/developers/docs/resources/sticker#list-nitro-sticker-packs}
*/
export async function getNitroStickerPacks(bot: Bot): Promise<Collection<bigint, StickerPack>> {
const results = await bot.rest.runMethod<DiscordStickerPack[]>(
bot.rest,
"GET",
bot.constants.routes.NITRO_STICKER_PACKS(),
);
return new Collection(
results.map((result) => {
const pack = bot.transformers.stickerPack(bot, result);
return [pack.id, pack];
}),
);
}