【发布时间】:2019-05-11 07:25:10
【问题描述】:
我正在寻求您的帮助。 我正在尝试发送一条等待回复的消息,然后当用户在时限内回答时,它会发送另一条类似这样的消息。 我不知道你是否理解我。 如果您需要更多信息,请不要回答。
真诚的。
我当前的代码:
const filter = m => m.author.id === message.author.id && m.author.id !== bot.user.id
// CHOISIR LE NOM
message.reply("S'il vous plaît choisissez un nom pour le tournoi.").then(r => r.delete(10000));
message.channel.awaitMessages(filter, {
max: 1,
time: 10000
}).then(collected => {
if(collected.first().content === "stop" || collected.first().content === "cancel"){
return message.reply("Création du tournoi annulé.")
}
let tournamentname = collected.first().content;
db.collection("tournois").findOneAndUpdate({"tournamentInformations.status": "active"}, {
$set: {
"tournamentInformations.tournamentName": tournamentname
}}, {upsert: true}, function(err,doc) { if (err) { throw err; } });
message.channel.send(":white_check_mark: | Vous avez défini le nom du tournoi à "+tournamentname);
}).catch(err => {
console.log(err)
})
// CHOISIR L'ORGANISATEUR
message.reply("S'il vous plaît choisissez le nom de l'organisateur.").then(r => r.delete(10000));
message.channel.awaitMessages(filter, {
max: 1,
time: 10000
}).then(collected => {
if(collected.first().content === "stop" || collected.first().content === "cancel"){
return message.reply("Création du tournoi annulé.")
}
let organisateur = collected.first().content;
db.collection("tournois").findOneAndUpdate({"tournamentInformations.status": "active"}, {
$set: {
"tournamentInformations.organizedBy": organisateur
}}, {upsert: true}, function(err,doc) { if (err) { throw err; } });
message.channel.send(":white_check_mark: | Vous avez défini l'organisateur à "+organisateur);
}).catch(err => {
console.log(err)
})
【问题讨论】:
-
请在问题本身中包含minimal reproducible example,而不是作为指向其他网站的链接。
标签: javascript node.js discord.js