为了账号安全,请及时绑定邮箱和手机立即绑定

迪克机器人。JS 无法读取未定义的属性“执行”

迪克机器人。JS 无法读取未定义的属性“执行”

慕森卡 2022-09-29 15:24:50
我无法让它工作。这是我的主文件:const fs = require('fs');  bot.commands = new Discord.Collection();  const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));  for(const file of commandFiles) {    const command = require(./commands/${file});    bot.commands.set(command.name, command);  } if (message.content == 'ping' || message.content == 'Ping') {   //message.channel.send('Pong');   bot.commands.get('ping').execute(message);和我的文件平.js:module.exports = {  name: 'test',  description: "Tester ting",  execute(message, args) {    message.channel.send("STOR TEST")  }}我收到此错误:UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'execute' of undefined我试图让我的机器人来拯救我:-)
查看完整描述

1 回答

?
慕丝7291255

TA贡献1859条经验 获得超6个赞

您的出口声明中似乎有点拼写错误。您忘记定义执行键。它应该看起来像这样:


module.exports = {

  name: 'test',

  description: "Tester ting",

  execute: function(message, args) {

    message.channel.send("STOR TEST")

  }

}


查看完整回答
反对 回复 2022-09-29
  • 1 回答
  • 0 关注
  • 100 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号