用户回复问题后,如何使我的机器人发送消息
我正在尝试制作一个系统,该系统由机器人提出问题,然后用户回复它清除了这2条消息,并提出了另一个问题并重复,直到所有问题完成为止。
我无法等待用户在提出另一个问题之前输入答案,任何帮助吗?
const { MessageEmbed } = require("discord.js");
const clearMessages = require("./clearMessages");
const askEventQuestions = async (client, channelId) => {
const edonoChannel = client.channels.cache.get(channelId);
let q1Answer = ""
//event questions embeds
const q1 = new MessageEmbed()
.setColor("AQUA")
.setDescription("What Type of Event would you like to donate for?");
const q2 = new MessageEmbed()
.setColor("AQUA")
.setDescription("What are the amounts of DMC/Items that you are donating?");
//send and set answer for questions
await edonoChannel.send({ embeds: [q1] });
client.on("messageCreate", async (message) => {
q1Answer = message.content;
if (q1Answer !== "") {
await clearMessages(2, message);
console.log(q1Answer);
}
});
await edonoChannel.send({ embeds: [q2] });
I'm trying to make a system where a user is given a question by the bot and after the user replies it clears these 2 messages and asks another question and repeats until all the questions are complete.
I can't make it to wait for the user to input their answer before asking another question, any help?
const { MessageEmbed } = require("discord.js");
const clearMessages = require("./clearMessages");
const askEventQuestions = async (client, channelId) => {
const edonoChannel = client.channels.cache.get(channelId);
let q1Answer = ""
//event questions embeds
const q1 = new MessageEmbed()
.setColor("AQUA")
.setDescription("What Type of Event would you like to donate for?");
const q2 = new MessageEmbed()
.setColor("AQUA")
.setDescription("What are the amounts of DMC/Items that you are donating?");
//send and set answer for questions
await edonoChannel.send({ embeds: [q1] });
client.on("messageCreate", async (message) => {
q1Answer = message.content;
if (q1Answer !== "") {
await clearMessages(2, message);
console.log(q1Answer);
}
});
await edonoChannel.send({ embeds: [q2] });
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用收集器,我认为等待: https://discordjs.guide/popular-topics/collectors.html#await-messages
是完全不同的方法,但是更简单的
事情,但更简单:
这 消息)包含(s)您问题的有效答案。之后,您可以进行治疗!
You should use Collectors and I think awaitMessages : https://discordjs.guide/popular-topics/collectors.html#await-messages
Its a totally different way to do it but simpler
Something like that :
That is returning the first message (or messages) that contain(s) the valid answer to your question. After that you can run your treatement!