【问题标题】:TypeError [INVALID_TYPE]: Supplied overwrites is not an Array or Collection of Permission Overwrites. Discord v12TypeError [INVALID_TYPE]:提供的覆盖不是权限覆盖的数组或集合。不和谐 v12
【发布时间】:2020-12-25 22:59:00
【问题描述】:
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 命令阻止每个人的消息,但是当我使用该命令时,机器人会发送嵌入消息:

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

但它不会阻塞消息,并在终端发送此错误:

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

【问题讨论】:

    标签: javascript node.js discord.js bots


    【解决方案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'],
      },
    ]);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-07
      • 1970-01-01
      • 1970-01-01
      • 2021-08-13
      • 1970-01-01
      • 2021-01-14
      • 1970-01-01
      • 2020-10-23
      相关资源
      最近更新 更多