类型错误:无法读取未定义 [Discord Bot] 的属性“执行”

时间:2020-12-22 02:44:44

标签: node.js discord discord.js

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

    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

1 个答案:

答案 0 :(得分: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",