Repository: discordjs/discord.js
File: packages/discord.js/src/managers/ApplicationEmojiManager.js (JavaScript)

Code before:
   * Options used for creating an emoji of the application
   * @typedef {Object} ApplicationEmojiCreateOptions
   * @property {BufferResolvable|Base64Resolvable} attachment The image for the emoji
   * @property {string} name The name for the emoji
   */

  /**
   * Creates a new custom emoji of the application.
   * @param {ApplicationEmojiCreateOptions} options Options for creating the emoji
   * @returns {Promise<Emoji>} The created emoji
   * @example
   * // Create a new emoji from a URL
   * application.emojis.create({ attachment: 'https://i.imgur.com/w3duR07.png', name: 'rip' })
   *   .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
   *   .catch(console.error);
   * @example
   * // Create a new emoji from a file on your computer
   * application.emojis.create({ attachment: './memes/banana.png', name: 'banana' })
   *   .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
   *   .catch(console.error);
   */
  async create({ attachment: rawAttachment, name }) {
    const attachment = await resolveImage(rawAttachment);
    if (!attachment) throw new DiscordjsTypeError(ErrorCodes.ReqResourceType);

    const body = { image: attachment, name };

    const emoji = await this.client.rest.post(Routes.applicationEmojis(this.application.id), { body });
    return this._add(emoji);
  }

  /**
   * Obtains one or more emojis from Discord, or the emoji cache if they're already available.
   * @param {Snowflake} [id] The emoji's id
   * @param {BaseFetchOptions} [options] Additional options for this fetch
   * @returns {Promise<ApplicationEmoji|Collection<Snowflake, ApplicationEmoji>>}
   * @example
   * // Fetch all emojis from the application
   * application.emojis.fetch()
   *   .then(emojis => console.log(`There are ${emojis.size} emojis.`))
   *   .catch(console.error);
   * @example
   * // Fetch a single emoji
   * application.emojis.fetch('222078108977594368')
   *   .then(emoji => console.log(`The emoji name is: ${emoji.name}`))
   *   .catch(console.error);
   */
  async fetch(id, { cache = true, force = false } = {}) {
    if (id) {
      if (!force) {
        const existing = this.cache.get(id);

Review comment (suggestion):
```suggestion
  async create({ attachment, name }) {
    const image = await resolveImage(attachment);
    if (!image) throw new DiscordjsTypeError(ErrorCodes.ReqResourceType);

    const body = { image, name };
```

Code after:
   * Options used for creating an emoji of the application
   * @typedef {Object} ApplicationEmojiCreateOptions
   * @property {BufferResolvable|Base64Resolvable} attachment The image for the emoji
   * @property {string} name The name for the emoji
   */

  /**
   * Creates a new custom emoji of the application.
   * @param {ApplicationEmojiCreateOptions} options Options for creating the emoji
   * @returns {Promise<Emoji>} The created emoji
   * @example
   * // Create a new emoji from a URL
   * application.emojis.create({ attachment: 'https://i.imgur.com/w3duR07.png', name: 'rip' })
   *   .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
   *   .catch(console.error);
   * @example
   * // Create a new emoji from a file on your computer
   * application.emojis.create({ attachment: './memes/banana.png', name: 'banana' })
   *   .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
   *   .catch(console.error);
   */
  async create({ attachment, name }) {
    const image = await resolveImage(attachment);
    if (!image) throw new DiscordjsTypeError(ErrorCodes.ReqResourceType);

    const body = { image, name };

    const emoji = await this.client.rest.post(Routes.applicationEmojis(this.application.id), { body });
    return this._add(emoji);
  }

  /**
   * Obtains one or more emojis from Discord, or the emoji cache if they're already available.
   * @param {Snowflake} [id] The emoji's id
   * @param {BaseFetchOptions} [options] Additional options for this fetch
   * @returns {Promise<ApplicationEmoji|Collection<Snowflake, ApplicationEmoji>>}
   * @example
   * // Fetch all emojis from the application
   * application.emojis.fetch()
   *   .then(emojis => console.log(`There are ${emojis.size} emojis.`))
   *   .catch(console.error);
   * @example
   * // Fetch a single emoji
   * application.emojis.fetch('222078108977594368')
   *   .then(emoji => console.log(`The emoji name is: ${emoji.name}`))
   *   .catch(console.error);
   */
  async fetch(id, { cache = true, force = false } = {}) {
    if (id) {
      if (!force) {
        const existing = this.cache.get(id);