2022-03-19 10:37:45 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { Collection } = require('@discordjs/collection');
|
|
|
|
const Base = require('./Base');
|
|
|
|
const { Sticker } = require('./Sticker');
|
2022-03-24 10:55:32 +00:00
|
|
|
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
2022-03-19 10:37:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a pack of standard stickers.
|
|
|
|
* @extends {Base}
|
|
|
|
*/
|
|
|
|
class StickerPack extends Base {
|
|
|
|
constructor(client, pack) {
|
|
|
|
super(client);
|
|
|
|
/**
|
|
|
|
* The Sticker pack's id
|
|
|
|
* @type {Snowflake}
|
|
|
|
*/
|
|
|
|
this.id = pack.id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The stickers in the pack
|
|
|
|
* @type {Collection<Snowflake, Sticker>}
|
|
|
|
*/
|
|
|
|
this.stickers = new Collection(pack.stickers.map(s => [s.id, new Sticker(client, s)]));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The name of the sticker pack
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
this.name = pack.name;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The id of the pack's SKU
|
|
|
|
* @type {Snowflake}
|
|
|
|
*/
|
|
|
|
this.skuId = pack.sku_id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The id of a sticker in the pack which is shown as the pack's icon
|
|
|
|
* @type {?Snowflake}
|
|
|
|
*/
|
|
|
|
this.coverStickerId = pack.cover_sticker_id ?? null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The description of the sticker pack
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
this.description = pack.description;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The id of the sticker pack's banner image
|
|
|
|
* @type {?Snowflake}
|
|
|
|
*/
|
|
|
|
this.bannerId = pack.banner_asset_id ?? null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The timestamp the sticker was created at
|
|
|
|
* @type {number}
|
|
|
|
* @readonly
|
|
|
|
*/
|
|
|
|
get createdTimestamp() {
|
2022-03-24 10:55:32 +00:00
|
|
|
return SnowflakeUtil.timestampFrom(this.id);
|
2022-03-19 10:37:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The time the sticker was created at
|
|
|
|
* @type {Date}
|
|
|
|
* @readonly
|
|
|
|
*/
|
|
|
|
get createdAt() {
|
|
|
|
return new Date(this.createdTimestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The sticker which is shown as the pack's icon
|
|
|
|
* @type {?Sticker}
|
|
|
|
* @readonly
|
|
|
|
*/
|
|
|
|
get coverSticker() {
|
|
|
|
return this.coverStickerId && this.stickers.get(this.coverStickerId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The URL to this sticker pack's banner.
|
2022-03-24 10:55:32 +00:00
|
|
|
* @param {StaticImageURLOptions} [options={}] Options for the Image URL
|
2022-03-19 10:37:45 +00:00
|
|
|
* @returns {?string}
|
|
|
|
*/
|
2022-03-24 10:55:32 +00:00
|
|
|
bannerURL({ format, size } = {}) {
|
|
|
|
return this.bannerId && this.client.rest.cdn.StickerPackBanner(this.bannerId, format, size);
|
2022-03-19 10:37:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = StickerPack;
|