Discord.js reply to message then wait for reply

风流意气都作罢 提交于 2019-12-03 22:16:16

问题


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:


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!");
            }
        })


来源:https://stackoverflow.com/questions/45856446/discord-js-reply-to-message-then-wait-for-reply

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!