尝试创建应用程序命令 discord.js 时出错

时间:2021-03-02 22:19:20

标签: javascript arrays discord.js

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

1 个答案:

答案 0 :(得分:0)

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