TypeError [INVALID_TYPE]: Supplied overwrites is not an Array or Collection of Permission Overwrites. Discord v12(TypeError [INVALID_TYPE]:提供的覆盖不是权限覆盖的数组或集合.不和谐 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]:提供的覆盖不是权限覆盖的数组或集合.不和谐 v12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:TypeError [INVALID_TYPE]:提供的覆盖不是权限覆盖的数


基础教程推荐
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01