javascript - 机器人是否可以为消息随机化 2 种颜色?
问题描述
我在我的嵌入中使用十进制颜色 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`,
},
},
});
解决方案
你可以,你需要做的就是添加这个。
// Array of all the colors you want to be randomized, add as much as you want.
const colorArray = [16777201, 6275760];
// Randomizing a number within the length of colorArray
const rand = Math.floor(Math.random() * colorArray.length);
// Defining the color by picking a random color from the colorArray
const color = colorArray[rand];
if (!args.length)
return message.channel.send({
embed: {
color: color,
description: `<:FubukiX:749212433951883264> | ${message.author}, You need to put a message.`,
footer: {
text: ` | Exemple: !say hello`,
},
},
}); // Define color as `color` which is the randomized color we defined above
推荐阅读
- php - 将相关的数据库表对象转换为嵌套数组 - PHP
- javascript - 在 Chamilo LMS 的移动设备上隐藏标题徽标
- css - 如何定位在特定 div 之后出现的特定按钮?
- php - PHP 如何准备好发送到脚本的文件主体
- reactjs - 为什么我的渲染方法被调用了两次
- kubernetes - Kubernetes 上的卡夫卡
- html - IE 中的滚动条正在工作,但在 chrome 中没有
- microsoft-teams - 向来宾用户提供有限团队访问权限的最佳方式是什么?
- django - RelatedObjectDoesNotExist at /post/new/ - 帖子没有作者
- swift - 如何阻止disclosureIndicator移动单元格背景图像