mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 17:43:30 +01:00
feat: general component improvements (#5787)
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
* * **`User`**
|
||||
* * **`CommandInteraction`**
|
||||
* * **`MessageComponentInteraction`**
|
||||
* * **`ButtonInteraction`**
|
||||
* @typedef {string} ExtendableStructure
|
||||
*/
|
||||
|
||||
@@ -113,6 +114,7 @@ const structures = {
|
||||
User: require('../structures/User'),
|
||||
CommandInteraction: require('../structures/CommandInteraction'),
|
||||
MessageComponentInteraction: require('../structures/MessageComponentInteraction'),
|
||||
ButtonInteraction: require('../structures/ButtonInteraction'),
|
||||
};
|
||||
|
||||
module.exports = Structures;
|
||||
|
||||
@@ -267,6 +267,20 @@ class Util {
|
||||
return { animated: Boolean(m[1]), name: m[2], id: m[3] || null };
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a partial emoji object from an {@link EmojiIdentifierResolvable}, without checking a Client.
|
||||
* @param {EmojiIdentifierResolvable} emoji Emoji identifier to resolve
|
||||
* @returns {?RawEmoji}
|
||||
* @private
|
||||
*/
|
||||
static resolvePartialEmoji(emoji) {
|
||||
if (!emoji) return null;
|
||||
if (typeof emoji === 'string') return /^\d{17,19}$/.test(emoji) ? { id: emoji } : Util.parseEmoji(emoji);
|
||||
const { id, name, animated } = emoji;
|
||||
if (!id && !name) return null;
|
||||
return { id, name, animated };
|
||||
}
|
||||
|
||||
/**
|
||||
* Shallow-copies an object with its class/prototype intact.
|
||||
* @param {Object} obj Object to clone
|
||||
|
||||
Reference in New Issue
Block a user