Advertisement
Guest User

Await Messages

a guest
Mar 6th, 2018
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async run(msg) {
  2.     const messages = [];
  3.     var username = null;
  4.     var email = null;
  5.     var password = null;
  6.     var blockProcess = 0;
  7.     try {
  8.       if (blockProcess === 0) {
  9.         await msg.direct('You are about to register. You will have 10 seconds to enter each process. You will need to have your username, email, and password ready! Type ok to continue.');
  10.         await msg.author.dmChannel.awaitMessages(res  => {
  11.           if (res.content === 'ok') {
  12.             blockProcess = 1;
  13.           } else {
  14.             console.log(res.content);
  15.             console.log(blockProcess);
  16.             return msg.direct('You did not produce the correct answer.');
  17.           }
  18.         }, { max: 1, time: 10000, errors: ['time'] });
  19.       }
  20.  
  21.       if (blockProcess === 1) {
  22.         await msg.direct('What do you wish your username to be?');
  23.         await msg.author.dmChannel.awaitMessages(res => {
  24.           username = res.content;
  25.           blockProcess = 2;
  26.           return msg.direct('Your username: ' + username);
  27.         }, { max: 1, time: 30000, errors: ['time'] });
  28.       }
  29.  
  30.       if (blockProcess === 2) {
  31.         await msg.direct('What is you email address?');
  32.         await msg.author.dmChannel.awaitMessages(res => {
  33.           email = res.content;
  34.           blockProcess = 3;
  35.           return msg.direct('Your email: ' + email);;
  36.         }, { max: 1, time: 30000, errors: ['time'] });
  37.       }
  38.  
  39.       if (blockProcess === 3) {
  40.         await msg.direct('What do you wish your password to be?');
  41.         await msg.author.dmChannel.awaitMessages(res => {
  42.           password = res.content;
  43.           blockProcess = 4;
  44.           return msg.direct('Your password: ' + password);
  45.         }, { max: 1, time: 30000, errors: ['time'] });
  46.       }
  47.  
  48.       if (blockProcess === 4) {
  49.         blockProcess = null;
  50.         return msg.direct('Your username:' + username +
  51.               '\nYour email: ' + email +
  52.               '\nYour password: ' + password + '\n`You have been registered!`');
  53.       }
  54.  
  55.       if (msg.channel.type !== 'dm') messages.push(await msg.reply('I have sent you a DM with further instructions.'));
  56.     } catch (err) {
  57.       messages.push(await msg.reply('Unable to send you a DM, you most likely have them disabled.'));
  58.     }
  59.  
  60.     return messages;
  61.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement