【发布时间】:2021-01-01 20:13:49
【问题描述】:
好的,我一直在研究一个使用 discord.js 创建频道覆盖的机器人。我对 discord.js 有点陌生,但我检查了文档,似乎更改覆盖时使用的正确方法是我在下面的代码中使用的,但我收到一条错误消息,我完全不知道我该如何解决它。
if (command == 'lockdown') {
if (commandArgs == '') {
let channel = msg.channel;
let roles = msg.guild.roles;
console.log(roles);
let testRole = 708384707015868486;
channel
.overwritePermissions(testRole, { SEND_MESSAGES: false }, 'closing up shop')
.then(console.log)
.catch(console.log);
}
}
这是该特定命令的代码,但我收到以下错误消息。
TypeError [INVALID_TYPE]: Supplied overwrites is not an Array or Collection of Permission Overwrites.
at TextChannel.overwritePermissions (/home/runner/Ecliptical-Productions-V3/node_modules/discord.js/src/structures/GuildChannel.js:208:9)
at Client.<anonymous> (/home/runner/Ecliptical-Productions-V3/index.js:25:17)
at Client.emit (events.js:315:20)
at Client.EventEmitter.emit (domain.js:483:12)
at MessageCreateAction.handle (/home/runner/Ecliptical-Productions-V3/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/runner/Ecliptical-Productions-V3/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/runner/Ecliptical-Productions-V3/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/runner/Ecliptical-Productions-V3/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/runner/Ecliptical-Productions-V3/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/runner/Ecliptical-Productions-V3/node_modules/ws/lib/event-target.js:125:16) {
[Symbol(code)]: 'INVALID_TYPE'
}
如何解决此错误?我在命令之后检查了通道覆盖并且没有进行更改,我一直在尝试修复这个问题但我找不到错误。
【问题讨论】:
标签: javascript node.js discord discord.js