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

Code before:
      if (typeof icon !== 'string') icon = undefined;
    }

    const colors = options.colors && {
      primary_color: resolveColor(options.colors.primaryColor),
      secondary_color: options.colors.secondaryColor && resolveColor(options.colors.secondaryColor),
      tertiary_color: options.colors.tertiaryColor && resolveColor(options.colors.tertiaryColor),
    };

    const data = await this.client.rest.post(Routes.guildRoles(this.guild.id), {
      body: {
        name,
        color,
        colors,
        hoist,
        permissions,
        mentionable,
        icon,
        unicode_emoji: unicodeEmoji,
      },
      reason,
    });
    const { role } = this.client.actions.GuildRoleCreate.handle({
      guild_id: this.guild.id,
      role: data,
    });
    if (position) return this.setPosition(role, position, { reason });
    return role;
  }

  /**
   * Options for editing a role
   *
   * @typedef {RoleData} RoleEditOptions
   * @property {string} [reason] The reason for editing this role
   */

  /**
   * Edits a role of the guild.
   *
   * @param {RoleResolvable} role The role to edit
   * @param {RoleEditOptions} options The options to provide
   * @returns {Promise<Role>}
   * @example
   * // Edit a role
   * guild.roles.edit('222079219327434752', { name: 'buddies' })
   *   .then(updated => console.log(`Edited role name to ${updated.name}`))
   *   .catch(console.error);
   */
  async edit(role, options) {
    const resolvedRole = this.resolve(role);

Review comment (suggestion):
We shouldn't send color and colors here. Instead (if we keep the color option, which we shouldn't imho, see above) colors should be assigned the value `colors ??= {primary_color: color}` or rather as ternary when assigned.

Code after:
   *     tertiaryColor: Constants.HolographicStyle.Tertiary,
   *   },
   * })
   *   .then(console.log)
   *   .catch(console.error);
   */
  async create(options = {}) {
    let { permissions, icon } = options;
    const { name, hoist, position, mentionable, reason, unicodeEmoji } = options;
    if (permissions !== undefined) permissions = new PermissionsBitField(permissions);
    if (icon) {
      const guildEmojiURL = this.guild.emojis.resolve(icon)?.imageURL();
      icon = guildEmojiURL ? await resolveImage(guildEmojiURL) : await resolveImage(icon);
      if (typeof icon !== 'string') icon = undefined;
    }

    const colors = options.colors && {
      primary_color: resolveColor(options.colors.primaryColor),
      secondary_color: options.colors.secondaryColor && resolveColor(options.colors.secondaryColor),
      tertiary_color: options.colors.tertiaryColor && resolveColor(options.colors.tertiaryColor),
    };

    const data = await this.client.rest.post(Routes.guildRoles(this.guild.id), {
      body: {
        name,
        colors,
        hoist,
        permissions,
        mentionable,
        icon,
        unicode_emoji: unicodeEmoji,
      },
      reason,
    });
    const { role } = this.client.actions.GuildRoleCreate.handle({
      guild_id: this.guild.id,
      role: data,
    });
    if (position) return this.setPosition(role, position, { reason });
    return role;
  }

  /**
   * Options for editing a role
   *
   * @typedef {RoleData} RoleEditOptions
   * @property {string} [reason] The reason for editing this role
   */

  /**
   * Edits a role of the guild.