[英]How to check if 2 statements are true
I'm trying to make my discord bot send a message that the server admin wants but i dont know how to check if the user using the command is an admin and has mentioned a channel, im trying to use if (message.member.hasPermission('ADMINISTRATOR'))
in this code我正在尝试让我的不和谐机器人发送服务器管理员想要的消息,但我不知道如何检查使用该命令的用户是否是管理员并提到了一个频道,我正在尝试使用
if (message.member.hasPermission('ADMINISTRATOR'))
在此代码中
message.channel.send(developerEmbed);
}
else {
let targetChannel = message.mentions.channels.first();
const args = message.content.split(" ").slice(2);
let userMessage = args.join(" ");
targetChannel.send(userMessage);
message.delete();
}
the only problem is that i don't know how to implement both of the statements at the same time唯一的问题是我不知道如何同时实现这两个语句
You can use:您可以使用:
if(message.member.hasPermission('ADMINISTRATOR') && message.mentions.channels.first())
See && operator: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND参见 && 运算符: https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.