diff --git a/packages/structures/src/stickers/Sticker.ts b/packages/structures/src/stickers/Sticker.ts index c0d2890cb..1bd5c3498 100644 --- a/packages/structures/src/stickers/Sticker.ts +++ b/packages/structures/src/stickers/Sticker.ts @@ -1,6 +1,8 @@ +import { DiscordSnowflake } from '@sapphire/snowflake'; import type { APISticker } from 'discord-api-types/v10'; import { Structure } from '../Structure.js'; import { kData } from '../utils/symbols.js'; +import { isIdSet } from '../utils/type-guards.js'; import type { Partialize } from '../utils/types.js'; /** @@ -69,4 +71,19 @@ export class Sticker extends Structu public get type() { return this[kData].type; } + + /** + * The timestamp the sticker was created at + */ + public get createdTimestamp() { + return isIdSet(this.id) ? DiscordSnowflake.timestampFrom(this.id) : null; + } + + /** + * The time the sticker was created at + */ + public get createdAt() { + const createdTimestamp = this.createdTimestamp; + return createdTimestamp ? new Date(createdTimestamp) : null; + } } diff --git a/packages/structures/src/stickers/StickerPack.ts b/packages/structures/src/stickers/StickerPack.ts new file mode 100644 index 000000000..3a190d969 --- /dev/null +++ b/packages/structures/src/stickers/StickerPack.ts @@ -0,0 +1,85 @@ +import { DiscordSnowflake } from '@sapphire/snowflake'; +import type { APIStickerPack } from 'discord-api-types/v10'; +import { Structure } from '../Structure.js'; +import { kData } from '../utils/symbols.js'; +import { isIdSet } from '../utils/type-guards.js'; +import type { Partialize } from '../utils/types.js'; + +/** + * Represents a sticker pack on Discord. + * + * @typeParam Omitted - Specify the properties that will not be stored in the raw data field as a union, implement via `DataTemplate` + * @remarks has substructure `Sticker` which needs to be instantiated and stored by an extending class using it + */ +export class StickerPack extends Structure { + /** + * The template used for removing data from the raw data stored for each sticker pack + */ + public static override DataTemplate: Partial = {}; + + /** + * @param data - The raw data received from the API for the sticker pack + */ + public constructor(data: Partialize) { + super(data); + } + + /** + * The id of the sticker pack + */ + public get id() { + return this[kData].id; + } + + /** + * The name of the sticker pack + */ + public get name() { + return this[kData].name; + } + + /** + * The id of the pack's SKU + */ + public get skuId() { + return this[kData].sku_id; + } + + /** + * The id of a sticker in the pack which is shown as the pack's icon + */ + public get coverStickerId() { + return this[kData].cover_sticker_id; + } + + /** + * The description of the sticker pack + */ + public get description() { + return this[kData].description; + } + + /** + * The id of the sticker pack's banner image + * + * @see {@link https://discord.com/developers/docs/reference#image-formatting} + */ + public get bannerAssetId() { + return this[kData].banner_asset_id; + } + + /** + * The timestamp the sticker pack was created at + */ + public get createdTimestamp() { + return isIdSet(this.id) ? DiscordSnowflake.timestampFrom(this.id) : null; + } + + /** + * The time the sticker pack was created at + */ + public get createdAt() { + const createdTimestamp = this.createdTimestamp; + return createdTimestamp ? new Date(createdTimestamp) : null; + } +} diff --git a/packages/structures/src/stickers/index.ts b/packages/structures/src/stickers/index.ts index 6d55baf8e..8dd474676 100644 --- a/packages/structures/src/stickers/index.ts +++ b/packages/structures/src/stickers/index.ts @@ -1 +1,2 @@ export * from './Sticker.js'; +export * from './StickerPack.js';