TypeError [INVALID_TYPE]:提供的覆盖不是权限覆盖的数组或集合.不和谐 v12
- 作者: 丐帮没帮主
- 来源: 51数据库
- 2022-10-21
问题描述
module.exports = {
config: {
name: 'lock',
aliases: ['lk'],
description: "",
category: "*****"
},
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'],
},
]);
推荐阅读
热点文章
检查拆分键盘
0
带有“上一个"的工具栏和“下一个"用于键盘输入AccessoryView
0
Activity 启动时显示软键盘
0
UIWebView 键盘 - 摆脱“上一个/下一个/完成"酒吧
0
在 iOS7 中边缘滑动时,使键盘与 UIView 同步动画
0
我的 iOS 应用程序中的键盘在 iPhone 6 上太高了.如何在 XCode 中调整键盘的分辨率?
0
android:inputType="textEmailAddress";- '@' 键和 '.com' 键?
0
禁用 iPhone 中键盘的方向
0
Android 2.3 模拟器上的印地语键盘问题
0
keyDown 没有被调用
0
