Javascript 试图为我的discord bot发出ban命令,但当我运行该命令时,总是会出错

Javascript 试图为我的discord bot发出ban命令,但当我运行该命令时,总是会出错,javascript,discord,discord.js,Javascript,Discord,Discord.js,这是我为ban命令编写的代码 Crashbot.on('message', message => { //looks for args if the user types a message with the defined prefix let args = message.content.substring(PREFIX.length).split(" "); //the switch equals true if the fi

这是我为ban命令编写的代码

Crashbot.on('message', message => {

    //looks for args if the user types a message with the defined prefix     
    let args = message.content.substring(PREFIX.length).split(" ");

    //the switch equals true if the first arg (word) after the defined prefix is "ban"
    switch (args[0]) {
        case 'ban':

        //checks if the message author has the needed permission to ban members
        if (message.member.hasPermission('BAN_MEMBERS')) {

            //checks if a user was mentioned to be banned and if not says that you need to specify someone to ban
            if (!args[1]) message.channel.send('You need to specify a person !');

            //makes a constant called user and sets it to the first person mentioned in the message
            const user = message.mentions.users.first();

            //checks if the constant "user" is a user mention
            if (user) {
                const member = message.guild.member(user);

                //checks if the mentioned user is a member of the guild (the discord server)
                if (member) {
                    
                    //checks if there was anything typed after the user mention (second arg) if not bans the mentioned user and responds with successfully banned "user" 
                    if (!args[2]) {
                        member.ban("Banned by Crashbot").then(() => {
                            message.reply(`Successfully banned ${user.tag}`);

                        }).catch(err => {
                            message.reply('I was unable to ban that member');
                            console.log(err);
                        });

                        //checks if there was anything typed after the user mention (second arg) and if there was ban the user and responds with successfully banned "user" for "reason specified in second arg"
                    } 
                    else if (args[2]) {
                        member.ban(`${args[2]}`).then(() => {
                            message.reply(`Successfully banned ${user.tag} for ${args[2]}`);

                        }).catch(err => {
                            message.reply('I was unable to ban that member');
                            console.log(err);
                        });
                    }
                }
            }
        }
        break;
    }
});
这就是我在控制台中不断遇到的错误

Response: Internal Server Error
    at RequestHandler.execute (C:\Users\Michael\desktop\crashbot\node_modules\discord.js\src\rest\RequestHandler.js:158:11)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  code: 500,
  method: 'put',
  path: '/guilds/555146022490341476/bans/615261605860737035'
}

bot没有崩溃,代码返回错误并继续按预期运行,但我不明白为什么我一直出现此错误

您能尝试放置完整选项吗?我不确定它是否有效,但让我们试试

// ban a guild member
guildMember.ban({ days: 7, reason: 'They deserved it' })
  .then(console.log)
  .catch(console.error);

这应该是一个评论,你必须有50的声誉,以评论,但这并不意味着你应该把它作为一个答案。这意味着你应该首先建立声誉。