[英]How to get role permissions ? Discord.js
I'm trying to make a bot that analyzes the server to find a flaw but I can't find how to know a precise authorization for a role?我正在尝试制作一个机器人来分析服务器以查找缺陷,但我找不到如何知道角色的精确授权? I have already tested this:
我已经对此进行了测试:
var role = message.mentions.roles.first()
if(role.permissions.has(Discord.Permissions.FLAGS.KICK_MEMBERS)){
message.reply("YES")
}
else message.reply("NO")
I always receive Yes as a message我总是收到 Yes 作为消息
You are doing the if/else wrong, instead do it like this:您做错了 if/else,而是这样做:
var role = message.mentions.roles.first()
if (role.permissions.has(Permissions.FLAGS.KICK_MEMBERS)) {
message.reply({ content: "YES" })
} else {
message.reply({ content: "NO" })
}
You don't need to put Discord infront of Permissions, and message.reply('')
is deprecated, instead use message.reply({ content: '' })
您不需要将 Discord 放在 Permissions 前面,并且不推荐使用 message.reply
message.reply('')
,而是使用message.reply({ content: '' })
Old: channel.send(embed);
New: channel.send({ embeds: [embed, embed2] });
Old: channel.send('Hello!', { embed });
New: channel.send({ content: 'Hello!', embeds: [embed, embed2] });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.