简体   繁体   English

如何检查发件人是否具有 discord.js 中的 MANAGE_ROLES 权限

[英]How would I check if a sender has the MANAGE_ROLES permission in discord.js

I'm currently working on a bot for discord and I have run into a problem that no matter what I have tried to check if the sender of a command has a certain permission before running.我目前正在为 discord 开发一个机器人,我遇到了一个问题,无论我尝试检查命令的发送者在运行之前是否具有一定的权限。 But everything I have tried just let's anyone or no one.但我所尝试的一切都只是让任何人或没有人。 I've searched so much around the internet and I don't know how to do it.我在互联网上搜索了很多,我不知道该怎么做。

Here is my code: https://replit.com/@AwesomeKalin55/KawahivaBot#commands/admin/verify.js这是我的代码: https://replit.com/@AwesomeKalin55/KawahivaBot#commands/admin/verify.js

Please note that the checking code is removed.请注意,检查代码已被删除。 Thanks in advance.提前致谢。

PS the command I want to check is k!verify PS我要检查的命令是k!verify

You can check if message.member.hasPermission('MANAGE_ROLES') is true.您可以检查message.member.hasPermission('MANAGE_ROLES')是否为真。

message.member returns the author of the message as a guild member. message.member作为公会成员返回消息的作者。 GuildMember s have a hasPermission method. GuildMember有一个hasPermission方法。 With this, you can check if any of this member's roles have a certain permission.有了这个,您可以检查该成员的任何角色是否具有一定的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM