Javascript Discord.js 回复消息然后等待回复
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45856446/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Discord.js reply to message then wait for reply
提问by andy wilson
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.
这必须能够在 PM 中工作,因为我不想用我计划做的事情向不和谐发送垃圾邮件。
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.
我可能写错了我不习惯图书馆。
采纳答案by Sindhoor
Compare with == And Try.
与 == 和 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!");
}
})

