Javascript bot&x27;未定义用户的用户名

Javascript bot&x27;未定义用户的用户名,javascript,bots,discord.js,Javascript,Bots,Discord.js,我收到此错误未处理PromisejectionWarning:TypeError:无法读取未定义的的属性“username”,这是由嵌入中的客户端.user.username引起的 module.exports={ 名称:“建议”, 别名:['sug','suggestion'], 描述:'为机器人提供建议', 执行(消息、客户端、参数){ const Discord=require('Discord.js'); const filter=m=>m.author.id==message.auth

我收到此错误
未处理PromisejectionWarning:TypeError:无法读取未定义的
的属性“username”,这是由
嵌入
中的
客户端.user.username
引起的

module.exports={
名称:“建议”,
别名:['sug','suggestion'],
描述:'为机器人提供建议',
执行(消息、客户端、参数){
const Discord=require('Discord.js');
const filter=m=>m.author.id==message.author.id;
message.channel.send(`请为Bot提供建议,或使用“取消”!`取消此命令)
message.channel.awaitMessages(筛选器,{max:1,})
。然后(异步(收集)=>{
if(collected.first().content.toLowerCase()=“取消”){
回复(“您的建议已被取消”)
}
否则{
let embed=new Discord.MessageEmbed()
.setFooter(client.user.username、client.user.displayAvatarURL)
.setTimestamp()文件
.addField(`newsuggestionfrom:`,`**${message.author.tag}**`)
.addField(`New Suggestion:`,`${collected.first().content}`)
.setColor('0x0099ff');
client.channels.fetch(“7028254464248808519”).send(嵌入)
message.channel.send(`您的建议已提交给员工团队。谢谢!`)
}
})
},
捕捉(错误){
console.log(错误)
}
};

根据您的评论

尝试{command.execute(message,args);}catch(error){console.error(error);message.reply('尝试执行该命令时出错!');})

您没有将
client
传递到
execute()
,您需要这样做

您还需要在
channels.fetch()
上使用
wait
,因为它返回一个承诺,所以将
client.channels.fetch(“70282544248808519”).send(embed)
替换为:

const channel=wait client.channels.fetch(“70282544648808519”)
channel.send(嵌入)

try{command.execute(message,client,args);}catch(error){像这样对吗?但是现在错误是:unhandledPromisejectionWarning:TypeError:client.channels.fetch(…)。发送不是一个功能,所以它仍然与客户有关,不是吗?此外,在这里,如果他们帮助您,您接受答案很重要,我注意到您只会更新答案,因此如果任何答案解决了您的问题,请接受它们,让其他人知道什么是有效的。谢谢,好的,我会记住,现在一切都很好