【问题标题】:TypeError: Cannot read property 'execute' of undefined [Discord Bot]TypeError:无法读取未定义 [Discord Bot] 的属性“执行”
【发布时间】:2021-03-31 19:10:11
【问题描述】:

我在这个特定的代码块中遇到了错误

    if(!message.content.startsWith(prefix) || message.author.bot) return;

    const args = message.content.slice(prefix.length).split(/ +/);
    const command = args.shift().toLowerCase();

    if(command === 'ping'){
        client.commands.get('ping').execute(message, args);
    } else if (command == 'reactionroles'){
        client.commands.get('reactionroles').execute(message, args, Discord, client);
    }
    });

我不得不将reactionroles.js 的代码放入一个pastebin。 https://pastebin.com/tYebDG4Y

【问题讨论】:

    标签: node.js discord discord.js


    【解决方案1】:

    reactionroles 块更改为:

     else if (command == 'reactionroles')
        client.commands.get('reactionrole').execute(message, args, Discord, client);
    

    注意文件名为reactionroles.js,但其内部方法名为reactionrole。所以它找不到任何名称为 reactionroles 的方法。正如您在 reactionroles.js 文件中指定的那样,该方法不包含尾随 s

    module.exports = {
        name: 'reactionrole',
        description: "Set up a reaction role message",
    

    【讨论】:

      猜你喜欢
      • 2020-10-15
      • 2021-08-29
      • 1970-01-01
      • 2021-01-19
      • 2021-09-14
      • 2021-02-01
      • 2020-06-20
      • 2021-06-06
      • 2021-10-02
      相关资源
      最近更新 更多