Discord.js reply to message then wait for reply

2019-02-16 03:06发布

Right so what i want my bot to do is wait for a message from the user so "!spec" when it gets that message i want it to respond with "See or Change?" then wait for you to type back "see" or "change" but i cant get it to work, the docs arent clear to me and im not sure on how to do it.

this has to be able to work in PM as i dont want to spam the discord with what i plan to do.

i have already tried this:

if (command === 'spec'){
        message.author.send("See or Change?");
        const collector = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, { time: 10000 });
        console.log(collector)
        collector.on('collect', message => {
            if (message.content === "See") {
                message.channel.send("You Want To See Someones Spec OK!");
            } else if (message.content === "Change") {
                message.channel.send("You Want To Change Your Spec OK!");
            }
        })

i may be writing this wrong im not used to the library.

1条回答
beautiful°
2楼-- · 2019-02-16 03:28

Compare with == And Try.

if (command === 'spec'){
        message.author.send("See or Change?");
        const collector = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, { time: 10000 });
        console.log(collector)
        collector.on('collect', message => {
            if (message.content == "See") {
                message.channel.send("You Want To See Someones Spec OK!");
            } else if (message.content == "Change") {
                message.channel.send("You Want To Change Your Spec OK!");
            }
        })
查看更多
登录 后发表回答