await message discord.js
message.channel.awaitMessages(m => m.author.id == message.author.id,
{max: 1, time: 30000}).then(collected => {
// only accept messages by the user who sent the command
// accept only 1 message, and return the promise after 30000ms = 30s
// first (and, in this case, only) message of the collection
if (collected.first().content.toLowerCase() == 'yes') {
message.reply('Shutting down...');
client.destroy();
}
else
message.reply('Operation canceled.');
}).catch(() => {
message.reply('No answer after 30 seconds, operation canceled.');
});let filter = m => m.author.id === message.author.id
message.channel.send(`Are you sure to delete all data? \`YES\` / \`NO\``).then(() => {
message.channel.awaitMessages(filter, {
max: 1,
time: 30000,
errors: ['time']
})
.then(message => {
message = message.first()
if (message.content.toUpperCase() == 'YES' || message.content.toUpperCase() == 'Y') {
message.channel.send(`Deleted`)
} else if (message.content.toUpperCase() == 'NO' || message.content.toUpperCase() == 'N') {
message.channel.send(`Terminated`)
} else {
message.channel.send(`Terminated: Invalid Response`)
}
})
.catch(collected => {
message.channel.send('Timeout');
});
})
Also in JavaScript:
- Javascript compare two objects
- capacitor doc
- javascript checkbox value
- unable to save shipping information. please check input data. magento 2
- useeffect with cleanup
- converting bytes into kb js
- map over object javascript
- js detect right key click
- how to use for loops to work with array in javascript
- html video tag autoplay not working
- npm run test:coverage command in jest
- js get current time minutes
- timeline material ui react native
- auto generate component angular
- javascript rtsp player
- how to remove last element of array in javascript
- jquery change picture source
- element show using javascript
- javascript define a global variable
- moving letters animation javascript
- rounding to nearest hundredth js
- kendo datetime picket default timezone
- javascript style an element
- change span value javascript