Advertisement
_xShaDowZx

shadow

Aug 25th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const moment = require('moment');
  2. client.on('message',async message => {
  3.   var time = moment().format('Do MMMM YYYY , hh:mm');
  4.   var room;
  5.   var title;
  6.   var duration;
  7.   var gMembers;
  8.   var currentTime = new Date(),
  9. hours = currentTime.getHours() + 3 ,
  10. minutes = currentTime.getMinutes(),
  11. done = currentTime.getMinutes() + duration / 60000 ,
  12. seconds = currentTime.getSeconds();
  13. if (minutes < 10) {
  14. minutes = "0" + minutes;
  15. }
  16. var suffix = "AM";
  17. if (hours >= 12) {
  18. suffix = "PM";
  19. hours = hours - 12;
  20. }
  21. if (hours == 0) {
  22. hours = 12;
  23. }
  24.  
  25.   var filter = m => m.author.id === message.author.id;
  26.   if(message.content.startsWith(prefix + "gcreate")) {
  27.  
  28.     if(!message.guild.member(message.author).hasPermission('MANAGE_GUILD')) return message.channel.send(':heavy_multiplication_x:| **You dont have perms**');
  29.     message.channel.send(`:one:| **Please type the name of a channel in this server**`).then(msg => {
  30.       message.channel.awaitMessages(filter, {
  31.         max: 1,
  32.         time: 20000,
  33.         errors: ['time']
  34.       }).then(collected => {
  35.         let room = message.guild.channels.find('name' , collected.first().content);
  36.         if(!room) return message.channel.send(":heavy_multiplication_x:| **I couldn`f find the channel `You must rewrite the command` :( __(Don't tag the channel just write the channel name without `#`)__**");
  37.         room = collected.first().content;
  38.         collected.first().delete();
  39.         msg.edit(':two:| **Time For The Giveaway (Please enter the duration of the giveaway in seconds. `(Example: 1 means 1 minute)`**').then(msg => {
  40.           message.channel.awaitMessages(filter, {
  41.             max: 1,
  42.             time: 20000,
  43.             errors: ['time']
  44.           }).then(collected => {
  45.             if(isNaN(collected.first().content)) return message.channel.send(':heavy_multiplication_x:| **You must set a correct time period.. `You must rewrite the command`**');
  46.             duration = collected.first().content * 60000;
  47.             collected.first().delete();
  48.             msg.edit(':three:| **Please enter the giveaway prize. This will also begin the giveaway **').then(msg => {
  49.               message.channel.awaitMessages(filter, {
  50.                 max: 1,
  51.                 time: 20000,
  52.                 errors: ['time']
  53.               }).then(collected => {
  54.                 title = collected.first().content;
  55.                 collected.first().delete();
  56.                 msg.delete();
  57.                 message.delete();
  58.                 try {
  59.                   let giveEmbed = new Discord.RichEmbed()
  60.                   .setDescription(`**${title}** \nReact With 🎉 To Enter! \nTime remaining : ${duration / 60000} **Minutes**\n **Created at :** ${hours}:${minutes}:${seconds} ${suffix}`)
  61.                   .setFooter(message.author.username, message.author.avatarURL);
  62.                   message.guild.channels.find("name" , room).send('🎉 **Giveaway Created** 🎉' , {embed: giveEmbed}).then(m => {
  63.                      let re = m.react('🎉');
  64.                      setTimeout(() => {
  65.                        let users = m.reactions.get("🎉").users;
  66.                        let list = users.array().filter(u => u.id !== m.author.id !== client.user.id);
  67.                        let gFilter = list[Math.floor(Math.random() * list.length) + 0]
  68.                        let endEmbed = new Discord.RichEmbed()
  69.                        .setAuthor(message.author.username, message.author.avatarURL)
  70.                        .setTitle(title)
  71.                        .addField('Giveaway Ended !🎉',`Winners : ${gFilter} \nEnded at :`)
  72.                        .setTimestamp()
  73.                      m.edit('** 🎉 GIVEAWAY ENDED 🎉**' , {embed: endEmbed});
  74.                     message.guild.channels.find("name" , room).send(`**Congratulations __${gFilter}!__ You won The Giveaway 🎉-> \`${title}\`**` ,  {})
  75.                      },duration);
  76.                    });
  77.                 } catch(e) {
  78.                 message.channel.send(`:heavy_multiplication_x:| **I Don't Have Prems**`);
  79.                  console.log(e);
  80.                }
  81.              });
  82.            });
  83.          });
  84.        });
  85.      });
  86.    });
  87.  }
  88. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement