我只想对具有ManageMes​​sages权限的角色执行nuke命令。我该怎么做?

时间:2020-10-18 03:04:26

标签: javascript visual-studio discord discord.js

Main.js nuke命令

if (command === 'nuke'){
        client.commands.get('nuke').execute(message, args);

命令文件夹中的nuke.js文件

module.exports = {
name: 'nuke',
description: "the bot will reply nuke gif!",
execute(message, args){
    
        if(message.member.roles.cache.has('755968860817195029'))
    {
    message.channel.bulkDelete("100").then(message.channel.send("NEWS HEADLINES:- **A BOMB JUST DROPPED HERE WHICH DELETED ALL THE MESSAGES (R.I.P.)**"));
    (message.channel.send("https://tenor.com/view/kozhi-nuclear-bomb-gif-18586883"));
} 

else { message.channel.send("It seems you dont have required permissions to do this commands!") } } }

1 个答案:

答案 0 :(得分:1)

您可以检查成员用户是否具有给定的权限,而不是检查角色。 Discord.js在成员对象Thi is an image of the directory上有一个实用程序。您可以使用它来检查成员是否具有“ MANAGE_MESSAGES”权限。