【问题标题】:Error while trying to make an application command discord.js尝试创建应用程序命令 discord.js 时出错
【发布时间】:2021-06-01 12:04:15
【问题描述】:
module.exports = {
    prefix: "!apply",
    fn: (msg) => {
        let application = {}
        let filter = (msg) => !msg.author.bot
        let options = {
            max: 1,
            time: 1500
        }
        msg.member.send("Which item do you want to sell")
        .then(dm => {
            return dm.channel.awaitMessages(filter,options)
        })
        .then(collected => {
            application.name = collected.array()[0].content;
            return msg.member.send("Got it, now whats your Discord [ex: Vouchy#0001]")
        })
        .then(dm => {
            return dm.channel.awaitMessages(filter,options)
        })
        .then(collected => {
            application.tag = collected.array()[0].content;
            return msg.member.send('Excellent, Finally, tell us how much you\'re willing to sell it for')
        })
        .then(dm => {
            return dm.channel.awaitMessages(filter,options)
        })
        .then(collected => {
            application.pitch = collect.array()[0].content;
            console.log(application)
        })
    }
}

我试图创建一个不和谐的应用程序,当用户执行 !apply 时,它会向他们发送一条消息并要求他们回答这些问题。

但每次都会出错 This is an image of the error i get

【问题讨论】:

  • 我在Collection#array 上找不到任何文档,您的意思是不是Collection#toArray? (.toArray())

标签: javascript arrays discord.js


【解决方案1】:

错误表示collected.array()[0] 未定义或无效。您应该在从中提取 content 之前添加 console.log(collected)console.log(collected.array(),以验证实际定义了collected/collected.array()

【讨论】:

  • 你能用我的代码做一个例子吗?我对 js 很陌生,所以我不知道把它放在哪里
  • 你有这行:application.name = collected.array()[0].content。在它之前添加一个console.log(collected)。此外,正如@Elitezen 提到的,collected.array() 可能是无效的。尝试将其替换为collected.toArray()
猜你喜欢
  • 2020-09-13
  • 2021-08-30
  • 1970-01-01
  • 1970-01-01
  • 2022-01-18
  • 2020-09-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多