困惑于;清晰的;discord.js中的命令

困惑于;清晰的;discord.js中的命令,discord.js,Discord.js,我目前正试图为我的discord机器人发出一个“清除”命令,(!Clearnumber),但我显然做错了什么;我对编码相当陌生,我希望有人能看到我哪里出了问题 在main.js文件中,我有以下内容: } else if(command == 'clear'){ client.commands.get('clear').execute(message, agrs); } 在我的clear.js文件中,我的代码可能是完全错误的 module.exports= {

我目前正试图为我的discord机器人发出一个“清除”命令,(!Clearnumber),但我显然做错了什么;我对编码相当陌生,我希望有人能看到我哪里出了问题

在main.js文件中,我有以下内容:

    } else if(command == 'clear'){
        client.commands.get('clear').execute(message, agrs);
    }
在我的clear.js文件中,我的代码可能是完全错误的

module.exports= {
    name: 'clear',
    description: 'clears an amount of messages.',
    execute(message, args){
        const args = message.content.split(' ').slice(1);
    const amount = args.join(' ');
    if (!amount) return msg.reply('You haven\'t given an amount of messages which should be deleted!'); 
    
    if (isNaN(amount)) return msg.reply('The amount parameter isn`t a number!'); 
    
    if (amount > 100) return msg.reply('You can`t delete more than 100 messages at once!'); 
    
    if (amount < 1) return msg.reply('You have to delete at least 1 message!'); 
    
    await msg.channel.messages.fetch({ limit: amount }).then(messages => {
        msg.channel.bulkDelete(messages
    )});
    }
}
module.exports={
名称:“清除”,
描述:“清除一定数量的邮件。”,
执行(消息,参数){
const args=message.content.split(“”).slice(1);
const amount=args.join(“”);
如果(!amount)返回msg.reply('您没有给出应该删除的邮件数量!');
if(isNaN(amount))返回msg.reply('amount参数不是数字!');
if(amount>100)返回msg.reply('您不能一次删除超过100封邮件!');
if(amount<1)返回msg.reply('您必须删除至少1条消息!');
等待msg.channel.messages.fetch({limit:amount})。然后(messages=>{
msg.channel.bulkDelete(消息
)});
}
}

任何帮助都将不胜感激。再次感谢你

您应该改用此选项:

//删除`const args=message.content…`,args已通过命令处理程序定义
常量金额=args[0]
//代码。。。
const fetched=wait msg.channel.messages.fetch({
限额:金额,,
});
味精频道
.bulkDelete(已提取)
.catch((error)=>console.log(`由于${error}`,无法清除消息)

hm…我删除了'const args=message.content e.c.t',并将其替换为amount=args e.c.t。在最后一行,它在结尾的括号下加下划线,并说“unterminated template literal”有什么帮助吗?哦,我太笨了哈哈。用倒勾(`)关闭
console.log()
。我相应地编辑了我的答案。