Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add ApplicationEmoji to EmojiResolvable and MessageReaction#emoji #10477

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
16 changes: 13 additions & 3 deletions packages/discord.js/src/structures/MessageReaction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const { Routes } = require('discord-api-types/v10');
const ApplicationEmoji = require('./ApplicationEmoji');
const GuildEmoji = require('./GuildEmoji');
const ReactionEmoji = require('./ReactionEmoji');
const ReactionUserManager = require('../managers/ReactionUserManager');
Expand Down Expand Up @@ -108,21 +109,30 @@ class MessageReaction {
}

/**
* The emoji of this reaction. Either a {@link GuildEmoji} object for known custom emojis, or a {@link ReactionEmoji}
* object which has fewer properties. Whatever the prototype of the emoji, it will still have
* The emoji of this reaction. Either a {@link GuildEmoji} object for known custom emojis,
* {@link ApplicationEmoji} for application emojis, or a {@link ReactionEmoji} object
* which has fewer properties. Whatever the prototype of the emoji, it will still have
* `name`, `id`, `identifier` and `toString()`
* @type {GuildEmoji|ReactionEmoji}
* @type {GuildEmoji|ReactionEmoji|ApplicationEmoji}
* @readonly
*/
get emoji() {
if (this._emoji instanceof GuildEmoji) return this._emoji;
if (this._emoji instanceof ApplicationEmoji) return this._emoji;
// Check to see if the emoji has become known to the client
if (this._emoji.id) {
const emojis = this.message.client.emojis.cache;
if (emojis.has(this._emoji.id)) {
const emoji = emojis.get(this._emoji.id);
this._emoji = emoji;
return emoji;
} else {
const applicationEmojis = this.message.client.application.emojis.cache;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be moved under line 124

if (applicationEmojis.has(this._emoji.id)) {
const emoji = applicationEmojis.get(this._emoji.id);
this._emoji = emoji;
return emoji;
}
}
}
return this._emoji;
Expand Down