【发布时间】:2021-01-16 02:48:44
【问题描述】:
我的帮助命令返回有关命令的信息,当命令没有别名或使用属性时返回undefined。
我的帮助命令代码:
const helpcommand = new Discord.MessageEmbed()
.addField("Command name",
`${command.name}`)
.addField("Description",
`${command.description}`)
.addField("Aliases",
`${command.aliases}`)
.addField("Usage",
`${command.usage}`)
.setTimestamp()
.setFooter(message.member.user.tag, message.author.avatarURL());
message.channel.send(helpcommand)
我尝试添加 || 以使其在没有别名或用法时返回 none 但它不起作用:
const helpcommand = new Discord.MessageEmbed()
.addField("Command name",
`${command.name}`)
.addField("Description",
`${command.description}`)
.addField("Aliases",
`${command.aliases}` || "none")
.addField("Usage",
`${command.usage}` || "none")
.setTimestamp()
.setFooter(message.member.user.tag, message.author.avatarURL());
message.channel.send(helpcommand)
谁能告诉我在没有可用属性时如何显示none?
【问题讨论】:
标签: javascript node.js discord.js