'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
  }
}


Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 panzer-chan