summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/structures/ReactionEmoji.js
diff options
context:
space:
mode:
author8cy <[email protected]>2020-04-03 02:37:42 -0700
committer8cy <[email protected]>2020-04-03 02:37:42 -0700
commit60867fb030bae582082340ead7dbc7efdc2f5398 (patch)
tree4c6a7356351be2e4914e15c4703172597c45656e /node_modules/discord.js/src/structures/ReactionEmoji.js
parentcommenting (diff)
downloads5nical-60867fb030bae582082340ead7dbc7efdc2f5398.tar.xz
s5nical-60867fb030bae582082340ead7dbc7efdc2f5398.zip
2020/04/03, 02:34, v1.2.0
Diffstat (limited to 'node_modules/discord.js/src/structures/ReactionEmoji.js')
-rw-r--r--node_modules/discord.js/src/structures/ReactionEmoji.js98
1 files changed, 98 insertions, 0 deletions
diff --git a/node_modules/discord.js/src/structures/ReactionEmoji.js b/node_modules/discord.js/src/structures/ReactionEmoji.js
new file mode 100644
index 0000000..9f7597e
--- /dev/null
+++ b/node_modules/discord.js/src/structures/ReactionEmoji.js
@@ -0,0 +1,98 @@
+const Constants = require('../util/Constants');
+const Snowflake = require('../util/Snowflake');
+
+/**
+ * Represents a limited emoji set used for both custom and unicode emojis. Custom emojis
+ * will use this class opposed to the Emoji class when the client doesn't know enough
+ * information about them.
+ */
+class ReactionEmoji {
+ constructor(reaction, emoji) {
+ /**
+ * The client that instantiated this object
+ * @name ReactionEmoji#client
+ * @type {Client}
+ * @readonly
+ */
+ Object.defineProperty(this, 'client', { value: reaction.message.client });
+
+ /**
+ * The message reaction this emoji refers to
+ * @type {MessageReaction}
+ */
+ this.reaction = reaction;
+
+ /**
+ * The name of this reaction emoji
+ * @type {string}
+ */
+ this.name = emoji.name;
+
+ /**
+ * The ID of this reaction emoji
+ * @type {?Snowflake}
+ */
+ this.id = emoji.id;
+
+ /**
+ * Whether this reaction emoji is animated
+ * @type {boolean}
+ */
+ this.animated = emoji.animated || false;
+ }
+
+ /**
+ * The timestamp the reaction emoji was created at, or null if unicode
+ * @type {?number}
+ * @readonly
+ */
+ get createdTimestamp() {
+ if (!this.id) return null;
+ return Snowflake.deconstruct(this.id).timestamp;
+ }
+
+ /**
+ * The time the reaction emoji was created, or null if unicode
+ * @type {?Date}
+ * @readonly
+ */
+ get createdAt() {
+ if (!this.id) return null;
+ return new Date(this.createdTimestamp);
+ }
+
+ /**
+ * The URL to the reaction emoji file, or null if unicode
+ * @type {string}
+ * @readonly
+ */
+ get url() {
+ if (!this.id) return null;
+ return Constants.Endpoints.CDN(this.client.options.http.cdn).Emoji(this.id, this.animated ? 'gif' : 'png');
+ }
+
+ /**
+ * The identifier of this emoji, used for message reactions
+ * @type {string}
+ * @readonly
+ */
+ get identifier() {
+ if (this.id) return `${this.name}:${this.id}`;
+ return encodeURIComponent(this.name);
+ }
+
+ /**
+ * Creates the text required to form a graphical emoji on Discord.
+ * @example
+ * // Send the emoji used in a reaction to the channel the reaction is part of
+ * reaction.message.channel.send(`The emoji used is ${reaction.emoji}`);
+ * @returns {string}
+ */
+ toString() {
+ if (!this.id) return this.name;
+
+ return `<${this.animated ? 'a' : ''}:${this.name}:${this.id}>`;
+ }
+}
+
+module.exports = ReactionEmoji;