Advertisement
Guest User

Giveaway Start

a guest
Jan 26th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const ms = require('ms');
  2.  
  3. exports.run = async (client, message, args) => {
  4.  
  5.     // If the member doesn't have enough permissions
  6.     if(!message.member.hasPermission('MANAGE_MESSAGES')){
  7.         return message.channel.send(':x: You need to have the manage messages permissions to start giveaways.');
  8.     }
  9.  
  10.     // Giveaway channel
  11.     let giveawayChannel = message.mentions.channels.first();
  12.     // If no channel is mentionned
  13.     if(!giveawayChannel){
  14.         return message.channel.send(':x: You have to mention a valid channel!');
  15.     }
  16.  
  17.     // Giveaway duration
  18.     let giveawayDuration = args[1];
  19.     // If the duration isn't valid
  20.     if(!giveawayDuration || isNaN(ms(giveawayDuration))){
  21.         return message.channel.send(':x: You have to specify a valid duration!');
  22.     }
  23.  
  24.     // Number of winners
  25.     let giveawayNumberWinners = args[2];
  26.     // If the specified number of winners is not a number
  27.     if(isNaN(giveawayNumberWinners)){
  28.         return message.channel.send(':x: You have to specify a valid number of winners!');
  29.     }
  30.  
  31.     // Giveaway prize
  32.     let giveawayPrize = args.slice(3).join(' ');
  33.     // If no prize is specified
  34.     if(!giveawayPrize){
  35.         return message.channel.send(':x: You have to specify a valid prize!');
  36.     }
  37.  
  38.     // Start the giveaway
  39. client.giveawaysManager.start(message.channel, {
  40.     time: ms(giveawayDuration),
  41.     prize: args.slice(2).join(" "),
  42.     winnerCount: parseInt(args[1]),
  43.     messages: {
  44.         giveaway: "🎉🎉 **GIVEAWAY** 🎉🎉",
  45.         giveawayEnded: "🎉🎉 **GIVEAWAY ENDED** 🎉🎉",
  46.         timeRemaining: "Time remaining: **{duration}**!",
  47.         inviteToParticipate: "React with 🎉 to participate!",
  48.         winMessage: "Congratulations, {winners}! You won **{prize}**!",
  49.         embedFooter: "Giveaways",
  50.         noWinner: "Giveaway cancelled, no valid participations.",
  51.         winners: "winner(s)",
  52.         endedAt: "Ended at",
  53.         units: {
  54.             seconds: "seconds",
  55.             minutes: "minutes",
  56.             hours: "hours",
  57.             days: "days",
  58.             pluralS: false // Not needed, because units end with a S so it will automatically removed if the unit value is lower than 2
  59.         }
  60.     }
  61. });
  62.  
  63.     message.channel.send(`Giveaway started in ${giveawayChannel}!`);
  64.  
  65. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement