n3k4a

gend

May 6th, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. const Command = require(`${process.cwd()}/base/Command.js`);
  2.  
  3. class gend extends Command {
  4. constructor(client) {
  5. super(client, {
  6. name: "gend",
  7. description: "ends the giveaway",
  8. usage: "gend <[messageID]>",
  9. aliases: [],
  10. permLevel: 2
  11. });
  12. }
  13.  
  14. async run(bot, msg, args, level) {
  15. var currentGiveaways = (msg.guild.giveaways) ? msg.guild.giveaways : [];
  16. if (args[0] && !isNaN(args[0])) {
  17. for (var i = 0; i < currentGiveaways; i++) {
  18. if (currentGiveaways[i].giveaway.id == args[0]){
  19. clearTimeout(currentGiveaways[i].timer);
  20. currentGiveaways[i].finishGiveaway();
  21. return msg.reply(`successfully ended ${args[0]} giveaway`);
  22. }
  23. }
  24. return msg.reply(`message ID not found`);
  25. } else if (args[0]) {
  26. return msg.reply(`Invalid syntax`);
  27. } else {
  28. var giveaway = currentGiveaways[currentGiveaways.length - 1];
  29. clearTimeout(giveaway.timer);
  30. giveaway.finishGiveaway();
  31. return msg.reply(`successfully ended ${giveaway.giveaway.id} giveaway`);
  32. }
  33. }
  34. }
  35.  
  36. module.exports = gend;
Add Comment
Please, Sign In to add comment