-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Sticker.js
88 lines (76 loc) · 1.84 KB
/
Sticker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
'use strict';
const Base = require('./Base');
const { StickerFormatTypes } = require('../util/Constants');
const SnowflakeUtil = require('../util/SnowflakeUtil');
/**
* 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 {StickerFormatType}
*/
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 SnowflakeUtil.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;