mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
feat(Sticker): added Sticker (#4909)
Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com> Co-authored-by: monbrey <rsm999@uowmail.edu.au> Co-authored-by: SpaceEEC <spaceeec@yahoo.com> Co-authored-by: Antonio Román <kyradiscord@gmail.com> Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> Co-authored-by: Tristan Guichaoua <33934311+tguichaoua@users.noreply.github.com> Co-authored-by: Advaith <advaithj1@gmail.com> Co-authored-by: izexi <43889168+izexi@users.noreply.github.com> Co-authored-by: Mestery <48163546+Mesteery@users.noreply.github.com> Co-authored-by: Jan <66554238+vaporox@users.noreply.github.com>
This commit is contained in:
88
src/structures/Sticker.js
Normal file
88
src/structures/Sticker.js
Normal file
@@ -0,0 +1,88 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
const { StickerFormatTypes } = require('../util/Constants');
|
||||
const Snowflake = require('../util/Snowflake');
|
||||
|
||||
/**
|
||||
* Represents a Sticker.
|
||||
* @extends {Base}
|
||||
*/
|
||||
class Sticker extends Base {
|
||||
constructor(client, sticker) {
|
||||
super(client);
|
||||
/**
|
||||
* The ID of the sticker
|
||||
* @type {Snowflake}
|
||||
*/
|
||||
this.id = sticker.id;
|
||||
|
||||
/**
|
||||
* The ID of the sticker's image
|
||||
* @type {string}
|
||||
*/
|
||||
this.asset = sticker.asset;
|
||||
|
||||
/**
|
||||
* The description of the sticker
|
||||
* @type {string}
|
||||
*/
|
||||
this.description = sticker.description;
|
||||
|
||||
/**
|
||||
* The format of the sticker
|
||||
* @type {StickerFormatTypes}
|
||||
*/
|
||||
this.format = StickerFormatTypes[sticker.format_type];
|
||||
|
||||
/**
|
||||
* The name of the sticker
|
||||
* @type {string}
|
||||
*/
|
||||
this.name = sticker.name;
|
||||
|
||||
/**
|
||||
* The ID of the pack the sticker is from
|
||||
* @type {Snowflake}
|
||||
*/
|
||||
this.packID = sticker.pack_id;
|
||||
|
||||
/**
|
||||
* An array of tags for the sticker, if any
|
||||
* @type {string[]}
|
||||
*/
|
||||
this.tags = sticker.tags?.split(', ') ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp the sticker was created at
|
||||
* @type {number}
|
||||
* @readonly
|
||||
*/
|
||||
get createdTimestamp() {
|
||||
return Snowflake.deconstruct(this.id).timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* The time the sticker was created at
|
||||
* @type {Date}
|
||||
* @readonly
|
||||
*/
|
||||
get createdAt() {
|
||||
return new Date(this.createdTimestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* A link to the sticker
|
||||
* <info>If the sticker's format is LOTTIE, it returns the URL of the Lottie json file.
|
||||
* Lottie json files must be converted in order to be displayed in Discord.</info>
|
||||
* @type {string}
|
||||
*/
|
||||
get url() {
|
||||
return `${this.client.options.http.cdn}/stickers/${this.id}/${this.asset}.${
|
||||
this.format === 'LOTTIE' ? 'json' : 'png'
|
||||
}`;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Sticker;
|
||||
Reference in New Issue
Block a user