TypeError [INVALID_TYPE]:提供的覆盖不是权限覆盖的数组或集合。 Discord v12

时间:2020-09-07 13:54:06

标签: javascript node.js discord.js bots

group by

我试图使!lock命令阻止所有人的消息,但是当我使用该命令时,机器人会发送嵌入消息:

module.exports = {
    config: {
        name: 'lock',
        aliases: ['lk'], 
        description: "",
        category: "Admin"
    },
    run: async (client, message, args) => {
    const Discord = require('discord.js')

    if(!message.member.hasPermission("MANAGE_MESSAGES", "MANAGE_CHANNELS")) {
    return message.reply(`<@${message.author.id}>, You do not have the permissions`);
    } else if(!message.guild.me.permissions.has("MANAGE_MESSAGES", "MANAGE_CHANNELS")) {
      return message.reply("I don't have Permissions")
    } else {
    
    message.channel.overwritePermissions(message.guild.everyone, {
    SEND_MESSAGES: false,
    ADD_REACTIONS: false
    });

     const embedLock = new Discord.MessageEmbed()
     .setTitle(`Channel successfully blocked! Use !ynlock to Unlock the channel`)
     .setColor("RED")
     const msg = await message.channel.send(embedLock)
    }
    }
}

但是它不会阻止消息,并且会在终端中发送此错误:

     const embedLock = new Discord.MessageEmbed()
     .setTitle(`Channel successfully blocked! Use !ynlock to Unlock the channel`)
     .setColor("RED")
     const msg = await message.channel.send(embedLock)

1 个答案:

答案 0 :(得分:1)

message.channel.overwritePermissions(message.guild.everyone, 
  {
    SEND_MESSAGES: false,
    ADD_REACTIONS: false
   });

实际上是Channel.updateOverwrite()的格式。对于Channel.overwritePermissions(),请改用它:

message.channel.overwritePermissions([
  {
     id: message.author.id,
     deny: ['SEND_MESSAGES', 'ADD_REACTIONS'],
  },
]);