UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'username' of undefined
所以我修复了一些其他错误,现在我在这里,但idk该怎么办。可能与用户的严格性有关?还是客户?请帮助我。
module.exports = {
name: 'suggest',
aliases: ['sug', 'suggestion'],
description: 'Suggest something for the Bot',
execute(message, client, args) {
const Discord = require('discord.js');
const filter = m => m.author.id === message.author.id;
message.channel.send(`Please provide a suggestion for the Bot or cancel this command with "cancel"!`)
message.channel.awaitMessages(filter, {max: 1,})
.then(async(collected) => {
if (collected.first().content.toLowerCase() === 'cancel') {
message.reply("Your suggestion has been cancelled.")
}
else { let embed = new Discord.MessageEmbed()
.setFooter(client.user.username, client.user.displayAvatarURL)
.setTimestamp()
.addField(`New Suggestion from:`, `**${message.author.tag}**`)
.addField(`New Suggestion:`, `${collected.first().content}`)
.setColor('0x0099ff');
client.channels.fetch("702825446248808519").send(embed)
message.channel.send(`Your suggestion has been filled to the staff team. Thank you!`)
}
})
},
catch (err) {
console.log(err)
}
};
根据您的评论here
尝试{command.execute(message,args); } catch(错误){console.error(错误); message.reply('尝试执行该命令时出错!'); }});
您没有将client
传递到execute()
,需要这样做