1 message.channel.awaitMessages(m => m.author.id == message.author.id,
2 {max: 1, time: 30000}).then(collected => {
3 // only accept messages by the user who sent the command
4 // accept only 1 message, and return the promise after 30000ms = 30s
5
6 // first (and, in this case, only) message of the collection
7 if (collected.first().content.toLowerCase() == 'yes') {
8 message.reply('Shutting down...');
9 client.destroy();
10 }
11
12 else
13 message.reply('Operation canceled.');
14 }).catch(() => {
15 message.reply('No answer after 30 seconds, operation canceled.');
16 });
1
2let filter = m => m.author.id === message.author.id
3 message.channel.send(`Are you sure to delete all data? \`YES\` / \`NO\``).then(() => {
4 message.channel.awaitMessages(filter, {
5 max: 1,
6 time: 30000,
7 errors: ['time']
8 })
9 .then(message => {
10 message = message.first()
11 if (message.content.toUpperCase() == 'YES' || message.content.toUpperCase() == 'Y') {
12 message.channel.send(`Deleted`)
13 } else if (message.content.toUpperCase() == 'NO' || message.content.toUpperCase() == 'N') {
14 message.channel.send(`Terminated`)
15 } else {
16 message.channel.send(`Terminated: Invalid Response`)
17 }
18 })
19 .catch(collected => {
20 message.channel.send('Timeout');
21 });
22 })
1message.channel.awaitMessages(m => m.author.id == message.author.id,
2 { max: 1, time: 30000 }).then(collected => {
3 if (collected.first().content.toLowerCase() == 'yes') {
4 message.reply('Shutting down...');
5 client.destroy();
6 }
7 else
8 message.reply('Operation canceled.');
9 }).catch(() => {
10 message.reply('No answer after 30 seconds, operation canceled.');
11 });