mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Improved EmojiIdentifierResolvable support (#1361)
* EmojiIdentifierResolvable now supports emoji IDs and pre-encoded unicode * forgot to return the identifier and not the emoji itself * using ? in JSDoc instead of |null
This commit is contained in:
@@ -236,21 +236,24 @@ class ClientDataResolver {
|
||||
|
||||
/**
|
||||
* Data that can be resolved to give an emoji identifier. This can be:
|
||||
* * A string
|
||||
* * An Emoji
|
||||
* * A ReactionEmoji
|
||||
* * The unicode representation of an emoji
|
||||
* * A custom emoji ID
|
||||
* * An Emoji object
|
||||
* * A ReactionEmoji object
|
||||
* @typedef {string|Emoji|ReactionEmoji} EmojiIdentifierResolvable
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resolves an EmojiResolvable to an emoji identifier
|
||||
* @param {EmojiIdentifierResolvable} emoji The emoji resolvable to resolve
|
||||
* @returns {string}
|
||||
* @returns {?string}
|
||||
*/
|
||||
resolveEmojiIdentifier(emoji) {
|
||||
if (emoji instanceof Emoji || emoji instanceof ReactionEmoji) return emoji.identifier;
|
||||
if (typeof emoji === 'string') {
|
||||
if (!emoji.includes('%')) return encodeURIComponent(emoji);
|
||||
if (!isNaN(parseInt(emoji))) return this.client.emojis.get(emoji).identifier;
|
||||
else if (!emoji.includes('%')) return encodeURIComponent(emoji);
|
||||
else return emoji;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user