消息收集器不工作 discord js v13

Message collector not working discord js v13

        let filter = m => m.author.id === message.author.id
    const collector = message.channel.createMessageCollector({filter, time: 15000, max: 1});

    //name
    let name = message.author.username
    gender()
    //gender

    function gender(){
    embed = embed
    .setTitle(`${message.author.username}'s About Me setup || Gender`)
    .setDescription('Whats your gender/pronounce?')
    .setColor("BLUE")
    message.reply({embeds: [embed]})


    collector.on('collect', m =>{
        let gender = m.content
        m.channel.send(`${gender}`)
        age()
        })
}

    //age
    function age(){
    embed = embed
    .setTitle(`${message.author.username}'s About Me setup || Age`)
    .setDescription('How old are you?')
    .setColor("BLUE")
    message.reply({embeds: [embed]})

    collector.on('collect', m =>{
        let age = m.content
        m.channel.send(`${age}`)
        nationality()
        })
    }
    //nationality
    function nationality() {
    embed = embed
    .setTitle(`${message.author.username}'s About Me setup || Nationality`)
    .setDescription('Where are you from?')
    .setColor("BLUE")
    message.reply({embeds: [embed]})

    collector.on('collect', m =>{
        let nationality = m.content
        m.channel.send(`${nationality}`)
        description()
        })
}
    //description
    function description(){
    embed = embed
    .setTitle(`${message.author.username}'s About Me setup || Age`)
    .setDescription('Describe yourself, tell others your favorite hobbies, favorite movies, ect. in less than 1500 characters')
    .setColor("BLUE")
    message.reply({embeds: [embed]})

    collector.on('collect', m =>{
        if(m.content.length > 1500){
            embed = embed
            .setTitle(':warning: Error! :warning:')
            .setDescription('Your description can only be less than 1500 characters')
            .setColor("BLUE")
            message.reply({embeds: [embed]})
            description()    
        }
        let description = m.content
        m.channel.send(`${description}`)
        })
    }

嘿,所以我正在尝试制作一个关于我的命令,当用户说“关于我的设置”时,它将 运行 通过设置并询问性别、年龄、描述等信息。 (message.channel.send 只是一个占位符,一旦我让它工作,我就把它放在一个实际的数据库中),但它似乎不像我预期的那样工作,这是我 [=11 时发生的事情=]

在线:

const collector = message.channel.createMessageCollector({filter, time: 15000, max: 1});

您的消息收集器仅收集 15 秒的消息,并且只会收集 1 条消息。

DiscordJS documentation 开始,createMessageCollector 接受以下参数:

  • time:收集器应该 运行 for
  • 的时间量(以毫秒为单位)
  • max: 成功通过过滤器的消息数
  • maxProcessed: 遇到的消息数(与过滤结果无关)

您可以通过在创建消息收集器时调整这些参数来满足您的需要来解决此问题,或者重新设计您的命令以接受性别、年龄和国籍的参数并使用这些参数构建最终的描述响应.

附带说明:您似乎正在使用 L! 前缀触发机器人命令。不再推荐这样做,因为 Discord 已经引入了 slash commands.

超过 75 个服务器中的机器人将无法读取消息内容(它正在成为 privileged). I'd recommend switching to slash commands so that you're using the latest way of providing interactions for your bot. There's a great tutorial showing how to create a bot from scratch using slash commands here