我有问题,我的代码正在显示
类型错误:无法读取暂停命令未定义的属性“执行”。所有其他命令都工作正常。
读取文件。
client.commands = new Discord.Collection();
const commandFIles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFIles){
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.on('message', msg => {
if (!msg.content.startsWith(prefix) || msg.author.bot) {
return;
}
const args = msg.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'ping') {
client.commands.get('ping').execute(msg, args);
} else if (command === 'userinfo') {
client.commands.get('userinfo').execute(msg, args);
} else if (command === 'delete') {
const amount = parseInt(args[0]) + 1;
if (isNaN(amount)) {
return msg.reply('Enter a valid number.');
} else if (amount <= 1 || amount > 100) {
return msg.reply('Enter a number between 1 and 99.');
} else {
msg.channel.bulkDelete(amount, true).catch(err => {
console.error(err);
msg.channel.send('There was an error trying to delete messages');
});
msg.channel.send(`Deleted ${args} messages.`);
}
} else if (command === 'p' || command === 'play') {
client.commands.get('play').execute(msg, args);
} else if (command === 'pause') {
client.commands.get('pause').execute(msg);
}
});
如果我复制代码并粘贴相同的代码,Client.on它可以正常工作,但在使用 with 时显示错误module.exports。有什么办法可以解决这个问题吗?
吃鸡游戏
料青山看我应如是
繁星coding
相关分类