亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

迪克機器人。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 關注
  • 96 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號