diff --git a/packages/discord.js/src/managers/BaseGuildEmojiManager.js b/packages/discord.js/src/managers/BaseGuildEmojiManager.js index 89eee4c95a32..305c1aaa9594 100644 --- a/packages/discord.js/src/managers/BaseGuildEmojiManager.js +++ b/packages/discord.js/src/managers/BaseGuildEmojiManager.js @@ -1,6 +1,7 @@ 'use strict'; const CachedManager = require('./CachedManager'); +const ApplicationEmoji = require('../structures/ApplicationEmoji'); const GuildEmoji = require('../structures/GuildEmoji'); const ReactionEmoji = require('../structures/ReactionEmoji'); const { parseEmoji } = require('../util/Util'); @@ -25,7 +26,8 @@ class BaseGuildEmojiManager extends CachedManager { * * A Snowflake * * A GuildEmoji object * * A ReactionEmoji object - * @typedef {Snowflake|GuildEmoji|ReactionEmoji} EmojiResolvable + * * An ApplicationEmoji object + * @typedef {Snowflake|GuildEmoji|ReactionEmoji|ApplicationEmoji} EmojiResolvable */ /** @@ -35,6 +37,7 @@ class BaseGuildEmojiManager extends CachedManager { */ resolve(emoji) { if (emoji instanceof ReactionEmoji) return super.resolve(emoji.id); + if (emoji instanceof ApplicationEmoji) return super.resolve(emoji.id); return super.resolve(emoji); } @@ -45,6 +48,7 @@ class BaseGuildEmojiManager extends CachedManager { */ resolveId(emoji) { if (emoji instanceof ReactionEmoji) return emoji.id; + if (emoji instanceof ApplicationEmoji) return emoji.id; return super.resolveId(emoji); } @@ -65,6 +69,7 @@ class BaseGuildEmojiManager extends CachedManager { const emojiResolvable = this.resolve(emoji); if (emojiResolvable) return emojiResolvable.identifier; if (emoji instanceof ReactionEmoji) return emoji.identifier; + if (emoji instanceof ApplicationEmoji) return emoji.identifier; if (typeof emoji === 'string') { const res = parseEmoji(emoji); if (res?.name.length) { diff --git a/packages/discord.js/src/structures/MessageReaction.js b/packages/discord.js/src/structures/MessageReaction.js index 45103b553c01..283156465df3 100644 --- a/packages/discord.js/src/structures/MessageReaction.js +++ b/packages/discord.js/src/structures/MessageReaction.js @@ -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'); @@ -108,16 +109,24 @@ 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 applicationEmojis = this.message.client.application.emojis.cache; + if (applicationEmojis.has(this._emoji.id)) { + const emoji = applicationEmojis.get(this._emoji.id); + this._emoji = emoji; + return emoji; + } const emojis = this.message.client.emojis.cache; if (emojis.has(this._emoji.id)) { const emoji = emojis.get(this._emoji.id); diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 94b76ff48ef2..c28be62901c2 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -2462,13 +2462,13 @@ export class MessagePayload { export class MessageReaction { private constructor(client: Client, data: RawMessageReactionData, message: Message); - private _emoji: GuildEmoji | ReactionEmoji; + private _emoji: GuildEmoji | ReactionEmoji | ApplicationEmoji; public burstColors: string[] | null; public readonly client: Client; public count: number; public countDetails: ReactionCountDetailsData; - public get emoji(): GuildEmoji | ReactionEmoji; + public get emoji(): GuildEmoji | ReactionEmoji | ApplicationEmoji; public me: boolean; public meBurst: boolean; public message: Message | PartialMessage; @@ -5709,7 +5709,7 @@ export type EmojiIdentifierResolvable = | `<${'' | 'a'}:${string}:${Snowflake}>` | string; -export type EmojiResolvable = Snowflake | GuildEmoji | ReactionEmoji; +export type EmojiResolvable = Snowflake | GuildEmoji | ReactionEmoji | ApplicationEmoji; export interface FetchApplicationCommandOptions extends BaseFetchOptions { guildId?: Snowflake;