[英]RangeError [BITFIELD_INVALID] when checking for permission overwrites (Discord.js v12)
[英]TypeError [INVALID_TYPE]: Supplied overwrites is not an Array or Collection of Permission Overwrites. 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 命令阻止每個人的消息,但是當我使用該命令時,機器人會發送嵌入消息:
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
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'],
},
]);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.