Files
discordeno/helpers/stickers/getGuildStickers.ts
T
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

30 lines
993 B
TypeScript

import { Bot } from "../../bot.ts";
import { Collection, Sticker } from "../../mod.ts";
import { DiscordSticker } from "../../types/discord.ts";
/**
* Returns an array of sticker objects for the given guild.
*
* @param bot The bot instance to use to make the request.
* @param guildId The ID of the guild to get
* @returns A collection of {@link Sticker} objects assorted by sticker ID.
*
* @remarks Includes user fields if the bot has the `MANAGE_EMOJIS_AND_STICKERS` permission.
*
* @see {@link https://discord.com/developers/docs/resources/sticker#list-guild-stickers}
*/
export async function getGuildStickers(bot: Bot, guildId: bigint): Promise<Collection<bigint, Sticker>> {
const results = await bot.rest.runMethod<DiscordSticker[]>(
bot.rest,
"GET",
bot.constants.routes.GUILD_STICKERS(guildId),
);
return new Collection(
results.map((result) => {
const pack = bot.transformers.sticker(bot, result);
return [pack.id, pack];
}),
);
}