Javascript 如何解决这个问题;执行;discord.js上的错误
我得到的错误是: TypeError:无法读取未定义的属性“execute” 我使用的代码是:Javascript 如何解决这个问题;执行;discord.js上的错误,javascript,discord,discord.js,Javascript,Discord,Discord.js,我得到的错误是: TypeError:无法读取未定义的属性“execute” 我使用的代码是: if(!message.content.startsWith(prefix) || message.author.bot) return; const args = message.content.slice(prefix.length).split(/ +/); const command = args.shift().toLowerCase(); if(command
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 == 'rules'){
client.commands.get('rules').execute(message, args);
}
if(command === 'hello'){
client.commands.get('hello').execute(message, args);
} else if (command == 'bye'){
client.commands.get('bye').execute(message, args);
}
if(command === 'command'){
client.commands.get('command').execute(message, args, Discord);
}
});
执行命令“-commands”时出现错误,命令文件的代码为:
name: 'commands',
description: "Embed!",
execute(message, args, Discord) {
const newEmbed = new Discord.MessageEmbed()
.setColor('#304281')
.setTitle('Rules')
.setDescription('This is a Embed rules for the server')
.addFields(
{name: 'Rule 1', value: 'Be nice'},
{name: 'Rule 2', value: 'No NSFW'},
{name: 'Rule 3', value: 'No spam'},
)
.setFooter('Make sure to check out the rules channel');
message.channel.send(newEmbed);
}
}
非常感谢您的回复!感谢您查看:)该命令名为
commands
,但您尝试使用名称command
获取它。这只是一个打字错误。