“Discord.js attend le message” Réponses codées

Discord Bot attendez la réponse


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');
        });
    })
TheFastestBugSnailer

Discord.js attend le message

message.channel.awaitMessages(m => m.author.id == message.author.id,
    { max: 1, time: 30000 }).then(collected => {
        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.');
    });
Undefined

Réponses similaires à “Discord.js attend le message”

Questions similaires à “Discord.js attend le message”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code