Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. client.on('message',async message => {
  2. const moment = require('moment'); //npm i moment
  3. const ms = require('ms') //npm i ms
  4. var prefix = 'o!' //Bot Prefix !
  5. var time = moment().format('Do MMMM YYYY , hh:mm');
  6. var room;
  7. var title;
  8. var duration;
  9. var currentTime = new Date(),
  10. hours = currentTime.getHours() + 3 ,
  11. minutes = currentTime.getMinutes(),
  12. done = currentTime.getMinutes() + duration,
  13. seconds = currentTime.getSeconds();
  14. if (minutes < 10) {
  15. minutes = "0" + minutes;
  16. }
  17. var suffix = "AM";
  18. if (hours >= 12) {
  19. suffix = "PM";
  20. hours = hours - 12;
  21. }
  22. if (hours == 0) {
  23. hours = 12;
  24. }
  25.  
  26. var filter = m => m.author.id === message.author.id;
  27. if(message.content.startsWith(prefix + "gstart")) {
  28.  
  29. if(!message.guild.member(message.author).hasPermission('MANAGE_MESSAGES')) return message.channel.send('**You do not have the manage messages permission**');
  30. message.channel.send(`**What is the name of the giveaway channel?, dont include #, Example Channel: main-giveaway**`).then(msg => {
  31. message.channel.awaitMessages(filter, {
  32. max: 1,
  33. time: 20000,
  34. errors: ['time']
  35. }).then(collected => {
  36. let room = message.guild.channels.find('name' , collected.first().content);
  37. if(!room) return message.channel.send('**Could not find the channel**');
  38. room = collected.first().content;
  39. collected.first().delete();
  40. msg.edit('**Duration of the giveaway, seconds = s, minutes = m, hours = h, days = d, weeks = w**').then(msg => {
  41. message.channel.awaitMessages(filter, {
  42. max: 1,
  43. time: 20000,
  44. errors: ['time']
  45. }).then(collected => {
  46. if(!collected.first().content.match(/[1-60][s,m,h,d,w]/g)) return message.channel.send('**This time is not supported!**');
  47. duration = collected.first().content
  48. collected.first().delete();
  49. msg.edit('**Now, what will the prize be?**').then(msg => {
  50. message.channel.awaitMessages(filter, {
  51. max: 1,
  52. time: 20000,
  53. errors: ['time']
  54. }).then(collected => {
  55. title = collected.first().content;
  56. collected.first().delete();
  57. msg.delete();
  58. message.delete();
  59. try {
  60. let giveEmbed = new Discord.RichEmbed()
  61. .setDescription(`**Item:** ${title}\nReact With 🎉 To Enter! \n**Total Giveaway Duration:** ${duration} \n **Created By:** ${message.member}`)
  62. .setFooter("Time Created:")
  63. .setTimestamp()
  64. message.guild.channels.find("name" , room).send('🎉🎈**Giveaway Created**🎈🎉' , {embed: giveEmbed}).then(m => {
  65. let re = m.react('🎉');
  66. setTimeout(() => {
  67. let users = m.reactions.get("🎉").users
  68. let list = users.array().filter(user => user.id !=client.user.id);
  69. let gFilter = list[Math.floor(Math.random() * list.length)]
  70. let endEmbed = new Discord.RichEmbed()
  71. .setAuthor(message.author.username, message.author.avatarURL)
  72. .setTitle("**Item:** " + title)
  73. .addField('Giveaway Ended !🎉',`**Winner:** ${gFilter}`)
  74. .setTimestamp()
  75. m.edit('** 🎉 GIVEAWAY ENDED 🎉**' , {embed: endEmbed});
  76. message.guild.channels.find("name" , room).send(`**Congratulations ${gFilter}! contact ${message.author} for more info about The \`${title}\`**`)
  77. }, ms(duration));
  78. });
  79. } catch(e) {
  80. message.channel.send(`:heavy_multiplication_x:| **i Don't Have Perm**`);
  81. console.log(e);
  82. }
  83. });
  84. });
  85. });
  86. });
  87. });
  88. });
  89. }
  90. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement