你好,我正在尝试制作一个不和谐的机器人来解除某人的禁令,但这给了我这个错误:
Unhandled promise rejection: Error [BAN_RESOLVE_ID]: Couldn't resolve the user ID to unban.
at GuildMemberManager.unban (C:\Users\Jakub Sokol\Documents\Coding\Discord Bots\Smiley\node_modules\discord.js\src\managers\GuildMemberManager.js:210:36)
at Object.execute (C:\Users\Jakub Sokol\Documents\Coding\Discord Bots\Smiley\commands\unban.js:17:35)
at Client.<anonymous> (C:\Users\Jakub Sokol\Documents\Coding\Discord Bots\Smiley\index.js:70:11)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\Jakub Sokol\Documents\Coding\Discord Bots\Smiley\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Jakub Sokol\Documents\Coding\Discord Bots\Smiley\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\Jakub Sokol\Documents\Coding\Discord Bots\Smiley\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (C:\Users\Jakub Sokol\Documents\Coding\Discord Bots\Smiley\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\Users\Jakub Sokol\Documents\Coding\Discord Bots\Smiley\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (C:\Users\Jakub Sokol\Documents\Coding\Discord Bots\Smiley\node_modules\ws\lib\event-target.js:125:16) {
[Symbol(code)]: 'BAN_RESOLVE_ID'
}
这是我的代码:
const Discord = require('discord.js');
module.exports = {
name: 'unban',
description: "Ping!",
async execute(client, message, args) {
if(!message.member.hasPermission(['BAN_MEMBERS', 'ADMINISTRATOR'])) return message.channel.send("You don't have permission to use that command!");
if(!message.guild.me.hasPermission(['BAN_MEMBERS', 'ADMINISTRATOR'])) return message.channel.send("I don't have permissions to unban members!")
let bannedMember = parseInt(args[0]);
if(isNaN(bannedMember)) return message.channel.send("You need to give me a valid ID!");
let reason = args.slice(1).join(' ');
if(!reason) return reason = "No reason given.";
message.delete()
try {
message.guild.members.unban(bannedMember, reason);
message.channel.send(`Succesfully unbanned ${bannedMember}!`)
} catch(e) {
console.log(e.message);
}
}
}
这是我键入的内容:/unban 262258367903301632 test
我真的不知道它出了什么问题,也找不到任何答案:/
答案 0 :(得分:1)
该错误表明他找不到具有该标识的用户。创建一个辅助帐户,禁止该帐户并使用此命令。如果您要检查此用户是否被禁止,可以尝试使用
检查该用户是否在您的服务器上if (!message.guild.members.get(bannedMember)) return message.reply("This user is not banned!")
我不知道如何检查它是否真的被禁止,但这现在可以为您提供帮助
(我正在使用翻译器)