Discord.js回复消息然后等待回复 [英] Discord.js reply to message then wait for reply

查看:156
本文介绍了Discord.js回复消息然后等待回复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,所以我希望我的机器人做的是等待来自用户的消息所以!spec当它获得该消息时我希望它以看到或改变?作出响应。然后等你回来看或改变,但我不能让它工作,文件不清楚,我不知道如何做到这一点。

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.

这必须能够在PM中工作,因为我不想用我打算做的事来发送不和谐。

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

我已经尝试过这个:

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.

推荐答案

与==比较并尝试。

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

这篇关于Discord.js回复消息然后等待回复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆