discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.33k stars 3.97k forks source link

Embed Color is not accepting #HEX #8304

Closed rodycouto closed 2 years ago

rodycouto commented 2 years ago

Which package is this bug report for?

builders

Issue description

Screenshot_1

Code sample

return await interaction.reply({
    embeds: [
        {
            color: '#FF0000',
            title: 'Some title'
        }
    ]
})

Package version

14.0.1

Node.js version

v16.15.0

Operating system

Linux

Priority this issue should have

High (immediate attention needed)

Which partials do you have configured?

User, Channel, GuildMember, Message, Reaction, GuildScheduledEvent, ThreadMember

Which gateway intents are you subscribing to?

Guilds, GuildMembers, GuildBans, GuildEmojisAndStickers, GuildIntegrations, GuildWebhooks, GuildInvites, GuildVoiceStates, GuildPresences, GuildMessages, GuildMessageReactions, MessageContent, GuildScheduledEvents

I have tested this issue on a development release

No response

suneettipirneni commented 2 years ago

Hi, this is intended behavior in v14. Colors within json objects are not resolved by default. If you'd like to use hex colors you have three options:

  1. Use a hex number literal Instead of using the color: '#FF0000' you can use a hex literal color: 0xFF0000

  2. Use EmbedBuilder either via the constructor or the setters.

  3. Use the resolveColor(color)utility function to resolve the hex color in the json.