我得到的错误是 UnhandledPromiseRejectionWarning:DiscordAPIError:无效的表单主体 embed.fields [0] .inline:必须为true或false。 我试图使所有语句均正确,但这一直给我同样的错误,这是我的代码
const member = message.mentions.members.first() || message.member,
user = member.user;
const embed = new Discord.RichEmbed()
.setAuthor(message.author.username)
.setDescription("Users Info", true)
.setColor("#9B59B6", true )
.addField("Full Username:", `${message.author.username}${message.author.discriminator}`, true)
.addField("ID:", message.author.id, true)
.addField("Created at:", message.author.createdAt, true)
.addField("Status:", `${user.presence.status}`, true)
.addField("Game:", `${user.presence.game}`, true)
.addField("Roles", member.roles.map(r => `${r}`).join('|'), true)
.addField("Messages sent", userdata[message.author.username].messagesSent, "messages", true);
message.channel.send(embed);
这是我尝试运行的其他代码,它给了我同样的错误
const embed = new Discord.RichEmbed()
.setAuthor(message.author.username, true)
.setDescription("Messages sent", true)
.addField("Messages sent", userdata[message.author.username].messagesSent, "messages", true);
message.channel.send(embed);
相同的问题,我使陈述正确,并且不起作用
答案 0 :(得分:0)
问题出在您最后拨打的.addField
上。您传递4个参数,而方法仅接受3个参数(传递字符串时,第三个参数是Boolean
)。尝试将最后一个.addField
更改为此:
.addField("Messages sent", userdata[message.author.username].messagesSent + " messages", true);