Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. ```
  2. const countGame = new Set();
  3. const {prefix} = require('../config');
  4.  
  5. module.exports.run = async (Happy, message, args) =>{
  6. let issuer = message.author;
  7. let player = message.member.user.tag;
  8. let num = parseInt(args[0]);
  9. if (!num) return message.channel.send(`Usage: "${prefix}count" <number>`);
  10.  
  11. //if the game doesn't exist, add user to the set and send message that a new game started
  12. if(countGame.size === 0){
  13. if(num !== 1) return message.channel.send(`The game must start at **1**!`);
  14. await countGame.add(issuer.id);
  15. return message.channel.send(`**[Count Game]** **${player}** has started a game! Current count is at **${countGame.size}**. To join type *!c <next number>*! `);
  16.  
  17. //if user enters incorrect number, end the game (clear the set)
  18. }else if(num !== countGame.size + 1) {
  19. countGame.clear();
  20. return message.channel.send(`:frowning: **${player}** has ended the game by entering **${num}**. Next time give him/her an advice about this game.`);
  21. //if a game is ongoing, add user to the set.
  22. } else {
  23. await countGame.add(issuer.id && countGame.size +1);
  24. //at every 10 numbers give a message that member who typed reached this number!
  25. let milestone;
  26. let i;
  27. let reached;
  28. // for(i= 1; i <= countGame.size; i++){
  29. // reached = countGame.size;
  30. // milestone = message.channel.send(`Hoaraaay, ${player} reached number ${reached}! Who will be the next player that will reach ${countGame.size+20}?`)
  31. // }
  32. do{
  33. //if(countGame.size == 20){
  34. milestone = message.channel.send(`Hoaraaay, ${player} reached number **${countGame.size}**! Who will be the next player that will reach **${countGame.size+3}**?`)
  35. //}
  36. } while (countGame.size % 3 == 0)
  37. return message.channel.send(`**[Count Game]** **${player}** joined the game! Game is now at **${countGame.size}**.`)
  38.  
  39. }
  40.  
  41.  
  42.  
  43.  
  44. };
  45.  
  46. module.exports.config = { //this is the config for the command, you can add things such as proper usage etc..
  47. name:"countgame",
  48. aliases:["c"],
  49. usage:"!count <number>",
  50. description: "It's a game, count as much as you can but don't go over the next number otherwise it will reset the game!!",
  51. accessableby: "Everyone",
  52. category:"Fun"
  53.  
  54. }
  55. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement