Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检查权限覆盖时出现RangeError[位字段_无效](Discord.js v12)_Javascript_Node.js_Discord.js - Fatal编程技术网

Javascript 检查权限覆盖时出现RangeError[位字段_无效](Discord.js v12)

Javascript 检查权限覆盖时出现RangeError[位字段_无效](Discord.js v12),javascript,node.js,discord.js,Javascript,Node.js,Discord.js,我试图创建一个锁定命令,用户可以在其中选择被覆盖的权限。但是,只有当第三和第四个if语句(检查现有权限覆盖)被删除时,这才有效,因为产生了以下错误:RangeError[BITFIELD\u INVALID]:无效的位域标志或数字。是否有解决方法 const channel = bot.channels.cache.get(args[0]); if(!channel) { return message.reply('Please provide a channel

我试图创建一个锁定命令,用户可以在其中选择被覆盖的权限。但是,只有当第三和第四个
if
语句(检查现有权限覆盖)被删除时,这才有效,因为产生了以下错误:
RangeError[BITFIELD\u INVALID]:无效的位域标志或数字。
是否有解决方法

const channel = bot.channels.cache.get(args[0]);

      if(!channel) {
        return message.reply('Please provide a channel id!');
      }

      if(!args[1]) {
        return message.reply('Please set the lock type!');
      }

      if (!channel.permissionsFor(message.guild.roles.everyone).has('VIEW_CHANNEL')) {
        const errorEmbed = new Discord.MessageEmbed()
          .setDescription(`❌ \`VIEW_CHANNEL\` for \`${channel.name}\` is already disabled.`)
          .setColor('RED');
        return message.channel.send(errorEmbed);
      }

      if (!channel.permissionsFor(message.guild.roles.everyone).has('READ_MESSAGES')) {
        const errorEmbed = new Discord.MessageEmbed()
          .setDescription(`❌ \`READ_MESSAGES\` for \`${channel.name}\` is already disabled.`)
          .setColor('RED');
        return message.channel.send(errorEmbed);
      }

      else if (args[1] === 'view' || args[1] === 'read') {
        channel.updateOverwrite(message.channel.guild.roles.everyone, { VIEW_CHANNEL: false }).then(() => {
          const msgEmbed = new Discord.MessageEmbed()
            .setDescription(`✅ The channel\`${message.channel.name}\` has been locked.`)
            .setColor('GREEN');
          message.channel.send(msgEmbed);
        }).catch((error) => {
          console.log(error);
          const errorEmbed = new Discord.MessageEmbed()
            .setDescription(`❌ Unable to lock \`${channel.name}\`.`)
            .setColor('RED');
          message.channel.send(errorEmbed);
        });
      }
      else if (args[1] === 'send') {
        channel.updateOverwrite(message.channel.guild.roles.everyone, { SEND_MESSAGES: false }).then(() => {
          const msgEmbed = new Discord.MessageEmbed()
            .setDescription(`✅ The channel\`${channel.name}\` has been locked.`)
            .setColor('GREEN');
          message.channel.send(msgEmbed);
        }).catch((error) => {
          console.log(error);
          const errorEmbed = new Discord.MessageEmbed()
            .setDescription(`❌ Unable to lock \`${channel.name}\`.`)
            .setColor('RED');
          message.channel.send(errorEmbed);
        });
      }

我想这是因为你在使用
READ_MESSAGES
而不是在任何地方都使用
VIEW_CHANNEL
(这是一样的,我认为
READ_MESSAGES
已经从Discord.jsv12中删除了)。

谢谢,是的,我实际上使用了
READ_MESSAGES
而不是
SEND_MESSAGES