我的discord.js帮助命令无法正常工作

时间:2018-11-09 22:06:20

标签: node.js discord discord.js

首先,我的帮助命令确实起作用了,但工作方式却不理想。

我的第一个问题是命令是在单独的消息中发送的,当您有很多命令时,这很烦人。

我的第二个问题是,当邮件以嵌入方式发送时,它显示如下:

  • 命令
  • 说明
  • 用法
  • 未定义

我尝试了多种方法来摆脱“未定义”。

我的代码:

let overlayTransitioningDelegate = OverlayTransitioningDelegate()

@IBAction func onOpenModalOverlay(_ sender: Any) {
    let overlayVC = OverlayViewController()
    overlayVC.transitioningDelegate  = self.overlayTransitioningDelegate
    overlayVC.modalPresentationStyle = .custom
    self.present(overlayVC, animated: true, completion: nil)
}

1 个答案:

答案 0 :(得分:0)

使用RichEmbed.addField()时,它至少需要两个参数:字段标题及其值。

.addField(`**${namelist}** \n${desclist} \n${usage}`) // this has only the title argument

尝试将三个“部分”放在三个不同的字段中。

.addField("Name:", namelist, true) // the 'true' means that they're inline fileds
.addField("Usage:", usage, true) // they will try to fit on the same line
.addField("Description:", desclist) // if there's no third argument, the default is 'false'

命令以不同的消息发送,因为您正在为每个命令运行整个代码,而不仅是为每个命令添加字段。如果您不想花时间在所有这些东西上,则可以使用discord.js-commando库:它是一个处理命令的框架,还处理错误,不完整的命令以及许多其他东西。如果您想检查一下,可以找到文档here

相关问题