不和谐的清除命令角色权限不起作用

时间:2020-04-05 08:44:40

标签: discord discord.js

我尝试使用具有权限的命令(!clear)制作一个简单的discord机器人。我希望“管理员权限”角色是唯一允许执行!clear命令的角色。每当我尝试执行该命令时,它都会说message.guild.roles.find不是一个函数。我现在拥有的代码是:

switch(args[0]){
    case 'clear':
       if(message.guild.roles.find(role => role.name === 'Admin perms')) {

            if(!args[1]) {
               return channel.reply ('How many message do you want me to delete idot!')
            }
       message.channel.bulkDelete(args[1]);


2 个答案:

答案 0 :(得分:1)

        if(!message.member.roles.cache.find(r => r.name === "Admin perms")) return message.channel.send('You dont have permissions to do that idot!')

    if(!args[1]) return message.reply('How many message do you want me to delete idot!')
    message.channel.bulkDelete(args[1]);
    break;

答案 1 :(得分:0)

尝试这样做:

switch(args[0]) { case 'clear': if (message.member.roles.cache.find(role => role.name === 'Admin perms')) { if(!args[1]) { return channel.reply ('How many message do you want me to delete idot!') } else { message.channel.bulkDelete(args[1]); } } break;