【问题标题】:TypeError: Cannot read property 'set' of undefined Command HandlerTypeError:无法读取未定义命令处理程序的属性“集”
【发布时间】:2021-02-16 17:19:13
【问题描述】:

当我尝试制作高级命令处理程序时出现此错误

这是我的脚本:

const Discord = require(`discord.js`);
const client = new Discord.Client();
const prefix = '!'
const fs = require(`fs`);
client.commands = new Discord.Collection();

const commandFile = fs.readdirSync('./scripts/').filter(file => file.endsWith('.js'));
for(const file of commandFile){
    const command = require(`./scripts/${file}`);

    client.command.set(command.name, command)
}

client.once('ready', ()=>{
    console.log('Succesfully Started Scriptz')
    client.user.setActivity("Scripts", {
        type: "WATCHING"
    })
})

client.login 的结尾部分我删除了,所以你无法访问我的机器人

【问题讨论】:

    标签: node.js typeerror


    【解决方案1】:

    我想你在命令末尾忘记了s

    应该改为client.commands.set

    【讨论】:

      猜你喜欢
      • 2020-09-07
      • 2021-12-15
      • 2019-10-31
      • 2019-04-07
      • 2018-03-07
      • 2021-11-15
      • 1970-01-01
      • 2022-11-26
      • 2017-11-02
      相关资源
      最近更新 更多