TypeError [INVALID_TYPE]:提供的覆盖不是权限覆盖的数组或集合。 Discord v12 [英] TypeError [INVALID_TYPE]: Supplied overwrites is not an Array or Collection of Permission Overwrites. Discord v12

查看:89
本文介绍了TypeError [INVALID_TYPE]:提供的覆盖不是权限覆盖的数组或集合。 Discord v12的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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)
    }
    }
}

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

I'm trying to make the !lock command block everyone's messages, but when I use the command, the bot sends the embed message:

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

但是它不会阻止消息,并且会在终端:

But it does not block messages, and sends this error in the terminal:

TypeError [INVALID_TYPE]: Supplied overwrites is not an Array or Collection of Permission Overwrites


推荐答案

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

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

Is actually the format for Channel.updateOverwrite(). For Channel.overwritePermissions(), use this instead:

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

这篇关于TypeError [INVALID_TYPE]:提供的覆盖不是权限覆盖的数组或集合。 Discord v12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆