Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
How to set random colour in a discord.js embed

I have a discord bot and it works perfectly. My objective is that when I send the >help message, the bot chooses a random colour for the embed and sends it.

This is the configuration file for my bot called config.json

{
  "token": "Token Here",
  "prefix": ">",
  "genChannel": "channel id",
  "genCooldown": "1000",
  "color": {
      "green": "0x57F287",
      "yellow": "0xFEE75C",
      "red": "0xED4245",
      "default": "0x5865F2"
  },
  "command": {
      "notfound_message": true,
      "error_message": true
  }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In discord.js, you can pass a colour argument as a string. More on that in: discord.js docs on embed colour. To use a random colour, you may use the following:

{
//...
    "color": {
        "green": "0x57F287",
        "yellow": "0xFEE75C",
        "red": "0xED4245",
        "default": "0x5865F2",
        "random": "RANDOM"
    },
//...
}

You parse it into the embed just like any other embed colour hex or RGB array. It's a good idea to check out on the docs and guide.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!