Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 是否可以在discord.js中为某些用户提供自定义嵌入颜色?_Javascript_Node.js_Discord_Discord.js - Fatal编程技术网

Javascript 是否可以在discord.js中为某些用户提供自定义嵌入颜色?

Javascript 是否可以在discord.js中为某些用户提供自定义嵌入颜色?,javascript,node.js,discord,discord.js,Javascript,Node.js,Discord,Discord.js,我想给自己一个自定义嵌入颜色,但这是可能的吗?我现在有这个代码: let color=message.member.displayHexColor; if(color=='#00000')color=message.member.winghrole.hexColor; 让set=db.fetch(`g_${message.guild.id}`); 如果(message.channel.id===设置){ var serverIcon=message.guild.iconURL(); const

我想给自己一个自定义嵌入颜色,但这是可能的吗?我现在有这个代码:

let color=message.member.displayHexColor;
if(color=='#00000')color=message.member.winghrole.hexColor;
让set=db.fetch(`g_${message.guild.id}`);
如果(message.channel.id===设置){
var serverIcon=message.guild.iconURL();
const embed=new Discord.MessageEmbed()
.setTitle(message.author.tag)
.addField('Message:',Message.content)
.setColor(message.member.displayHexColor)
.set缩略图(message.author.avatarURL())
.setFooter(
`服务器:${message.guild.name}| |用户id:${message.author.id}| |成员:${message.guild.memberCount}`
);
client.guilds.cache.forEach((g)=>{
试一试{
client.channels.cache.get(db.fetch(`g_${g.id}`)).send(嵌入);
}捕获(e){
返回;
}
});
}

您可以使用三元运算符检查成员是否为您

//对于一个人
.setColor(message.author.id==“您的id”?“特殊十六进制颜色(或rgb值)”:颜色)
//多次
.setColor(['Your ID'、'Second ID'、'etc...].includes(message.author.ID)?'special hex color':颜色)

是否也可以添加第二个ID?将
message.author.ID===“您的ID”
切换到
[“您的ID”,“第二个ID]”。包括(message.author.ID)
。您可以向数组中添加任意数量的ID。