Skip to content

Button's or select menu's animated property can be more specific #6483

@Jiralite

Description

@Jiralite

Please describe the problem you are having in as much detail as possible:
The .animated property is only sent across if it is actually animated. Right now, if it is not sent across, it will be undefined. This could default to false instead.

Under the hood, it looks like they call this utility method:

discord.js/src/util/Util.js

Lines 301 to 313 in d6e6244

/**
* 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 };
}

Since animated there was undefined, it shows as such. But for components, this can be specified as false.

Include a reproducible code sample here, if possible:

<Client>.channels.resolve("channel_id").send({
  content: "content",
  components: [
    {
      type: "ACTION_ROW",
      components: [
        {
          type: "BUTTON",
          style: "PRIMARY",
          label: "label",
          customId: "customId",
          emoji: "non_animated_emoji",
          disabled: false
        }
      ]
    }
  ]
}).then(message => console.log(message.components[0].components[0]));
Response
MessageButton {
  type: 'BUTTON',
  label: 'label',
  customId: 'customId',
  style: 'PRIMARY',
  emoji: { id: 'id', name: 'name', animated: undefined },
  url: null,
  disabled: false
}

Further details:

  • discord.js version: 13.2.0-dev
  • Node.js version: 16.6.1
  • Operating system: macOS 11.5.1
  • Priority this issue should have – please be realistic and elaborate if possible: Low

Relevant client options:

  • partials: none
  • gateway intents: GUILDS, GUILD_MEMBERS, GUILD_EMOJIS_AND_STICKERS, GUILD_MESSAGES, GUILD_MESSAGE_REACTIONS
  • other: none
  • I have also tested the issue on latest main; Commit hash: d6e6244

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions