NevaehAnimeLover

Untitled

Feb 19th, 2021
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. const ms = require('ms')
  2. if (message.content.startsWith(prefix + "giveaway")) {
  3. if (!message.guild) return;
  4. if (!message.member.hasPermission("ADMINISTRATOR")) {
  5. return message.channel.send(":x: | You must be an administrator of this server");
  6. }
  7. let time = args[1]
  8. if (!time) return message.channel.send('You did not specify a time!');
  9.  
  10. if (
  11. !args[1].endsWith("d") &&
  12. !args[1].endsWith("h") &&
  13. !args[1].endsWith("m") &&
  14. !args[1].endsWith("s")
  15. )
  16. return message.channel.send('You need to use d (days), h (hours), m (minutes), or s (seconds)')
  17.  
  18. let channel = message.mentions.channels.first();
  19. if (!channel) return message.channel.send("I can't find that channel in the server!")
  20.  
  21. let prize = args.slice(3).join(" ")
  22. if (!prize) return message.channel.send('Arguement missing. What is the prize?')
  23. let item = args.slice(3).join(" ")
  24.  
  25. channel.send(":tada: **NEW GIVEAWAY** :tada:")
  26. var embed = new Discord.MessageEmbed()
  27. .setTitle("New Giveaway!")
  28. .setDescription(`React with :tada: to enter the giveaway!\nHosted By: **${message.author}**\nTime: **${time}**\nPrize: **${prize}**`)
  29. .setTimestamp(Date.now + ms(args[1]))
  30. .setColor(3447003)
  31. .addField(`Duration : `, ms(ms(time), {
  32. long: true
  33. }), true);
  34.  
  35. try {
  36. const sent = message.channel.send(embed);
  37. message.react('🎉');
  38.  
  39. setTimeout(async () => {
  40. try {
  41. const peopleReactedBot = sent.reactions.cache
  42. .get('🎉')
  43. .users.fetch();
  44.  
  45. const peopleReacted = peopleReactedBot
  46. .array()
  47. .filter((u) => u.id !== client.user.id);
  48. console.log({ peopleReacted });
  49. } catch (e) {
  50. message.channel.send(
  51. `An unknown error happened during the draw of the giveaway **${item}**: \`${e}\``
  52. );
  53. }
  54. }, timeout);
  55. } catch (e) {
  56. message.channel.send(
  57. `An error occurred while running the command You shouldn't ever receive an error like this Please contact <@390690088348024843> in this server **${item}**: \`${e}\``
  58. );
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment