Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ms = require('ms');
- exports.run = async (client, message, args) => {
- // If the member doesn't have enough permissions
- if(!message.member.hasPermission('MANAGE_MESSAGES')){
- return message.channel.send(':x: You need to have the manage messages permissions to start giveaways.');
- }
- // Giveaway channel
- let giveawayChannel = message.mentions.channels.first();
- // If no channel is mentionned
- if(!giveawayChannel){
- return message.channel.send(':x: You have to mention a valid channel!');
- }
- // Giveaway duration
- let giveawayDuration = args[1];
- // If the duration isn't valid
- if(!giveawayDuration || isNaN(ms(giveawayDuration))){
- return message.channel.send(':x: You have to specify a valid duration!');
- }
- // Number of winners
- let giveawayNumberWinners = args[2];
- // If the specified number of winners is not a number
- if(isNaN(giveawayNumberWinners)){
- return message.channel.send(':x: You have to specify a valid number of winners!');
- }
- // Giveaway prize
- let giveawayPrize = args.slice(3).join(' ');
- // If no prize is specified
- if(!giveawayPrize){
- return message.channel.send(':x: You have to specify a valid prize!');
- }
- // Start the giveaway
- client.giveawaysManager.start(message.channel, {
- time: ms(giveawayDuration),
- prize: args.slice(2).join(" "),
- winnerCount: parseInt(args[1]),
- messages: {
- giveaway: "🎉🎉 **GIVEAWAY** 🎉🎉",
- giveawayEnded: "🎉🎉 **GIVEAWAY ENDED** 🎉🎉",
- timeRemaining: "Time remaining: **{duration}**!",
- inviteToParticipate: "React with 🎉 to participate!",
- winMessage: "Congratulations, {winners}! You won **{prize}**!",
- embedFooter: "Giveaways",
- noWinner: "Giveaway cancelled, no valid participations.",
- winners: "winner(s)",
- endedAt: "Ended at",
- units: {
- seconds: "seconds",
- minutes: "minutes",
- hours: "hours",
- days: "days",
- pluralS: false // Not needed, because units end with a S so it will automatically removed if the unit value is lower than 2
- }
- }
- });
- message.channel.send(`Giveaway started in ${giveawayChannel}!`);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement