Javascript 机器人是否可以为一条消息随机选择2种颜色?

Javascript 机器人是否可以为一条消息随机选择2种颜色?,javascript,node.js,discord.js,bots,Javascript,Node.js,Discord.js,Bots,我在嵌入中使用十进制颜色6275760,但我希望他也使用16777201,当他发送嵌入时,他发送的是这两种颜色中的一种 if (!args.length) return message.channel.send({ embed: { color: 6275760, description: `<:FubukiX:749212433951883264> | ${message.author}, You need to put a message.`,

我在嵌入中使用十进制颜色6275760,但我希望他也使用16777201,当他发送嵌入时,他发送的是这两种颜色中的一种

if (!args.length)
  return message.channel.send({
    embed: {
      color: 6275760,
      description: `<:FubukiX:749212433951883264> | ${message.author}, You need to put a message.`,
      footer: {
        text: `   | Exemple: !say hello`,
      },
    },
  });
if(!args.length)
返回message.channel.send({
嵌入:{
颜色:6275760,
描述:`${message.author},您需要放置一条消息。`,
页脚:{
文本:`|示例:!打招呼`,
},
},
});

您可以,只需添加此项即可

//要随机化的所有颜色的数组,可以随意添加。
常量colorArray=[167772016275760];
//在colorArray长度内随机化一个数字
const rand=Math.floor(Math.random()*colorArray.length);
//通过从colorArray中拾取随机颜色来定义颜色
const color=colorArray[rand];
如果(!参数长度)
返回message.channel.send({
嵌入:{
颜色:颜色,
描述:`${message.author},您需要放置一条消息。`,
页脚:{
文本:`|示例:!打招呼`,
},
},
}); // 将颜色定义为“color”,这是我们上面定义的随机颜色

您可以,只需添加此项即可

//要随机化的所有颜色的数组,可以随意添加。
常量colorArray=[167772016275760];
//在colorArray长度内随机化一个数字
const rand=Math.floor(Math.random()*colorArray.length);
//通过从colorArray中拾取随机颜色来定义颜色
const color=colorArray[rand];
如果(!参数长度)
返回message.channel.send({
嵌入:{
颜色:颜色,
描述:`${message.author},您需要放置一条消息。`,
页脚:{
文本:`|示例:!打招呼`,
},
},
}); // 将颜色定义为“color”,这是我们上面定义的随机颜色
color:Math.random()<0.5?6275760:16777201,
只是一个旁注,我强烈建议将这些数字用十六进制表示<代码>颜色:0x5fc2b0作为RGB值比十进制等效值更容易理解。
颜色:Math.random()<0.5?6275760:16777201,
只是一个旁注,我强烈建议将这些数字用十六进制表示<代码>颜色:0x5fc2b0作为RGB值比十进制等效值更容易理解。