Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```
- const countGame = new Set();
- const {prefix} = require('../config');
- module.exports.run = async (Happy, message, args) =>{
- let issuer = message.author;
- let player = message.member.user.tag;
- let num = parseInt(args[0]);
- if (!num) return message.channel.send(`Usage: "${prefix}count" <number>`);
- //if the game doesn't exist, add user to the set and send message that a new game started
- if(countGame.size === 0){
- if(num !== 1) return message.channel.send(`The game must start at **1**!`);
- await countGame.add(issuer.id);
- return message.channel.send(`**[Count Game]** **${player}** has started a game! Current count is at **${countGame.size}**. To join type *!c <next number>*! `);
- //if user enters incorrect number, end the game (clear the set)
- }else if(num !== countGame.size + 1) {
- countGame.clear();
- return message.channel.send(`:frowning: **${player}** has ended the game by entering **${num}**. Next time give him/her an advice about this game.`);
- //if a game is ongoing, add user to the set.
- } else {
- await countGame.add(issuer.id && countGame.size +1);
- //at every 10 numbers give a message that member who typed reached this number!
- let milestone;
- let i;
- let reached;
- // for(i= 1; i <= countGame.size; i++){
- // reached = countGame.size;
- // milestone = message.channel.send(`Hoaraaay, ${player} reached number ${reached}! Who will be the next player that will reach ${countGame.size+20}?`)
- // }
- do{
- //if(countGame.size == 20){
- milestone = message.channel.send(`Hoaraaay, ${player} reached number **${countGame.size}**! Who will be the next player that will reach **${countGame.size+3}**?`)
- //}
- } while (countGame.size % 3 == 0)
- return message.channel.send(`**[Count Game]** **${player}** joined the game! Game is now at **${countGame.size}**.`)
- }
- };
- module.exports.config = { //this is the config for the command, you can add things such as proper usage etc..
- name:"countgame",
- aliases:["c"],
- usage:"!count <number>",
- 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!!",
- accessableby: "Everyone",
- category:"Fun"
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement