Answer the question
In order to leave comments, you need to log in
How to catch the user's next message?
I need to catch the user's next message, and take content from it.
For example:
message.reply('укажите число')
ephemeral: true
????
//ответ бот ожидает в течении 10 секунд, после чего
message.reply('Прошло 10 секунд, попробуйте еще')
ephemeral: true
bot.on('messageCreate', (message) => {
if(message.author.id !== "337262564289282051") {
return;
}
if(message.content == "222") {
bot.on('messageCreate', (message) => {
if(message.author.id !== "337262564289282051") {
return;
}
//if канал пользователь
console.log('123')
return;
})
setTimeout(() => {
console.log("321");
return;
}, 10000);
return;
};
})
Answer the question
In order to leave comments, you need to log in
if (message.content === ...) {
const collector = message.channel.createMessageCollector({
time: 10000
});
let userMessage = [];
collector.on('collect', m => {
if (m.author.id === message.author.id) {
userMessage.push(m.content);
collector.stop();
}
})
collector.on('end', collected => {
if (userMessage.length === 0) return message.reply(`Прошло 10 секунд, попробуйте ещё.`)
// userMessage[0] - контент первого сообщения, отправленного пользователем
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question