【发布时间】:2018-09-12 03:42:31
【问题描述】:
您好,我正在使用 discord.js 和 discord.js-commando 创建一个不和谐机器人,而我遇到的问题基本上是试图让我的 discord.js 机器人发布一个带有以下属性的嵌入。
运行机器人客户端并输入命令后,我的控制台中出现错误提示
(node:6120) UnhandledPromiseRejectionWarning: UnhandledPromiseRejection (rejection id: 3): TypeError: Cannot read property 'username' of undefined
以前,在我尝试将动态返回输出(来自answer())放入嵌入之前,该命令运行良好。该函数调用的return 值是一个基于lootedItem 的字符串。
lootedItem 是从父数组的加权随机选择中选择的对象。
const embed = new Discord.RichEmbed({
"title": "Game Results",
"color": 3662439,
"description": answer(),
"thumbnail": {
"url": lootedItem.image
},
})
message.channel.send('Placing...', {
embed: embed.setTimestamp()
});
【问题讨论】:
-
你在某些时候试图获取
Cannot read property 'username' of undefined的用户名。
标签: javascript discord discord.js