├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ └── npm-publish.yml ├── package.json ├── index.js ├── LICENSE ├── games ├── guessTheNumber-game.js ├── pokemon-game.js ├── guessTheFlag-game.js ├── guessTheLogo-game.js ├── findEmoji-game.js ├── rps-game.js ├── hangman-game.js ├── connect4-game.js ├── snake-game.js ├── fasttyper-game.js └── tictactoe-game.js └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | ko_fi: gizmoxgg 4 | custom: ["https://buymeacoffee.com/g1zmo"] 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "djs-games", 3 | "version": "2.1.8", 4 | "description": "A Discord Js Package for Mini-Games", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Gizmo", 10 | "license": "MIT", 11 | "dependencies": { 12 | "node-fetch": "^2.6.1", 13 | "random-unicode-emoji": "^1.0.2" 14 | }, 15 | "devDependencies": {}, 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/gizmolabAi/djs-games" 19 | }, 20 | "keywords": [ 21 | "discord", 22 | "discord-games", 23 | "mini-games", 24 | "discord.js" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports.SnakeGame = require('./games/snake-game') 2 | 3 | module.exports.TicTacToe = require('./games/tictactoe-game') 4 | 5 | module.exports.ConnectFour = require('./games/connect4-game') 6 | 7 | module.exports.FastTyper = require('./games/fasttyper-game') 8 | 9 | module.exports.GuessTheNumber = require('./games/guessTheNumber-game') 10 | 11 | module.exports.RockPaperScissors = require('./games/rps-game') 12 | 13 | module.exports.HangMan = require('./games/hangman-game') 14 | 15 | module.exports.Pokemon = require('./games/pokemon-game') 16 | 17 | module.exports.GTL = require('./games/guessTheLogo-game') 18 | 19 | module.exports.GTF = require('./games/guessTheFlag-game') 20 | 21 | module.exports.FindEmoji = require('./games/findEmoji-game') 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 gizmo-dev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages 3 | 4 | name: Node.js Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: actions/setup-node@v2 16 | with: 17 | node-version: 14 18 | - run: npm ci 19 | - run: npm test 20 | 21 | publish-npm: 22 | needs: build 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v2 26 | - uses: actions/setup-node@v2 27 | with: 28 | node-version: 14 29 | registry-url: https://registry.npmjs.org/ 30 | - run: npm ci 31 | - run: npm publish 32 | env: 33 | NODE_AUTH_TOKEN: ${{secrets.npm_token}} 34 | 35 | publish-gpr: 36 | needs: build 37 | runs-on: ubuntu-latest 38 | permissions: 39 | contents: read 40 | packages: write 41 | steps: 42 | - uses: actions/checkout@v2 43 | - uses: actions/setup-node@v2 44 | with: 45 | node-version: 14 46 | registry-url: https://npm.pkg.github.com/ 47 | - run: npm ci 48 | - run: npm publish 49 | env: 50 | NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} 51 | -------------------------------------------------------------------------------- /games/guessTheNumber-game.js: -------------------------------------------------------------------------------- 1 | class GuessTheNumber { 2 | 3 | constructor(options) { 4 | if (!options.message) throw new TypeError('Missing argument: message') 5 | this.message = options.message 6 | this.wrongGuess = options.wrongGuess 7 | this.correctGuess = options.correctGuess 8 | 9 | 10 | } 11 | 12 | start() { 13 | 14 | var options = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]; 15 | var result = options[Math.floor(Math.random() * options.length)]; 16 | 17 | this.message.channel.send(`**Guess a number from 1 to 10!**`).then(async msg => { 18 | const filter = m => m.author.id == this.message.author.id 19 | this.message.channel.awaitMessages({ filter, max: 1 }) 20 | 21 | .then(collected => { 22 | var guess = collected.first().content 23 | if (isNaN(guess)) { 24 | 25 | this.message.channel.send(`**🤦‍♂️ You dimmadumbass, I need a number. Not that alphabet shit!** *Use the command again to play again*`) 26 | 27 | } else if (guess != result) { 28 | 29 | this.message.channel.send(this.wrongGuess || `**Nope, that isn't the number. You only have 2 chances left**`) 30 | 31 | this.message.channel.awaitMessages({ filter, max: 1 }) 32 | .then(collected => { 33 | var guess = collected.first().content 34 | if (isNaN(guess)) { 35 | this.message.channel.send(`**🤦‍♂️ You You dimmadumbass, I need a number. Not that alphabet shit!** *Use the command again to play again*`) 36 | 37 | } else if (guess === result) { 38 | 39 | this.message.channel.send(this.correctGuess || `**🎉 You guessed the number in your second try!** *Number was ${result}*`) 40 | 41 | 42 | } else if (guess != result) { 43 | 44 | this.message.channel.send(this.wrongGuess || `**Nope, that isn't the number. You only have 1 chance left**`) 45 | 46 | this.message.channel.awaitMessages({ filter, max: 1 }) 47 | .then(collected => { 48 | var guess = collected.first().content 49 | if (isNaN(guess)) { 50 | 51 | this.message.channel.send(`**🤦‍♂️ You You dimmadumbass, I need a number. Not that alphabet shit!** *Use the command again to play again*`) 52 | } else if (guess != result) { 53 | 54 | this.message.channel.send(this.wrongGuess || `**Nope, that isn't the number. You only have 0 chances left.** *Number was ${result}*`) 55 | 56 | 57 | } else if (guess === result) { 58 | 59 | this.message.channel.send(this.correctGuess || `**🎉 You guessed the number in your last try!** *Number was ${result}*`) 60 | } 61 | }) 62 | } else if (guess === result) { 63 | 64 | this.message.channel.send(this.correctGuess || `**🎉 You guessed the number in your second try!** *Number was ${result}*`) 65 | } 66 | }) 67 | } else if (guess === result) { 68 | 69 | this.message.channel.send(this.correctGuess || `**🎉 You guessed the number in your first try!** *Number was ${result}*`) 70 | } 71 | }) 72 | }) 73 | } 74 | 75 | } 76 | 77 | module.exports = GuessTheNumber; -------------------------------------------------------------------------------- /games/pokemon-game.js: -------------------------------------------------------------------------------- 1 | class Pokemon { 2 | /** 3 | * @name ShuffleGuess 4 | * @kind constructor 5 | * @param {Object} options options 6 | * @param {any} [options.message] message 7 | * @param {any} [options.token] token 8 | * @param {any} [options.winMessage] win message 9 | * @param {any} [options.loseMessage] lose message 10 | * @param {any} [options.embedColor] embedcolor 11 | * @param {any} [options.stopCommand] stop command 12 | * @param {any} [options.wrongGuess] wrong guess 13 | * @param {any} [options.maxAttempts] max attempts 14 | */ 15 | constructor(options) { 16 | if (!options.token) throw new TypeError('Missing argument: token') 17 | if (typeof options.token !== 'string') throw new TypeError('token must be in a string') 18 | 19 | if (!options.message) throw new TypeError('Missing argument: message') 20 | 21 | this.message = options.message; 22 | this.winMessage = options.winMessage || '`You Guessed It Right!`'; 23 | this.loseMessage = options.loseMessage || 'You Lost!'; 24 | this.wrongGuess = options.wrongGuess || 'Wrong Guess Try Again!'; 25 | this.token = options.token; 26 | this.embedColor = options.embedColor || '#0099ff'; 27 | this.stopCommand = options.stopCommand || 'stop'; 28 | this.maxAttempts = options.maxAttempts || 3; 29 | 30 | } 31 | async start() { 32 | const fetch = require("node-fetch") 33 | const Discord = require('discord.js'); 34 | fetch(`https://api.dagpi.xyz/data/wtp`, { 35 | headers: { 36 | "Authorization": this.token 37 | } 38 | }) 39 | .then(res => res.json()) 40 | .then(data => { 41 | 42 | const pok = new Discord.MessageEmbed() 43 | .setTitle(`Who's That Pokemon?`) 44 | .addField(`Type:`, `${data.Data.Type}`, true) 45 | .addField(`Abilities:`, `${data.Data.abilities}`) 46 | .setImage(data.question) 47 | .setColor(this.embedColor) 48 | .setFooter(`You have Unlimited Chances! Type stop to stop the game`) 49 | 50 | const right = new Discord.MessageEmbed() 51 | .setTitle(this.winMessage) 52 | .setAuthor(this.message.author.tag) 53 | .setURL(data.Data.Link) 54 | .setDescription(`It was ${data.Data.name}`) 55 | .setColor(this.embedColor) 56 | .setImage(data.answer) 57 | 58 | 59 | const wrong = new Discord.MessageEmbed() 60 | .setTitle(this.loseMessage) 61 | .setAuthor(this.message.author.tag) 62 | .setURL(data.Data.Link) 63 | .setDescription(`It was ${data.Data.name}`) 64 | .setColor(this.embedColor) 65 | .setImage(data.answer) 66 | 67 | 68 | this.message.channel.send({ embeds: [pok] }) 69 | const gameFilter = m => m.author.id === this.message.author.id 70 | const gameCollector = this.message.channel.createMessageCollector({ gameFilter }); 71 | let i = this.maxAttempts - 1; 72 | gameCollector.on('collect', async msg => { 73 | if (msg.author.bot) return 74 | const selection = msg.content.toLowerCase(); 75 | if (selection === data.Data.name.toLowerCase()) { 76 | this.message.channel.send({ embeds: [right] }) 77 | gameCollector.stop() 78 | } else if (selection === this.stopCommand) { 79 | this.message.channel.send({ embeds: [wrong] }) 80 | gameCollector.stop(); 81 | } else if (i <= this.maxAttempts && selection !== data.Data.name && selection !== this.stopCommand && i > 0) { 82 | i--; 83 | this.message.channel.send(`${this.wrongGuess} | You have ${i + 1} chances left | Type ${this.stopCommand} to cancel the Game`) 84 | } else if (i <= 0 && selection !== data.brand) { 85 | this.message.channel.send({ embeds: [wrong] }) 86 | gameCollector.stop(); 87 | } 88 | }) 89 | 90 | }) 91 | .catch(err => { 92 | console.log(err) 93 | }) 94 | } 95 | } 96 | 97 | module.exports = Pokemon; 98 | -------------------------------------------------------------------------------- /games/guessTheFlag-game.js: -------------------------------------------------------------------------------- 1 | class GTF { 2 | 3 | constructor(options) { 4 | if (!options.token) throw new TypeError('Missing argument: token') 5 | if (typeof options.token !== 'string') throw new TypeError('token must be in a string') 6 | if (!options.stopCommand) throw new TypeError('Missing argument: stopCommand') 7 | if (typeof options.stopCommand !== 'string') throw new TypeError('stopCommand Must be a string') 8 | if (!options.message) throw new TypeError('Missing argument: message') 9 | /* 10 | if (typeof options.winFooter !== 'string') throw new TypeError('embedFooter must be a string') 11 | if (typeof options.winColor !== 'string') throw new TypeError('embedColor must be a string') 12 | 13 | if (typeof options.lostFooter !== 'string') throw new TypeError('embedFooter must be a string') 14 | if (typeof options.lostColor !== 'string') throw new TypeError('embedColor must be a string') 15 | 16 | if (typeof options.questionFooter !== 'string') throw new TypeError('embedFooter must be a string') 17 | if (typeof options.questionColor !== 'string') throw new TypeError('embedColor must be a string') 18 | */ 19 | this.message = options.message; 20 | this.token = options.token; 21 | this.winFooter = options.winFooter; 22 | this.winColor = options.winColor 23 | this.lostColor = options.lostColor; 24 | this.lostFooter = options.lostFooter; 25 | this.questionColor = options.questionColor; 26 | this.questionFooter = options.questionFooter; 27 | this.stopCommand = options.stopCommand 28 | this.maxAttempts = options.maxAttempts || 3; 29 | this.winMessage = options.winMessage || '`You Guessed It Right!`'; 30 | this.loseMessage = options.loseMessage || 'You Lost!'; 31 | this.wrongGuess = options.wrongGuess || 'Wrong Guess Try Again!'; 32 | this.stopCommand = options.stopCommand || 'stop'; 33 | this.commandName = options.commandName || 'guessTheFlag'; 34 | 35 | } 36 | async start() { 37 | const fetch = require("node-fetch") 38 | const Discord = require('discord.js'); 39 | fetch(`https://api.dagpi.xyz/data/flag`, { 40 | headers: { 41 | "Authorization": this.token 42 | } 43 | }) 44 | .then(res => res.json()) 45 | .then(data => { 46 | const que = new Discord.MessageEmbed() 47 | .setTitle(`Guess the Flag!`) 48 | .setColor(this.questionColor || "RANDOM") 49 | .setImage(data.flag) 50 | .setFooter(this.questionFooter || "Made by GizmoLab") 51 | 52 | 53 | const right = new Discord.MessageEmbed() 54 | .setTitle(this.winMessage) 55 | .setAuthor(this.message.author.tag) 56 | .setColor(this.winColor || "RANDOM") 57 | .setDescription(`It was ${data.Data.name.common}`) 58 | .setImage(data.flag) 59 | .setFooter(this.winFooter || "Made by GizmoLab") 60 | 61 | 62 | const wrong = new Discord.MessageEmbed() 63 | .setTitle(this.loseMessage) 64 | .setColor(this.lostColor || "RANDOM") 65 | .setAuthor(this.message.author.tag) 66 | .setDescription(`It was ${data.Data.name.common}`) 67 | .setImage(data.flag) 68 | .setFooter(this.lostFooter || "Made by GizmoLab") 69 | 70 | 71 | this.message.channel.send({ embeds: [que] }) 72 | const gameFilter = m => m.author.id === this.message.author.id 73 | const gameCollector = this.message.channel.createMessageCollector({ gameFilter }); 74 | let i = this.maxAttempts - 1; 75 | gameCollector.on('collect', async msg => { 76 | if (msg.author.bot || msg.author.id != this.message.author.id) return 77 | const selection = msg.content; 78 | if (msg.author.id === this.message.author.id && selection.includes((this.commandName).toLowerCase())) { 79 | this.message.channel.send({ content: `You already have one game running` }) 80 | return; 81 | } 82 | if (selection === data.Data.name.common.toLowerCase()) { 83 | this.message.reply({ embeds: [right] }) 84 | gameCollector.stop() 85 | } else if (selection === this.stopCommand) { 86 | this.message.channel.send({ embeds: [wrong] }) 87 | gameCollector.stop(); 88 | } else if (i <= this.maxAttempts && selection !== data.Data.name.common && selection !== this.stopCommand && i > 0) { 89 | i--; 90 | this.message.channel.send({ content: `${this.wrongGuess} | You have ${i + 1} chances left | Type ${this.stopCommand} to cancel the Game` }) 91 | } else if (i <= 0 && selection !== data.Data.name.common) { 92 | this.message.channel.send({ embeds: [wrong] }) 93 | gameCollector.stop(); 94 | } 95 | }) 96 | 97 | }) 98 | .catch(err => { 99 | console.log(err) 100 | }) 101 | } 102 | } 103 | 104 | module.exports = GTF; 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | 5 |

6 | 7 | 8 |
9 |

10 | 11 |


12 | 13 |

14 | A discord.js Games Package with Who's that Pokemon, ConnectFour, Snake, rock paper scissors, guessTheNumber, , guess the Logo , Guess The Flag, tictactoe , fast type, Hangman and More! 15 |
16 | Explore the docs » 17 |
18 |
19 | Report Bug 20 | · 21 | Discord 22 |

23 |

24 | 25 | 26 | # About 27 | - A discord.js Games Package with Who's that Pokemon, ConnectFour, Snake, rock paper scissors, guessTheNumber, , guess the Logo , Guess The Flag, tictactoe , fast type, Hangman and More! 28 | - Join our [Support Server](https://discord.gg/jDP2FbvCdk) for help 29 | 30 | # Installation 31 | 32 | ```npm i djs-games``` 33 | 34 | # Example usage 35 | 36 | ``` 37 | USE ACCORDING TO YOUR COMMAND HANDLER 38 | ``` 39 | 40 | **Who's That Pokemon** 41 | === 42 | 43 | ```js 44 | const { Pokemon } = require('djs-games') 45 | const game = new Pokemon({ 46 | message: message, 47 | token: 'dagpi-token-here', // Get Your Api Token at https://dagpi.xyz/dashboard 48 | winMessage: 'You Win!', 49 | loseMessage: 'You Lose!', 50 | wrongGuess: 'Wrong Guess!', 51 | stopCommand = 'stop', 52 | maxAttempts: 10, 53 | }) 54 | game.start() 55 | ``` 56 | 57 | **Guess The Logo** 58 | === 59 | 60 | ```js 61 | const { GTL } = require('djs-games') 62 | const game = new GTL({ 63 | message: message, 64 | token: 'dagpi-token-here', // *Required!! Get Your Api Token at https://dagpi.xyz/dashboard 65 | stopCommand: 'stop', // *Required!! 66 | winFooter: 'You Win!', // Set The Footer of the win message 67 | winColor: 'GREEN', // The embed color of the win message 68 | loseFooter: 'You Lose!', // Set The Footer of the lose message 69 | loseColor: 'RED', // The embed color of the lose message 70 | questionFooter: 'Guess the Logo!', // Set The Footer of the question message 71 | questionColor: 'BLUE', // The embed color of the question message 72 | maxAttempts: 5, // 73 | }) 74 | game.start() 75 | ``` 76 | **Guess The Flag** 77 | === 78 | 79 | ```js 80 | const { GTF } = require('djs-games') 81 | const game = new GTF({ 82 | message: message, 83 | token: 'dagpi-token-here', // *Required!! Get Your Api Token at https://dagpi.xyz/dashboard 84 | stopCommand: 'stop', // *Required!! 85 | winFooter: 'You Win!', // Set The Footer of the win message 86 | winColor: 'GREEN', // The embed color of the win message 87 | loseFooter: 'You Lose!', // Set The Footer of the lose message 88 | loseColor: 'RED', // The embed color of the lose message 89 | questionFooter: 'Guess the Flag!', // Set The Footer of the question message 90 | questionColor: 'BLUE', // The embed color of the question message 91 | winMessage: 'You Win!', // Set The Win Message 92 | loseMessage: 'You Lose!', // Set The Lose Message 93 | maxAttempts: 5, // 94 | wrongGuess: 'Wrong Guess!', // Set The Wrong Guess Message 95 | }) 96 | game.start() 97 | ``` 98 | 99 | **Tic Tac Toe** 100 | === 101 | ```js 102 | const { TicTacToe } = require('djs-games') 103 | const game = new TicTacToe({ 104 | message: message, 105 | xEmote: '❌', // The Emote for X 106 | oEmote: '0️⃣', // The Emote for O 107 | xColor: 'PRIMARY', 108 | oColor: 'PRIMARY', // The Color for O 109 | embedDescription: 'Tic Tac Toe', // The Description of the embed 110 | }) 111 | game.start() 112 | ``` 113 | 114 | **ConnectFour** 115 | === 116 | ```js 117 | const { ConnectFour } = require('djs-games') 118 | const game = new ConnectFour({ 119 | message: message, 120 | player1: '🔴', 121 | player2: '🟡', 122 | }) 123 | game.start() 124 | ``` 125 | 126 | **SNAKE** 127 | === 128 | 129 | ```js 130 | const { Snake } = require('djs-games') 131 | const game = new Snake({ 132 | message: message, 133 | buttons: true, // If you want to use buttons || False if you want to use reactions 134 | snake: '🟩', 135 | apple: '🍎', 136 | embedColor: 'RANDOM', 137 | leftButton: '◀', 138 | rightButton: '▶', 139 | upButton: '▲', 140 | downButton: '▼', 141 | }) 142 | game.start() 143 | ``` 144 | 145 | **RockPaperScissors** 146 | === 147 | ```js 148 | const { RockPaperScissors } = require('djs-games') 149 | const game = new RockPaperScissors({ 150 | message: message, 151 | }) 152 | game.start() 153 | ``` 154 | 155 | ## Docs 156 | Checkout the [docs](https://docs.gizmolab.xyz) for more information on the games and how to use them. 157 | 158 | 159 | # Feature Requests 160 | 161 | If you have any feature requests, please open an issue on [GitHub](https://github.com/GizmolabAI/djs-games) 162 | 163 | # Contributing 164 | 165 | Any contributions you make are **greatly appreciated**. 166 | 167 | 1. Fork the Project 168 | 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 169 | 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 170 | 4. Push to the Branch (`git push origin feature/AmazingFeature`) 171 | 5. Open a Pull Request 172 | 173 | 174 | # Help 175 | 176 | Join Our Discord Server for help related to our projects or programming in General. 177 | 178 | [![Support Server](https://img.shields.io/discord/834390097621286922.svg?label=Discord&logo=Discord&colorB=7289da&style=for-the-badge)](https://discord.gg/jDP2FbvCdk) 179 | 180 | # Buy us a coffee 181 | 182 | 183 | 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /games/guessTheLogo-game.js: -------------------------------------------------------------------------------- 1 | class GTL { 2 | 3 | constructor(options) { 4 | if (!options.token) throw new TypeError('Missing argument: token') 5 | if (typeof options.token !== 'string') throw new TypeError('token must be in a string') 6 | if (!options.stopCommand) throw new TypeError('Missing argument: stopCommand') 7 | if (typeof options.stopCommand !== 'string') throw new TypeError('stopCommand Must be a string') 8 | if (!options.message) throw new TypeError('Missing argument: message') 9 | /* 10 | if (typeof options.winFooter !== 'string') throw new TypeError('embedFooter must be a string') 11 | if (typeof options.winColor !== 'string') throw new TypeError('embedColor must be a string') 12 | 13 | if (typeof options.lostFooter !== 'string') throw new TypeError('embedFooter must be a string') 14 | if (typeof options.lostColor !== 'string') throw new TypeError('embedColor must be a string') 15 | 16 | if (typeof options.questionFooter !== 'string') throw new TypeError('embedFooter must be a string') 17 | if (typeof options.questionColor !== 'string') throw new TypeError('embedColor must be a string') 18 | */ 19 | this.message = options.message; 20 | this.token = options.token; 21 | this.winFooter = options.winFooter; 22 | this.winColor = options.winColor 23 | this.lostColor = options.lostColor; 24 | this.lostFooter = options.lostFooter; 25 | this.questionColor = options.questionColor; 26 | this.questionFooter = options.questionFooter; 27 | this.stopCommand = options.stopCommand || "stop"; 28 | this.maxAttempts = options.maxAttempts || 3; 29 | this.commandName = options.commandName || 'guessTheLogo'; 30 | 31 | } 32 | 33 | async start() { 34 | 35 | const fetch = require("node-fetch") 36 | const Discord = require('discord.js'); 37 | fetch(`https://api.dagpi.xyz/data/logo`, { 38 | headers: { 39 | "Authorization": this.token 40 | } 41 | }) 42 | .then(res => res.json()) 43 | .then(data => { 44 | 45 | const que = new Discord.MessageEmbed() 46 | .setTitle(`Guess the Logo!`) 47 | .addField(`Clue:`, `${data.clue || `No Clue for this round`}`, true) 48 | .addField(`Hint:`, `${data.hint}`) 49 | .setColor(this.questionColor || "RANDOM") 50 | .setImage(data.question) 51 | .setFooter(this.questionFooter || "Made by GizmoLab") 52 | 53 | 54 | const right = new Discord.MessageEmbed() 55 | .setTitle(`You Guessed It Right!`) 56 | .setAuthor(this.message.author.tag) 57 | .setColor(this.winColor || "RANDOM") 58 | .setDescription(`It was ${data.brand}`) 59 | .setImage(data.answer) 60 | .setFooter(this.winFooter || "Made by GizmoLab") 61 | 62 | 63 | const wrong = new Discord.MessageEmbed() 64 | .setTitle(`You Lost`) 65 | .setColor(this.lostColor || "RANDOM") 66 | .setAuthor(this.message.author.tag) 67 | .setDescription(`It was ${data.brand}`) 68 | .setImage(data.answer) 69 | .setFooter(this.lostFooter || "Made by GizmoLab") 70 | 71 | 72 | this.message.channel.send({ embeds: [que] }) 73 | // .then(() => { 74 | // 75 | // this.message.channel.awaitMessages({ max: this.maxAttempt }) 76 | // .then(collected => { 77 | // console.log(collected) 78 | // if (collected.first().content.toLowerCase() === this.stopCommand) { 79 | // this.message.channel.send({ embeds: [wrong] }) 80 | // return; 81 | // } 82 | // if (collected.first().content.toLowerCase() === data.brand.toLowerCase()) { 83 | // this.message.channel.send({ embeds: [right] }) 84 | // } else { 85 | // this.message.channel.send({ embeds: [wrong] }) 86 | // } 87 | // }) 88 | // .catch(err => { 89 | // console.log(err) 90 | // }) 91 | // }) 92 | const gameFilter = (m) => m.author.id === this.message.author.id; 93 | const gameCollector = this.message.channel.createMessageCollector({ gameFilter }); 94 | let i = this.maxAttempts - 1; 95 | gameCollector.on('collect', async msg => { 96 | if (msg.author.bot || msg.author.id != this.message.author.id) return 97 | const selection = msg.content.toLowerCase(); 98 | if (selection === data.brand.toLowerCase()) { 99 | this.message.channel.send({ embeds: [right] }) 100 | gameCollector.stop() 101 | } else if (selection === this.stopCommand) { 102 | this.message.channel.send({ embeds: [wrong] }) 103 | gameCollector.stop(); 104 | } else if (i <= this.maxAttempts && selection !== data.brand && selection !== this.stopCommand && i > 0) { 105 | i--; 106 | this.message.channel.send({ content: `Wrong Guess Try Again! | You have ${i + 1} chances left - Type ${this.stopCommand} to cancel the Game` }) 107 | } else if (i <= 0 && selection !== data.brand) { 108 | this.message.channel.send({ embeds: [wrong] }) 109 | gameCollector.stop(); 110 | } 111 | }) 112 | }) 113 | .catch(err => { 114 | console.log(err) 115 | }) 116 | } 117 | 118 | 119 | 120 | } 121 | 122 | module.exports = GTL; 123 | 124 | -------------------------------------------------------------------------------- /games/findEmoji-game.js: -------------------------------------------------------------------------------- 1 | const { random } = require("random-unicode-emoji") 2 | const { MessageEmbed, MessageButton, MessageActionRow } = require("discord.js") 3 | 4 | let emojiChoosen; 5 | 6 | class FindEmoji { 7 | constructor(options) { 8 | if (!options.message) throw new TypeError('Missing argument: message') 9 | 10 | if (typeof options.timeoutTime !== 'number') throw new TypeError('Error: timeoutTime must be a number') 11 | 12 | this.message = options.message 13 | this.winMessage = options.winMessage ? options.winMessage : "WoW! You won." 14 | this.loseMessage = options.loseMessage ? options.loseMessage : "Oops! thats wrong." 15 | this.timeOutMessage = options.timeOutMessage ? options.timeOutMessage : "Timeout :()" 16 | this.timeoutTime = options.timeoutTime ? options.timeoutTime : 60000 17 | this.emojiUsed = [] 18 | } 19 | 20 | //Start Game 21 | 22 | async start() { 23 | 24 | let buttons = createButtons(this.emojiUsed) 25 | 26 | let msg = await this.message.channel.send({ 27 | content: "Here's your board I will edit the buttons after 5 sec...", components: [ 28 | { 29 | type: 1, 30 | components: [ 31 | buttons[0], 32 | buttons[1], 33 | buttons[2] 34 | ] 35 | }, 36 | { 37 | type: 1, 38 | components: [ 39 | buttons[3], 40 | buttons[4], 41 | buttons[5], 42 | ] 43 | }, 44 | { 45 | type: 1, 46 | components: [ 47 | buttons[6], 48 | buttons[7], 49 | buttons[8] 50 | ] 51 | } 52 | ] 53 | }) 54 | 55 | 56 | setTimeout(async () => { 57 | await editButtons(msg, this.message, this.winMessage, this.loseMessage, this.timeOutMessage, this.emojiUsed) 58 | }, 5000) 59 | } 60 | } 61 | 62 | function createButtons(emojiUsed) { 63 | let buttons = [] 64 | 65 | for (let i = 0; i < 9; i++) { 66 | let emoji = random({ count: 1 }) 67 | emojiUsed.push(emoji) 68 | 69 | const button = new MessageButton() 70 | .setLabel(`${emoji}`) 71 | .setCustomId(`${emoji}`) 72 | .setStyle("PRIMARY") 73 | 74 | buttons.push(button) 75 | } 76 | 77 | return buttons; 78 | } 79 | 80 | async function editButtons(msg, message, winMessage, loseMessage, timeOutMessage, emojiUsed) { 81 | const buttons = [] 82 | 83 | msg.components.map(c => { 84 | c.components.map(c => { 85 | c.label = "~" 86 | 87 | buttons.push(c) 88 | }) 89 | }) 90 | 91 | let emoji = emojiUsed[Math.floor(Math.random() * emojiUsed.length)] 92 | 93 | emojiChoosen = emoji 94 | 95 | await msg.edit({ 96 | content: `Find \\${emoji} | Before the Time Runs Out`, components: [ 97 | { 98 | type: 1, 99 | components: [ 100 | buttons[0], 101 | buttons[1], 102 | buttons[2] 103 | ] 104 | }, 105 | { 106 | type: 1, 107 | components: [ 108 | buttons[3], 109 | buttons[4], 110 | buttons[5], 111 | ] 112 | }, 113 | { 114 | type: 1, 115 | components: [ 116 | buttons[6], 117 | buttons[7], 118 | buttons[8] 119 | ] 120 | } 121 | ] 122 | }) 123 | 124 | await handleGame(msg, message, winMessage, loseMessage, timeOutMessage) 125 | } 126 | 127 | async function handleGame(msg, message, winMessage, loseMessage, timeOutMessage) { 128 | 129 | const filter = i => { 130 | return i.user.id === message.author.id 131 | } 132 | 133 | msg.awaitMessageComponent({ filter, componentType: 'BUTTON', time: this.timeoutTime }) 134 | .then(interaction => { 135 | if (interaction.customId === `${emojiChoosen}`) { 136 | const buttons = [] 137 | 138 | msg.components.map(c => { 139 | c.components.map(c => { 140 | if (c.customId === interaction.customId && c.customId === `${emojiChoosen}`) { 141 | c.style = "SUCCESS" 142 | } 143 | 144 | c.label = c.customId 145 | 146 | buttons.push(c) 147 | }) 148 | }) 149 | 150 | msg.edit({ 151 | components: [ 152 | { 153 | type: 1, 154 | components: [ 155 | buttons[0], 156 | buttons[1], 157 | buttons[2] 158 | ] 159 | }, 160 | { 161 | type: 1, 162 | components: [ 163 | buttons[3], 164 | buttons[4], 165 | buttons[5], 166 | ] 167 | }, 168 | { 169 | type: 1, 170 | components: [ 171 | buttons[6], 172 | buttons[7], 173 | buttons[8] 174 | ] 175 | } 176 | ] 177 | }) 178 | 179 | interaction.reply(winMessage) 180 | } else { 181 | const buttons = [] 182 | 183 | msg.components.map(c => { 184 | c.components.map(c => { 185 | if (c.customId === interaction.customId) { 186 | c.style = "DANGER" 187 | } 188 | 189 | c.label = c.customId 190 | 191 | buttons.push(c) 192 | }) 193 | }) 194 | 195 | msg.edit({ 196 | components: [ 197 | { 198 | type: 1, 199 | components: [ 200 | buttons[0], 201 | buttons[1], 202 | buttons[2] 203 | ] 204 | }, 205 | { 206 | type: 1, 207 | components: [ 208 | buttons[3], 209 | buttons[4], 210 | buttons[5], 211 | ] 212 | }, 213 | { 214 | type: 1, 215 | components: [ 216 | buttons[6], 217 | buttons[7], 218 | buttons[8] 219 | ] 220 | } 221 | ] 222 | }) 223 | 224 | interaction.reply(loseMessage) 225 | } 226 | }) 227 | .catch(err => { 228 | msg.edit({ 229 | content: timeOutMessage, 230 | components: [] 231 | }) 232 | }) 233 | } 234 | 235 | 236 | module.exports = FindEmoji 237 | -------------------------------------------------------------------------------- /games/rps-game.js: -------------------------------------------------------------------------------- 1 | const { MessageEmbed, MessageButton, MessageActionRow } = require('discord.js') 2 | 3 | class RockPaperScissors { 4 | 5 | constructor(options) { 6 | 7 | if (!options.message) throw new TypeError('Missing argument: message') 8 | 9 | 10 | 11 | this.winMessage = options.Winmessage ? options.winMessage : "{winner} is the winner!" 12 | this.AI = options.AI ? options.AI : true 13 | this.message = options.message; 14 | this.opponent = options.opponent || this.message.mentions.members.first() 15 | this.embedColor = options.embedColor ? options.embedColor : "RANDOM" 16 | this.tieMessage = options.tieMessage ? options.tieMessage : "Its a tie." 17 | this.timeOutMessage = options.timeOutMessage ? options.timeOutMessage : "Times Up!" 18 | 19 | } 20 | 21 | async start() { 22 | let player1Choosed; 23 | let player2Choosed; 24 | let winner; 25 | 26 | let button1 = new MessageButton() 27 | .setLabel("🪨") 28 | .setCustomId("rock") 29 | .setStyle("PRIMARY") 30 | 31 | let button2 = new MessageButton() 32 | .setLabel("🧻") 33 | .setCustomId("paper") 34 | .setStyle("PRIMARY") 35 | 36 | let button3 = new MessageButton() 37 | .setLabel("✂️") 38 | .setCustomId("scissors") 39 | .setStyle("PRIMARY") 40 | 41 | const row = new MessageActionRow().addComponents(button1, button2, button3) 42 | 43 | if(!this.opponent && !this.AI) return this.message.channel.send("Mention the user you want to play with. ") 44 | 45 | 46 | if(!this.opponent && this.AI){ 47 | 48 | let msg = await this.message.channel.send({embeds: [{ 49 | title: `${this.message.author.username} V/S AI`, 50 | color: this.embedColor }], components: [row]}) 51 | 52 | 53 | let filter = i => {return i.user.id === this.message.author.id} 54 | 55 | msg.awaitMessageComponent({filter, componentType: "BUTTON" , time: 60000, max: 1, errors: ["time"]}).then(interaction => { 56 | let player1Choosed = interaction.customId 57 | 58 | let botChoosed = ["rock", "paper", "scissors"] 59 | 60 | player2Choosed = botChoosed[Math.floor(Math.random() * botChoosed.length)] 61 | 62 | if(player1Choosed === "rock" && player2Choosed === "scissors"){ 63 | winner = this.message.author.id 64 | } 65 | if(player1Choosed === "scissors" && player2Choosed === "paper"){ 66 | winner = this.message.author.id 67 | } 68 | if(player1Choosed === "paper" && player2Choosed === "rock"){ 69 | winner = this.message.author.id 70 | } 71 | if(player1Choosed === "paper" && player2Choosed === "scissors"){ 72 | winner = "AI" 73 | } 74 | if(player1Choosed === "scissors" && player2Choosed === "rock"){ 75 | winner = "AI" 76 | } 77 | if(player1Choosed === "rock" && player2Choosed === "paper"){ 78 | winner = "AI" 79 | } 80 | 81 | if(winner === "AI"){ 82 | interaction.reply(this.winMessage.replace("{winner}", "AI")) 83 | 84 | msg.edit({embeds: [{ 85 | title: `Your Answer: ${player1Choosed}\nAI: ${player2Choosed}\n\nWinner: AI`, 86 | color: this.embedColor 87 | }], 88 | components: []}) 89 | 90 | } else if(winner === this.message.author.id){ 91 | interaction.reply(this.winMessage.replace("{winner}", this.message.author.username)) 92 | 93 | msg.edit({embeds: [{ 94 | title: `Your Answer: ${player1Choosed}\nAI: ${player2Choosed}\n\nWinner: ${this.message.author.username}`, 95 | color: this.embedColor}], 96 | components: []}) 97 | 98 | } else { 99 | interaction.reply(this.tieMessage) 100 | 101 | msg.edit({embeds: [{ 102 | title: `Your Answer: ${player1Choosed}\nAI: ${player2Choosed}\n\nWinner: NoOne`, 103 | color: this.embedColor}], 104 | components: []}) 105 | } 106 | 107 | }).catch((e) => { 108 | this.message.channel.send(this.timeOutMessage) 109 | console.log(e) 110 | }) 111 | } else if(this.opponent){ 112 | 113 | let msg = await this.message.channel.send({embeds: [{ 114 | title: `${this.message.author.username} V/S ${this.opponent.user.username}`, 115 | color: this.embedColor }], components: [row]}) 116 | 117 | 118 | const collector = msg.createMessageComponentCollector({ componentType: 'BUTTON', time: 60000 }); 119 | 120 | collector.on('collect', i => { 121 | if (i.user.id === this.message.author.id || i.user.id === this.opponent.user.id) { 122 | 123 | if(i.user.id === this.message.author.id){ 124 | if(player1Choosed) return i.reply({content: "You have already chosen your answer.", ephemeral: true}) 125 | 126 | player1Choosed = i.customId 127 | i.reply({content: `You choosed ${i.customId} `, ephemeral: true}) 128 | } else { 129 | if(player2Choosed) return i.reply({content: "You have already chosen your answer.", ephemeral: true}) 130 | 131 | player2Choosed = i.customId 132 | i.reply({content: `You choosed ${i.customId}`, ephemeral: true}) 133 | } 134 | 135 | if(player1Choosed && player2Choosed){ 136 | if(player1Choosed === "rock" && player2Choosed === "scissors"){ 137 | winner = this.message.author.id 138 | } 139 | if(player1Choosed === "scissors" && player2Choosed === "paper"){ 140 | winner = this.message.author.id 141 | } 142 | if(player1Choosed === "paper" && player2Choosed === "rock"){ 143 | winner = this.message.author.id 144 | } 145 | if(player1Choosed === "paper" && player2Choosed === "scissors"){ 146 | winner = this.opponent.user.id 147 | } 148 | if(player1Choosed === "scissors" && player2Choosed === "rock"){ 149 | winner = this.opponent.user.id 150 | } 151 | if(player1Choosed === "rock" && player2Choosed === "paper"){ 152 | winner = this.opponent.user.id 153 | } 154 | 155 | if(winner === this.opponent.user.id){ 156 | this.message.reply(this.winMessage.replace("{winner}", this.opponent.user.username)) 157 | 158 | msg.edit({embeds: [{ 159 | title: `${this.message.author.username}'s Answer: ${player1Choosed}\n${this.opponent.user.username}'s Answer: ${player2Choosed}\n\nWinner: ${this.opponent.user.username}`, 160 | color: this.embedColor 161 | }], 162 | components: []}) 163 | 164 | } else if(winner === this.message.author.id){ 165 | this.message.reply(this.winMessage.replace("{winner}", this.message.author.username)) 166 | 167 | msg.edit({embeds: [{ 168 | title: `${this.message.author.username}'s Answer: ${player1Choosed}\n${this.opponent.user.username}'s Answer: ${player2Choosed}\n\nWinner: ${this.message.author.username}`, 169 | color: this.embedColor 170 | }], 171 | components: []}) 172 | 173 | } else { 174 | this.message.reply(this.tieMessage) 175 | 176 | msg.edit({embeds: [{ 177 | title: `${this.message.author.username}'s Answer: ${player1Choosed}\n${this.opponent.user.username}'s Answer: ${player2Choosed}\n\nWinner: NoOne`, 178 | color: this.embedColor 179 | }], 180 | components: []}) 181 | } 182 | } 183 | } else { 184 | i.reply({ content: `These buttons aren't for you!`, ephemeral: true }); 185 | } 186 | }); 187 | 188 | collector.on('end', collected => { 189 | msg.edit({embeds: [{ 190 | title: "Game Ended", 191 | color: this.embedColor 192 | }]}) 193 | }) 194 | 195 | } 196 | 197 | } 198 | } 199 | 200 | module.exports = RockPaperScissors 201 | -------------------------------------------------------------------------------- /games/hangman-game.js: -------------------------------------------------------------------------------- 1 | const { MessageEmbed } = require('discord.js'); 2 | 3 | const possible_themes = ['sport', 'coding', 'nature', 'popular game', 'phone brand', 'color', 'camping', 'music instrument'] 4 | 5 | const sport_theme = ['tennis', 'football', 'rugby', 'golf', 'hockey', 'badminton', 'boxing', 'cricket', 'karate', 'judo', 'baseball', 'basketball', 'dodgeball', 'cycling'] 6 | const coding_theme = ['javascript', 'html', 'css', 'python', 'typescript', 'sql', 'java', 'json', 'php'] 7 | const nature_theme = ['tree', 'forest', 'wildlife', 'river', 'island', 'hill', 'animal', 'plant', 'rock', 'waterfall', 'grass', 'flower', 'summer', 'sun', 'bush', 'jungle'] 8 | const games_theme = ['minecraft', 'grand theft auto', 'fortnite', 'counter strike', 'apex legends', 'rocket league', 'overwatch', 'roblox', 'call of duty', 'ark', 'among us', 'mario', 'star wars'] 9 | const phone_theme = ['samsung', 'iphone', 'oppo', 'huawei', 'nokia', 'xiaomi', 'vivo', 'lg', 'lenovo', 'oneplus', 'sony', 'asus'] 10 | const color_theme = ['red', 'blue', 'green', 'cyan', 'black', 'white', 'pink', 'purple', 'gray', 'brown', 'dark green', 'light green', 'dark blue', 'light blue', 'dark red', 'light red', 'magenta', 'gold', 'silver'] 11 | const camping_theme = ['marshmellow', 'barbeque', 'sticks', 'tent', 'campfire', 'camper', 'caravan', 'flashlight', 'fishing', 'insect', 'park', 'outdoors', 'walking', 'trip'] 12 | const music_theme = ['keyboard', 'piano', 'guitar', 'banjo', 'saxophone', 'clarinet', 'horn', 'pipes', 'drums', 'violin', 'flute', 'trumpet', 'harp', 'trumpet', 'voice'] 13 | 14 | const letterEmojisMap = { 15 | "🇦": "A", "🇧": "B", "🇨": "C", "🇩": "D", "🇪": "E", 16 | "🇫": "F", "🇬": "G", "🇭": "H", "🇮": "I", "🇯": "J", "🇰": "K", "🇱": "L", 17 | "🇲": "M", "🇳": "N", "🇴": "O", "🇵": "P", "🇶": "Q", "🇷": "R", "🇸": "S", 18 | "🇹": "T", "🇺": "U", "🇻": "V", "🇼": "W", "🇽": "X", "🇾": "Y", "🇿": "Z" 19 | } 20 | 21 | class HangMan { 22 | constructor(options) { 23 | if (!options.message) throw new TypeError('Missing argument: message') 24 | this.message = options.message; 25 | this.theme = options.theme || possible_themes[Math.floor(Math.random() * possible_themes.length)] 26 | this.embedColor = options.embedColor || 'RANDOM' 27 | this.hangManHat = options.hangManHat || '🎩' 28 | this.hangManHead = options.hangManHead || '😟' 29 | this.hangManShirt = options.hangManShirt || '👕' 30 | this.hangManPants = options.hangManPants || '🩳' 31 | this.hangManBoots = options.hangManBoots || '👞👞' 32 | 33 | 34 | } 35 | 36 | 37 | start = async () => { 38 | 39 | const theme = this.theme 40 | 41 | let words; 42 | if (theme === 'sport') words = sport_theme 43 | if (theme === 'coding') words = coding_theme 44 | if (theme === 'nature') words = nature_theme 45 | if (theme === 'popular game') words = games_theme 46 | if (theme === 'phone brand') words = phone_theme 47 | if (theme === 'color') words = color_theme 48 | if (theme === 'camping') words = camping_theme 49 | if (theme === 'music instrument') words = music_theme 50 | 51 | const word = words[Math.floor(Math.random() * words.length)] 52 | 53 | let guessed = []; 54 | let wrongs = 0; 55 | 56 | const embed = new MessageEmbed() 57 | .setColor(this.embedColor) 58 | .setTitle(`Hangman Game`) 59 | .setDescription("```" 60 | + "|‾‾‾‾‾‾| \n| " 61 | + (wrongs > 0 ? this.hangManHat : " ") 62 | + " \n| " 63 | + (wrongs > 1 ? this.hangManHead : " ") 64 | + " \n| " 65 | + (wrongs > 2 ? this.hangManShirt : " ") 66 | + " \n| " 67 | + (wrongs > 3 ? this.hangManPants : " ") 68 | + " \n| " 69 | + (wrongs > 4 ? this.hangManBoots : " ") 70 | + " \n| \n|__________\n\n" 71 | + word.split("").map(l => guessed.includes(l) ? l : "_").join(" ") 72 | + "```") 73 | .addField(`Letters Guessed`, '\u200b') 74 | .addField(`The theme is...`, `A ${theme}!`) 75 | .addField(`How to play?`, `React to this message with a letter emoji! Example: 🇦, 🇧`) 76 | const gameMessage = await this.message.channel.send({ embeds: [embed] }) 77 | 78 | const filter = (reaction, user) => ["🇦", "🇧", "🇨", "🇩", "🇪", "🇫", "🇬", "🇭", "🇮", "🇯", "🇰", "🇱", "🇲", "🇳", "🇴", "🇵", "🇶", "🇷", "🇸", "🇹", "🇺", "🇻", "🇼", "🇽", "🇾", "🇿"].includes(reaction.emoji.name) && user.id === this.message.author.id 79 | 80 | const gameCollector = gameMessage.createReactionCollector({ filter }); 81 | 82 | gameCollector.on("collect", async (reaction, user) => { 83 | 84 | if (user.id != this.message.author.id) { 85 | reaction.users.remove(user) 86 | return 87 | } 88 | reaction.message.reactions.cache.get(reaction.emoji.name).remove(); 89 | 90 | if (!guessed.includes(letterEmojisMap[reaction.emoji.name])) { 91 | 92 | guessed.push(letterEmojisMap[reaction.emoji.name]) 93 | 94 | if (word.toUpperCase().indexOf(letterEmojisMap[reaction.emoji.name]) == -1) { 95 | wrongs++ 96 | 97 | if (wrongs == 6) { 98 | 99 | gameCollector.stop() 100 | const stopEmbed = new MessageEmbed() 101 | .setColor(this.embedColor) 102 | .setTitle(`Hangman Game`) 103 | .setDescription("```" 104 | + "|‾‾‾‾‾‾| \n| " 105 | + (wrongs > 0 ? this.hangManHat : " ") 106 | + " \n| " 107 | + (wrongs > 1 ? this.hangManHead : " ") 108 | + " \n| " 109 | + (wrongs > 2 ? this.hangManShirt : " ") 110 | + " \n| " 111 | + (wrongs > 3 ? this.hangManPants : " ") 112 | + " \n| " 113 | + (wrongs > 4 ? this.hangManBoots : " ") 114 | + " \n| \n|__________\n\n" 115 | + word.toUpperCase().split("").map(l => guessed.includes(l) ? l : "_").join(" ") 116 | + "```") 117 | .addField(`Letters Guessed`, guessed.join(" ")) 118 | .addField(`The theme is...`, `A ${theme}!`) 119 | .addField(`How to play?`, `React to this message with a letter emoji! Example: 🇦, 🇧`) 120 | .addField(`Game Over`, `You lost this Hangman Game! The word was... **${word}**`) 121 | return gameMessage.edit({ embeds: [stopEmbed] }) 122 | } 123 | } else if (!word.toUpperCase().split("").map(l => guessed.includes(l) ? l : "_").includes("_")) { 124 | 125 | gameCollector.stop() 126 | const winEmbed = new MessageEmbed() 127 | .setColor(this.embedColor) 128 | .setTitle(`Hangman Game`) 129 | .setDescription("```" 130 | + "|‾‾‾‾‾‾| \n| " 131 | + (wrongs > 0 ? this.hangManHat : " ") 132 | + " \n| " 133 | + (wrongs > 1 ? this.hangManHead : " ") 134 | + " \n| " 135 | + (wrongs > 2 ? this.hangManShirt : " ") 136 | + " \n| " 137 | + (wrongs > 3 ? this.hangManPants : " ") 138 | + " \n| " 139 | + (wrongs > 4 ? this.hangManBoots : " ") 140 | + " \n| \n|__________\n\n" 141 | + word.toUpperCase().split("").map(l => guessed.includes(l) ? l : "_").join(" ") 142 | + "```") 143 | .addField(`Letters Guessed`, guessed.join(" ")) 144 | .addField(`The theme is...`, `A ${theme}!`) 145 | .addField(`How to play?`, `React to this message with a letter emoji! Example: 🇦, 🇧`) 146 | .addField(`Game Over`, `You won this Hangman Game! The word was... **${word}**`) 147 | return gameMessage.edit({ embeds: [winEmbed] }) 148 | } 149 | 150 | } 151 | 152 | const editEmbed = new MessageEmbed() 153 | .setColor(this.embedColor) 154 | .setTitle(`Hangman Game`) 155 | .setDescription("```" 156 | + "|‾‾‾‾‾‾| \n| " 157 | + (wrongs > 0 ? this.hangManHat : " ") 158 | + " \n| " 159 | + (wrongs > 1 ? this.hangManHead : " ") 160 | + " \n| " 161 | + (wrongs > 2 ? this.hangManShirt : " ") 162 | + " \n| " 163 | + (wrongs > 3 ? this.hangManPants : " ") 164 | + " \n| " 165 | + (wrongs > 4 ? this.hangManBoots : " ") 166 | + " \n| \n|__________\n\n" 167 | + word.toUpperCase().split("").map(l => guessed.includes(l) ? l : "_").join(" ") 168 | + "```") 169 | .addField(`Letters Guessed`, guessed.length == 0 ? '\u200b' : guessed.join(" ")) 170 | .addField(`The theme is...`, `A ${theme}!`) 171 | .addField(`How to play?`, `React to this message with a letter emoji! Example: 🇦, 🇧`) 172 | gameMessage.edit({ embeds: [editEmbed] }) 173 | 174 | }) 175 | } 176 | } 177 | 178 | module.exports = HangMan; -------------------------------------------------------------------------------- /games/connect4-game.js: -------------------------------------------------------------------------------- 1 | const discord = require('discord.js') 2 | 3 | class ConnectFour { 4 | 5 | constructor(options) { 6 | if (!options.message) throw new TypeError('Missing argument: message') 7 | this.gameEmbed = null 8 | this.message = options.message 9 | this.player1 = options.player1 || '🔴' 10 | this.player2 = options.player2 || '🟡' 11 | } 12 | 13 | start() { 14 | 15 | const challenger = this.message.author; 16 | const oppenent = this.message.mentions.users.first(); 17 | 18 | if (!oppenent) return this.message.channel.send(`**Who do you wanna play Connect Four with?(Mention the person with the command.**`) 19 | 20 | const board = [ 21 | ["⚪", "⚪", "⚪", "⚪", "⚪", "⚪", "⚪"], 22 | ["⚪", "⚪", "⚪", "⚪", "⚪", "⚪", "⚪"], 23 | ["⚪", "⚪", "⚪", "⚪", "⚪", "⚪", "⚪"], 24 | ["⚪", "⚪", "⚪", "⚪", "⚪", "⚪", "⚪"], 25 | ["⚪", "⚪", "⚪", "⚪", "⚪", "⚪", "⚪"], 26 | ["⚪", "⚪", "⚪", "⚪", "⚪", "⚪", "⚪"], 27 | ]; 28 | 29 | const renderBoard = (board) => { 30 | let tempString = ""; 31 | for (const boardSection of board) { 32 | tempString += `${boardSection.join("")}\n`; 33 | } 34 | 35 | tempString = tempString.concat("1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣"); 36 | return tempString; 37 | } 38 | 39 | const initialState = renderBoard(board); 40 | 41 | const initial = new discord.MessageEmbed() 42 | .setTitle(`${this.player1} It's your turn, ${this.message.author.username}!`) 43 | .setDescription(initialState) 44 | .setFooter(`${challenger.username} vs ${oppenent.username}`) 45 | this.message.channel.send({ embeds: [initial] }).then(gameMessage => { 46 | 47 | gameMessage.react("1️⃣") 48 | gameMessage.react("2️⃣") 49 | gameMessage.react("3️⃣") 50 | gameMessage.react("4️⃣") 51 | gameMessage.react("5️⃣") 52 | gameMessage.react("6️⃣") 53 | gameMessage.react("7️⃣") 54 | 55 | const gameFilter = (reaction, user) => ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣"].includes(reaction.emoji.name) && (user.id === oppenent.id || user.id === challenger.id); 56 | 57 | const gameCollector = gameMessage.createReactionCollector({ filter: gameFilter }); 58 | 59 | const gameData = [ 60 | { member: challenger, playerColor: this.player1 }, 61 | { member: oppenent, playerColor: this.player2 } 62 | ] 63 | 64 | let player = 0; 65 | 66 | const checkFour = (a, b, c, d) => (a === b) && (b === c) && (c === d) && (a !== "⚪"); 67 | 68 | const horizontalCheck = () => { 69 | 70 | for (let i = 0; i < 6; i++) { 71 | 72 | for (let j = 0; j < 4; j++) { 73 | if (checkFour(board[i][j], board[i][j + 1], board[i][j + 2], board[i][j + 3])) return [ 74 | board[i][j], board[i][j + 1], board[i][j + 2], board[i][j + 3] 75 | ]; 76 | } 77 | } 78 | } 79 | 80 | const verticalCheck = () => { 81 | for (let j = 0; j < 7; j++) { 82 | for (let i = 0; i < 3; i++) { 83 | 84 | if (checkFour(board[i][j], board[i + 1][j], board[i + 2][j], board[i + 3][j])) return [ 85 | board[i][j], board[i + 1][j], board[i + 2][j], board[i + 3][j] 86 | ] 87 | } 88 | } 89 | } 90 | 91 | const diagonal1 = () => { 92 | for (let col = 0; col < 4; col++) { 93 | for (let row = 0; row < 3; row++) { 94 | if (checkFour(board[row][col], board[row + 1][col + 1], board[row + 2][col + 2], board[row + 3][col + 3])) return [ 95 | board[row][col], board[row + 1][col + 1], board[row + 2][col + 2], board[row + 3][col + 3] 96 | ] 97 | } 98 | } 99 | } 100 | 101 | const diagonal2 = () => { 102 | for (let col = 0; col < 4; col++) { 103 | for (let row = 5; row > 2; row--) { 104 | if (checkFour(board[row][col], board[row - 1][col + 1], board[row - 2][col + 2], board[row - 3][col + 3])) return [ 105 | board[row][col], board[row - 1][col + 1], board[row - 2][col + 2], board[row - 3][col + 3] 106 | ] 107 | } 108 | } 109 | } 110 | 111 | const tieCheck = () => { 112 | let count = 0; 113 | for (const el of board) { 114 | for (const string of el) { 115 | if (string !== "⚪") count++; 116 | } 117 | } 118 | if (count === 42) return true; 119 | else return false; 120 | } 121 | 122 | const checks = [horizontalCheck, verticalCheck, diagonal1, diagonal2]; 123 | 124 | gameCollector.on("collect", (reaction, user) => { 125 | 126 | reaction.message.reactions.cache.get(reaction.emoji.name).users.remove(user.id); 127 | 128 | if (user.id === gameData[player].member.id) { 129 | 130 | const openSpaces = []; 131 | 132 | switch (reaction.emoji.name) { 133 | case "1️⃣": 134 | for (let i = 5; i > -1; i--) { 135 | if (board[i][0] === "⚪") openSpaces.push({ i, j: 0 }); 136 | } 137 | if (openSpaces.length == 0) return this.message.channel.send(`**${gameData[player].member}, that column is already full. Choose another one**`).then(msg1 => msg1.delete({ timeout: 10000 })) 138 | else board[openSpaces[0].i][openSpaces[0].j] = gameData[player].playerColor; 139 | break; 140 | case "2️⃣": 141 | for (let i = 5; i > -1; i--) { 142 | if (board[i][1] === "⚪") openSpaces.push({ i, j: 1 }); 143 | } 144 | if (openSpaces.length == 0) return this.message.channel.send(`**${gameData[player].member}, that column is already full. Choose another one**`).then(msg1 => msg1.delete({ timeout: 10000 })) 145 | else board[openSpaces[0].i][openSpaces[0].j] = gameData[player].playerColor; 146 | break; 147 | case "3️⃣": 148 | for (let i = 5; i > -1; i--) { 149 | if (board[i][2] === "⚪") openSpaces.push({ i, j: 2 }); 150 | } 151 | if (openSpaces.length == 0) return this.message.channel.send(`**${gameData[player].member}, that column is already full. Choose another one**`).then(msg1 => msg1.delete({ timeout: 10000 })) 152 | else board[openSpaces[0].i][openSpaces[0].j] = gameData[player].playerColor; 153 | break; 154 | case "4️⃣": 155 | for (let i = 5; i > -1; i--) { 156 | if (board[i][3] === "⚪") openSpaces.push({ i, j: 3 }); 157 | } 158 | if (openSpaces.length == 0) return this.message.channel.send(`**${gameData[player].member}, that column is already full. Choose another one**`).then(msg1 => msg1.delete({ timeout: 10000 })) 159 | else board[openSpaces[0].i][openSpaces[0].j] = gameData[player].playerColor; 160 | break; 161 | case "5️⃣": 162 | for (let i = 5; i > -1; i--) { 163 | if (board[i][4] === "⚪") openSpaces.push({ i, j: 4 }); 164 | } 165 | if (openSpaces.length == 0) return this.message.channel.send(`**${gameData[player].member}, that column is already full. Choose another one**`).then(msg1 => msg1.delete({ timeout: 10000 })) 166 | else board[openSpaces[0].i][openSpaces[0].j] = gameData[player].playerColor; 167 | break; 168 | case "6️⃣": 169 | for (let i = 5; i > -1; i--) { 170 | if (board[i][5] === "⚪") openSpaces.push({ i, j: 5 }); 171 | } 172 | if (openSpaces.length == 0) return this.message.channel.send(`**${gameData[player].member}, that column is already full. Choose another one**`).then(msg1 => msg1.delete({ timeout: 10000 })) 173 | else board[openSpaces[0].i][openSpaces[0].j] = gameData[player].playerColor; 174 | break; 175 | case "7️⃣": 176 | for (let i = 5; i > -1; i--) { 177 | if (board[i][6] === "⚪") openSpaces.push({ i, j: 6 }); 178 | } 179 | if (openSpaces.length == 0) return this.message.channel.send(`**${gameData[player].member}, that column is already full. Choose another one**`).then(msg1 => msg1.delete({ timeout: 10000 })) 180 | else board[openSpaces[0].i][openSpaces[0].j] = gameData[player].playerColor; 181 | break; 182 | } 183 | 184 | if (tieCheck()) { 185 | gameMessage.reactions.removeAll() 186 | const TieEmbed = new discord.MessageEmbed() 187 | .setTitle(`The game ended, it is a Tie!`) 188 | .setDescription(renderBoard(board)) 189 | .setFooter(`${challenger.username} vs ${oppenent.username}`) 190 | gameCollector.stop("Tie Game") 191 | return gameMessage.edit({ embeds: [TieEmbed] }) 192 | } 193 | 194 | for (const func of checks) { 195 | 196 | const data = func(); 197 | if (data) { 198 | gameMessage.reactions.removeAll() 199 | 200 | const WinEmbed = new discord.MessageEmbed() 201 | .setTitle(`${gameData[player].member.username} has won the game!`) 202 | .setDescription(renderBoard(board)) 203 | .setFooter(`${challenger.username} vs ${oppenent.username}`) 204 | gameCollector.stop(`${gameData[player].member.id} won`); 205 | return gameMessage.edit({ embeds: [WinEmbed] }) 206 | } 207 | } 208 | 209 | player = (player + 1) % 2; 210 | 211 | const newEmbed = new discord.MessageEmbed() 212 | .setTitle(`${gameData[player].playerColor} - It's your turn, ${gameData[player].member.username}!`) 213 | .setDescription(renderBoard(board)) 214 | .setFooter(`${challenger.username} vs ${oppenent.username}`) 215 | gameMessage.edit({ embeds: [newEmbed] }); 216 | } 217 | }) 218 | }) 219 | } 220 | } 221 | 222 | module.exports = ConnectFour; 223 | -------------------------------------------------------------------------------- /games/snake-game.js: -------------------------------------------------------------------------------- 1 | const { MessageEmbed, MessageButton, MessageActionRow } = require('discord.js'); 2 | 3 | 4 | const WIDTH = 10; 5 | const HEIGHT = 8; 6 | const gameBoard = []; 7 | const apple = { x: 1, y: 1 }; 8 | 9 | class SnakeGame { 10 | 11 | constructor(options) { 12 | 13 | for (let y = 0; y < HEIGHT; y++) { 14 | for (let x = 0; x < WIDTH; x++) { 15 | gameBoard[y * WIDTH + x] = "⬜"; 16 | } 17 | } 18 | 19 | if (!options.message) throw new TypeError('Missing argument: message') 20 | 21 | this.message = options.message; 22 | this.buttons = options.buttons || false; 23 | this.snake = options.snake || "🟩"; 24 | this.apple = options.apple || "🍎"; 25 | this.embedColor = options.embedColor || '#0099ff'; 26 | this.leftButton = options.leftButton || '⬅';; 27 | this.rightButton = options.rightButton || '➡'; 28 | this.upButton = options.upButton || '⬆️'; 29 | this.downButton = options.downButton || '⬇'; 30 | 31 | } 32 | 33 | start() { 34 | if (!this.buttons) { 35 | 36 | let snake = [{ x: 5, y: 5 }] 37 | let snakeLength = 1; 38 | let score = 0; 39 | 40 | const gameBoardTostring = () => { 41 | 42 | 43 | let str = "" 44 | for (let y = 0; y < HEIGHT; y++) { 45 | for (let x = 0; x < WIDTH; x++) { 46 | if (x == apple.x && y == apple.y) { 47 | str += this.apple; 48 | continue; 49 | } 50 | 51 | let flag = true; 52 | for (let s = 0; s < snake.length; s++) { 53 | if (x == snake[s].x && y == snake[s].y) { 54 | str += this.snake; 55 | flag = false; 56 | } 57 | } 58 | 59 | if (flag) 60 | str += gameBoard[y * WIDTH + x]; 61 | } 62 | str += "\n"; 63 | } 64 | return str; 65 | 66 | } 67 | 68 | const isLocInSnake = (pos) => { 69 | return snake.find(sPos => sPos.x == pos.x && sPos.y == pos.y) 70 | } 71 | 72 | const newAppleLoc = () => { 73 | 74 | let newApplePos = { x: 0, y: 0 }; 75 | 76 | if (isLocInSnake(newApplePos)) newApplePos = { x: parseInt(Math.random() * WIDTH), y: parseInt(Math.random() * HEIGHT) }; 77 | 78 | apple.x = newApplePos.x; 79 | apple.y = newApplePos.y; 80 | 81 | } 82 | 83 | const embed = new MessageEmbed() 84 | .setColor(this.embedColor) 85 | .setTitle(`Snake Game - ${this.message.author.username}`) 86 | .setDescription(gameBoardTostring()) 87 | .setTimestamp(); 88 | 89 | this.message.channel.send({ embeds: [embed] }).then(gameMessage => { 90 | gameMessage.react('⬅️'); 91 | gameMessage.react('⬆️'); 92 | gameMessage.react('⬇️'); 93 | gameMessage.react('➡️'); 94 | 95 | const waitForReaction = () => { 96 | 97 | const filter = (reaction, user) => ["⬅️", "⬆️", "⬇️", "➡️"].includes(reaction.emoji.name) && (user.id === this.message.author.id); 98 | 99 | gameMessage.awaitReactions({ filter: filter, max: 1, time: 60000, errors: ['time'] }) 100 | .then(collected => { 101 | const reaction = collected.first() 102 | 103 | const snakeHead = snake[0] 104 | const nextPos = { x: snakeHead.x, y: snakeHead.y }; 105 | 106 | if (reaction.emoji.name === '⬅️') { 107 | let nextX = snakeHead.x - 1; 108 | if (nextX < 0) 109 | nextX = WIDTH - 1; 110 | nextPos.x = nextX; 111 | } 112 | else if (reaction.emoji.name === '⬆️') { 113 | let nextY = snakeHead.y - 1; 114 | if (nextY < 0) 115 | nextY = HEIGHT - 1; 116 | nextPos.y = nextY; 117 | } 118 | else if (reaction.emoji.name === '⬇️') { 119 | let nextY = snakeHead.y + 1; 120 | if (nextY >= HEIGHT) 121 | nextY = 0; 122 | nextPos.y = nextY; 123 | } 124 | else if (reaction.emoji.name === '➡️') { 125 | let nextX = snakeHead.x + 1; 126 | if (nextX >= WIDTH) 127 | nextX = 0; 128 | nextPos.x = nextX; 129 | } 130 | 131 | reaction.users.remove(reaction.users.cache.filter(user => user.id !== gameMessage.author.id).first().id).then(() => { 132 | if (isLocInSnake(nextPos)) { 133 | gameOver() 134 | } 135 | else { 136 | snake.unshift(nextPos); 137 | if (snake.length > snakeLength) 138 | snake.pop(); 139 | 140 | step(); 141 | } 142 | }); 143 | }) 144 | .catch(collected => { 145 | gameMessage.reactions.removeAll() 146 | 147 | const editEmbed = new MessageEmbed() 148 | .setColor(this.embedColor) 149 | .setTitle(`Game Over - ${this.message.author.username}`) 150 | .setDescription(`**You didn't react for a while!**\n**Total Apples Grabbed: **${score}`) 151 | .setTimestamp() 152 | gameMessage.edit({ embeds: [editEmbed] }) 153 | }); 154 | } 155 | 156 | waitForReaction() 157 | 158 | const step = () => { 159 | 160 | if (apple.x == snake[0].x && apple.y == snake[0].y) { 161 | score += 1; 162 | snakeLength++; 163 | newAppleLoc(); 164 | } 165 | 166 | const editEmbed = new MessageEmbed() 167 | .setColor(this.embedColor) 168 | .setTitle(`Snake Game - ${this.message.author.username}`) 169 | .setDescription(gameBoardTostring()) 170 | .setTimestamp(); 171 | gameMessage.edit({ embeds: [editEmbed] }) 172 | 173 | waitForReaction() 174 | } 175 | 176 | const gameOver = () => { 177 | 178 | const editEmbed = new MessageEmbed() 179 | .setColor(this.embedColor) 180 | .setTitle(`Game Over - ${this.message.author.username}`) 181 | .setDescription(`**Total Apples Grabbed: **${score}`) 182 | .setTimestamp() 183 | gameMessage.edit({ embeds: [editEmbed] }) 184 | 185 | gameMessage.reactions.removeAll() 186 | } 187 | }); 188 | } else { 189 | 190 | let snake = [{ x: 5, y: 5 }] 191 | let snakeLength = 1; 192 | let score = 0; 193 | 194 | const gameBoardTostring = () => { 195 | 196 | 197 | let str = "" 198 | for (let y = 0; y < HEIGHT; y++) { 199 | for (let x = 0; x < WIDTH; x++) { 200 | if (x == apple.x && y == apple.y) { 201 | str += this.apple; 202 | continue; 203 | } 204 | 205 | let flag = true; 206 | for (let s = 0; s < snake.length; s++) { 207 | if (x == snake[s].x && y == snake[s].y) { 208 | str += this.snake; 209 | flag = false; 210 | } 211 | } 212 | 213 | if (flag) 214 | str += gameBoard[y * WIDTH + x]; 215 | } 216 | str += "\n"; 217 | } 218 | return str; 219 | 220 | } 221 | 222 | const isLocInSnake = (pos) => { 223 | return snake.find(sPos => sPos.x == pos.x && sPos.y == pos.y) 224 | } 225 | 226 | const newAppleLoc = () => { 227 | 228 | let newApplePos = { x: 0, y: 0 }; 229 | 230 | if (isLocInSnake(newApplePos)) newApplePos = { x: parseInt(Math.random() * WIDTH), y: parseInt(Math.random() * HEIGHT) }; 231 | 232 | apple.x = newApplePos.x; 233 | apple.y = newApplePos.y; 234 | 235 | } 236 | 237 | const embed = new MessageEmbed() 238 | .setColor(this.embedColor) 239 | .setTitle(`Snake Game - ${this.message.author.username}`) 240 | .setDescription(gameBoardTostring()) 241 | .setTimestamp(); 242 | 243 | const row1 = new MessageActionRow() 244 | .addComponents(new MessageButton() 245 | .setStyle('SECONDARY') 246 | .setLabel(`\u200b`) 247 | .setCustomId('extra1') 248 | .setDisabled(true), 249 | 250 | ) 251 | .addComponents(new MessageButton() 252 | .setStyle('PRIMARY') 253 | .setCustomId('up') 254 | .setEmoji(this.upButton) 255 | 256 | ) 257 | .addComponents(new MessageButton() 258 | .setStyle('SECONDARY') 259 | .setLabel(`\u200b`) 260 | .setCustomId('extra2') 261 | .setDisabled(true), 262 | ) 263 | 264 | const row2 = new MessageActionRow() 265 | .addComponents(new MessageButton() 266 | .setStyle('PRIMARY') 267 | .setEmoji(this.leftButton) 268 | .setCustomId('left'), 269 | 270 | 271 | ) 272 | .addComponents(new MessageButton() 273 | .setStyle('PRIMARY') 274 | .setCustomId('down') 275 | .setEmoji(this.downButton) 276 | 277 | ) 278 | .addComponents(new MessageButton() 279 | .setStyle('PRIMARY') 280 | .setCustomId('right') 281 | .setEmoji(this.rightButton) 282 | 283 | ) 284 | 285 | 286 | this.message.channel.send({ embeds: [embed], components: [row1, row2] }).then(gameMessage => { 287 | 288 | 289 | const waitForReaction = () => { 290 | 291 | const filter = i => { 292 | return i.user.id === this.message.author.id; 293 | }; 294 | 295 | gameMessage.awaitMessageComponent({ filter, componentType: 'BUTTON', max: 1, time: 60000, errors: ['time'] }) 296 | .then(interaction => { 297 | 298 | const button = interaction 299 | const snakeHead = snake[0] 300 | const nextPos = { x: snakeHead.x, y: snakeHead.y }; 301 | 302 | if (button.customId === 'left') { 303 | button.deferUpdate(); 304 | let nextX = snakeHead.x - 1; 305 | if (nextX < 0) 306 | nextX = WIDTH - 1; 307 | nextPos.x = nextX; 308 | } 309 | else if (button.customId === 'up') { 310 | button.deferUpdate(); 311 | let nextY = snakeHead.y - 1; 312 | if (nextY < 0) 313 | nextY = HEIGHT - 1; 314 | nextPos.y = nextY; 315 | } 316 | else if (button.customId === 'down') { 317 | button.deferUpdate(); 318 | let nextY = snakeHead.y + 1; 319 | if (nextY >= HEIGHT) 320 | nextY = 0; 321 | nextPos.y = nextY; 322 | } 323 | else if (button.customId === 'right') { 324 | button.deferUpdate(); 325 | let nextX = snakeHead.x + 1; 326 | if (nextX >= WIDTH) 327 | nextX = 0; 328 | nextPos.x = nextX; 329 | } 330 | 331 | 332 | if (isLocInSnake(nextPos)) { 333 | gameOver() 334 | } 335 | else { 336 | snake.unshift(nextPos); 337 | if (snake.length > snakeLength) 338 | snake.pop(); 339 | 340 | step(); 341 | } 342 | 343 | }) 344 | .catch(collected => { 345 | 346 | const editEmbed = new MessageEmbed() 347 | .setColor(this.embedColor) 348 | .setTitle(`Game Over - ${this.message.author.username}`) 349 | .setDescription(`**You didn't react for a while!**\n**Total Apples Grabbed: **${score}`) 350 | .setTimestamp() 351 | gameMessage.edit({ embeds: [editEmbed], components: [] }) 352 | }); 353 | } 354 | 355 | waitForReaction() 356 | 357 | const step = () => { 358 | 359 | if (apple.x == snake[0].x && apple.y == snake[0].y) { 360 | score += 1; 361 | snakeLength++; 362 | newAppleLoc(); 363 | } 364 | 365 | const editEmbed = new MessageEmbed() 366 | .setColor(this.embedColor) 367 | .setTitle(`Snake Game - ${this.message.author.username}`) 368 | .setDescription(gameBoardTostring()) 369 | .setTimestamp(); 370 | gameMessage.edit({ embeds: [editEmbed], components: [row1, row2] }) 371 | 372 | waitForReaction() 373 | } 374 | 375 | const gameOver = () => { 376 | 377 | const editEmbed = new MessageEmbed() 378 | .setColor(this.embedColor) 379 | .setTitle(`Game Over - ${this.message.author.username}`) 380 | .setDescription(`**Total Apples Grabbed: **${score}`) 381 | .setTimestamp() 382 | gameMessage.edit({ embeds: [editEmbed], components: [] }) 383 | 384 | 385 | } 386 | }); 387 | } 388 | } 389 | } 390 | 391 | module.exports = SnakeGame; 392 | -------------------------------------------------------------------------------- /games/fasttyper-game.js: -------------------------------------------------------------------------------- 1 | const discord = require('discord.js') 2 | 3 | const possible_words = ["medicine", "situation", "hall", "desk", "hotel", "president", "thought", "method", "village", "user", "blood", "math", "highway", "agency", "intention", "marriage", "poet", "student", "pollution", "office", "insurance", "person", "health", "session", "warning", "attitude", "analysis", "trainer", "paper", "attention", "currency", "chocolate", "depth", "dealer", "dinner", "night", "drawer", "tennis", "singer", "virus", "college", "oven", "uncle", "arrival", "recording", "sector", "flight", "emotion", "meaning", "moment", "elevator", "lab", "teaching", "ad", "sister", "artisan", "memory", "studio", "goal", "currency", "employer", "camera", "marketing", "quantity", "clothes", "tale", "leader", "solution", "cousin", "republic", "signature", "idea", "moment", "basket", "homework", "hospital", "direction", "potato", "death", "scene", "committee", "version", "childhood", "manager", "menu", "mud", "people", "love", "king", "drawing", "housing", "hearing", "insect", "lake", "gate", "category", "theory", "movie", "inflation", "media", "arrival", "week", "outcome", "health", "recipe", "payment", "oven", "inspector", "intention", "song", "apartment", "dirt", "food", "medicine", "growth", "funeral", "concept", "throat", "reality", "mud", "awareness", "sister", "context", "cancer", "actor", "bread", "basis", "reading", "college", "climate", "theory", "industry", "idea", "volume", "region", "hearing", "security", "clothes", "director", "data", "opinion", "confusion", "camera", "sympathy", "signature", "complaint", "message", "wealth", "drawing", "secretary", "wing", "uppity", "shallow", "wrist", "body", "develop", "ground", "snails", "squealing", "drug", "army", "sad", "cherries", "rabbit", "rock", "helpless", "flowers", "cows", "ready", "zany", "yellow", "save", "listen", "accidental", "tacky", "horrible", "flagrant", "nervous", "flock", "bear", "cure", "bag", "mom", "cup", "wed", "letter", "eggs", "illumine", "sheet", "dusty", "frogs", "aboard", "bed", "reply", "receipt", "grandiose", "shrill", "new", "dump", "painstaking", "journey", "month", "passenger", "scam", "tree", "determine", "town", "hinder", "book", "mammoth", "shun", "resemble", "face", "toys", "card", "act", "zonked", "ill", "foretell", "tame", "encouraging", "action", "possessive", "imperfect", "angle", "determined", "present", "contract", "waggish", "lazy", "produce", "mute", "spectacular", "restrain", "time", "horn", "thought", "special", "physical", "boil", "lock", "accurate", "bridge", "confuse", "fiction", "airplane", "placid", "team", "serious", "dependent", "crave", "girl", "burn", "blow", "separate", "person", "cower", "vomit", "run", "stretch", "handy", "efficient", "stitch", "hoax", "blush", "net", "far", "fax", "boy", "doctor", "cellar", "knotty", "compare", "view", "sew", "madly", "chubby", "damp", "touch", "numberless", "halting", "innocent", "glance", "insure", "cup", "crack", "mature", "instrument", "google", "engine", "damage", "burst", "rampant", "describe", "observant", "exchange", "penitent", "intelligent", "install", "courageous", "terrible", "agreeable", "system", "inspire", "pretty", "book", "bell", "teach", "step", "rend", "curve", "squealing", "act", "dispensable", "ants", "gabby", "jar", "pollute", "hair", "request", "omit", "conduct", "afterthought", "axiomatic", "earthquake", "convey", "fall", "irritating", "peep", "fortunate", "capture", "sever", "burn", "egg", "dusty", "aromatic", "stranger", "self", "compete", "busy", "sack", "vase", "conduct", "overtake", "colour", "appliance", "shut", "base", "history", "rot", "uptight", "contest", "clever", "dwell", "quince", "lunchroom", "carpenter", "animate", "fallacious", "evaporate", "mean", "present", "fertile", "painful", "window", "knotty", "complain", "willing", "spy", "bind", "stupendous", "nourish", "thinkable", "satisfying", "feigned", "superb", "makeshift", "ducks", "show", "warlike", "let", "brave", "convert", "resolute", "innovate", "irate", "limping", "omniscient", "conclude", "thing", "mind", "snakes", "finger", "whole", "brave", "existence", "bird", "obstruct", "snobbish", "acquire", "certain", "rough", "pay", "star", "squirrel", "sash", "alluring", "efficacious", "snobbish", "fierce", "lavish", "naughty", "crime", "insidious", "entertaining", "threatening", "tense", "abash", "nimble", "wiry", "disobey", "walk", "dwell", "greedy", "drop", "give", "parcel", "secret", "expect", "inscribe", "want", "hunt", "purring", "pastoral", "taste", "exchange", "dry", "many", "see", "sew", "laugh", "condition", "violate", "psychedelic", "pathetic", "fair", "cover", "cling", "greet", "pump", "boys", "sulky", "quickest", "hanging", "mammoth", "glance", "alarm", "engine", "grandiose", "guarded", "prohibit", "invite", "vigorous", "split", "agreeable", "modify", "nasty", "trousers", "sail", "defective", "shame", "", "pest", "friendly", "tap", "stimulating", "apply", "disuse", "education", "collect", "apply", "infamous", "chide", "grade", "fantastic", "educat", "touch", "carve", "conserve", "join", "appear", "quilt", "silly", "rewind", "smell", "ordinary", "historical", "wring", "frame", "lumpy", "powerful", "leap", "crowd", "ducks", "husky", "amazing", "invite", "thirsty", "fretful", "undesirable", "month", "racial", "marble", "erase", "love", "nutritious", "implant", "renounce", "shocking", "awake", "participate", "harsh", "satirise", "carry", "bored", "fortunate", "display", "light", "wilderness", "tacit", "distance", "enter", "inject", "comment", "rain", "type", "adamant", "steam", "taste", "mice", "grind", "sweltering", "debonair", "song", "fight", "idealize", "boil", "consort", "note", "grubby", "awesome", "ooze", "puzzling", "purify", "convict", "lyrical", "resolute", "tender", "imaginary", "catch", "chunky", "watch", "see", "climb", "behold", "spurious", "leg", "taboo", "overwrought", "furry", "tax", "amazing", "straight", "month", "review", "door", "obscene", "outstanding", "find", "ambitious", "distance", "next", "match", "wet", "blush", "berserk", "come", "super", "nutty", "urge", "snap", "tender", "verify", "airport", "nervous", "shed", "cave", "dwell", "dead", "boast", "territory", "fine", "love", "trade", "fragile", "station", "impose", "cough", "nappy", "shout", "colour", "change", "nifty", "vengeful", "scientific", "heat", "inflame", "giants", "toy", "imbibe", "women", "crack", "idea", "scale", "observation", "stereotyped", "shelf", "obsequious", "shock", "chin", "banish", "convey", "signify", "curve", "stingy", "jumbled", "stew", "corn", "instrument", "sew", "propose", "smite", "ruthless", "weep", "assert", "test", "shake", "knee", "burly", "head", "slam", "misty", "cattle", "goofy", "astonish", "cherry", "copper", "feet", "class", "prose", "perpetual", "common", "rewind", "place", "skillful", "sort", "join", "reduce", "country", "overflow", "placid", "respect", "clammy", "jewel", "milk", "park", "self", "smash", "die", "toy", "bloody", "romantic", "implode", "add", "change", "transfer", "fairies", "vast", "week", "sloppy", "transport", "pour", "protest", "boundary", "dispose", "degree", "inspire", "scabble", "highfalutin", "makeshift", "shut", "butter", "fail", "available", "behold", "bustling", "smash", "waste", "saunter", "poised", "yarn", "cower", "stink", "weak", "humor", "sharp", "relax", "spotty", "true", "closed", "jam", "ship", "damp", "nifty", "dock", "cast", "hydrant", "state", "thing", "gleaming", "bite", "invention", "left", "eager", "vex", "hurt", "imagine", "gamy", "zinc", "scam", "camera", "cracker", "bright", "teeny", "riddle", "acid", "choose", "man", "swell", "charge", "recast", "inflame", "living", "spiky", "man", "brush", "gainsay", "blow", "migrate", "sink", "terrify", "destroy", "normal", "steadfast", "insurance", "loving", "changeable", "pencil", "beautify", "compete", "pen", "roar", "marry", "glamorous", "rampant", "tree", "powerful", "love", "print", "macho", "implant", "example", "creepy", "vast", "death", "alert", "gullible", "scab", "delay", "jelly", "shake", "open", "dock", "rule", "robust", "corrod", "farmer", "faint", "jobless", "selection", "beg", "guide", "large", "police", "future", "vulgar", "complain", "color", "damaging", "blood", "oppress", "sulky", "lawyer", "wren", "sleep", "grade", "nimble", "direful", "cute", "exist", "chairs", "push", "discreet", "vex", "curtain", "counsel", "holiday", "discover", "limit", "measly", "love", "observe", "omit", "alcoholic", "wash", "meet", "far", "pencil", "redundant", "organic", "gamy", "tough", "warn", "linen", "beast", "fall", "expensive", "cannon", "kill", "flower", "illegal", "town", "functional", "whispering", "right", "relax", "quick", "detect", "mellow", "sassy", "lovely", "quince", "table", "guard", "ring", "tidy", "place", "cheap", "disgust", "quill", "unused", "decorous", "station", "purring", "store", "dapper", "separate", "trail", "push", "cause", "ready", "forbid", "relax", "legs", "rise", "save", "return", "stitch", "quartz", "brush", "female", "run", "flop", "grandmother", "healthy", "spring", "grain", "difficult", "incise", "fight", "abject", "voracious", "dapper", "sound", "pest", "greet", "writer", "enlighten", "store", "bet", "lyrical", "reuse", "ignore", "melt", "week", "relate", "curvy", "silent", "heavenly", "leather", "gabby", "endorse", "abrasive", "read", "son", "club", "coil", "bash", "godly", "ragged", "mould", "promise", "bait", "gainsay", "book", "dash", "clumsy", "gain", "disagreeable", "chat", "lacking", "scab", "shaggy", "resolve", "telling", "renew", "roar", "learning", "reduce", "piquant", "scale", "creator", "tart", "happy", "learned", "measure", "correct", "crush", "cope", "art", "country", "thump", "contrive", "elegant", "mailbox", "symptomatic", "scant", "letter", "lick", "conquer", "suppose", "exclude", "female", "bustling", "show", "needy", "beautiful", "representative", "imperil", "learning", "growth", "bashful", "kid", "carry", "retain", "set", "careless", "frantic", "touch", "wave", "dwell", "leap", "agree", "ball", "pardon", "beggar", "frame", "soda", "scared", "swim", "statement", "contribute", "dynamic", "fallacious", "install", "tiresome", "beseech", "abate", "fallacious", "bray", "cable", "cost", "foot", "chicken", "balloon", "sidewalk", "classify", "tough", "sheep", "bit", "tender", "beneficial", "flippant", "attractive", "magnificent", "pricey", "illegal", "fierce", "stitch", "like", "suffer", "break", "feast", "hill", "mammoth", "spotted", "wise", "stupid", "collapse", "sail", "plucky", "impinge", "expert", "flop", "harsh", "hammer", "concerned", "battle", "sag", "break", "honorable", "salvage", "aspiring", "abiding", "cautious", "breakable", "normal", "sleep", "assorted", "float", "medical", "birds", "adjustment", "hate", "contrive", "coast", "shiver", "invent", "exuberant", "fixed", "friends", "visitor", "motivate", "dolls", "tax", "subtract", "lazy", "crime", "disobey", "resonant", "ugliest", "daughter", "representative", "snow", "envious", "growth", "father", "racial", "persuade", "rich", "scan", "throw", "coil", "hapless", "paint", "elderly", "compare", "teach", "fetch", "winter", "hurried", "historical", "party", "comfortable", "saponify", "sink", "profit", "sticky", "heavenly", "aloof", "find", "encourage", "boorish", "impress", "force", "family", "fight", "handy", "stem", "far", "desk", "discreet", "five", "robust", "thrive", "murmur", "far", "obeisant", "venomous", "versed", "bash", "earsplitting", "beggar", "guarded", "disturbed", "solicit", "forlese", "great", "friend"]; 4 | 5 | class fastTyper { 6 | 7 | constructor(options) { 8 | if (!options.message) throw new TypeError('Missing argument: message') 9 | this.word = "" 10 | this.message = options.message 11 | } 12 | 13 | start() { 14 | 15 | let word = possible_words[Math.floor(Math.random() * possible_words.length)] 16 | 17 | let beginEmbed = new discord.MessageEmbed() 18 | .setColor("#960202") 19 | .setTitle(`Fast Typer`) 20 | .setDescription(`**Choosing a word...**`) 21 | .setTimestamp() 22 | 23 | this.message.channel.send({ embeds: [beginEmbed] }).then(emsg => { 24 | 25 | const filter = m => (m.content.toLowerCase() === word) 26 | this.message.channel.awaitMessages({ filter, max: 1, time: 60000 }) 27 | .then(async collected => { 28 | 29 | let firstCollected = collected.first().content 30 | 31 | collected.first().react('🎉') 32 | 33 | let winnerEmbed = new discord.MessageEmbed() 34 | .setColor("YELLOW") 35 | .setTitle(`Fast Typer`) 36 | .setDescription(`Game begins in 5 seconds...\nGame begins in 4 seconds...\nGame begins in 3 seconds...\nGame begins in 2 seconds...\nGame begins in 1 second... 37 | \nThe word is ${word}\n\n**GG!**\n**The winner is ${collected.first().author}**`) 38 | .setTimestamp() 39 | emsg.edit({ embeds: [winnerEmbed] }) 40 | }).catch(err => { 41 | 42 | let timeEmbed = new discord.MessageEmbed() 43 | .setColor("#960202") 44 | .setTitle(`Fast Typer`) 45 | .setDescription(`**You guys were to late to type the word correctly!**`) 46 | .setTimestamp() 47 | return emsg.edit({ embeds: [timeEmbed] }) 48 | }) 49 | 50 | setTimeout(() => { 51 | 52 | let second1 = new discord.MessageEmbed() 53 | .setColor("#b80404") 54 | .setTitle(`Fast Typer`) 55 | .setDescription(` **Games begins in 5 seconds...**\nGame begins in 4 seconds...\nGame begins in 3 seconds...\nGame begins in 2 seconds...\nGame begins in 1 second...`) 56 | .setTimestamp() 57 | 58 | emsg.edit({ embeds: [second1] }) 59 | 60 | setTimeout(() => { 61 | 62 | let second2 = new discord.MessageEmbed() 63 | .setColor("#ff0000") 64 | .setTitle(`Fast Typer`) 65 | .setDescription(`Game begins in 5 seconds...\n**Game begins in 4 seconds...**\nGame begins in 3 seconds...\nGame begins in 2 seconds...\nGame begins in 1 second...`) 66 | .setTimestamp() 67 | 68 | emsg.edit({ embeds: [second2] }) 69 | 70 | setTimeout(() => { 71 | 72 | let second3 = new discord.MessageEmbed() 73 | .setColor("#c45f00") 74 | .setTitle(`Fast Typer`) 75 | .setDescription(`Game begins in 5 seconds...\nGame begins in 4 seconds...\n**Game begins in 3 seconds...**\nGame begins in 2 seconds...\nGame begins in 1 second...`) 76 | .setTimestamp() 77 | 78 | emsg.edit({ embeds: [second3] }) 79 | 80 | setTimeout(() => { 81 | 82 | let second4 = new discord.MessageEmbed() 83 | .setColor("#e06e02") 84 | .setTitle(`Fast Typer`) 85 | .setDescription(`Game begins in 5 seconds...\nGame begins in 4 seconds...\nGame begins in 3 seconds...\n**Game begins in 2 seconds...**\nGame begins in 1 second...`) 86 | .setTimestamp() 87 | 88 | emsg.edit({ embeds: [second4] }) 89 | 90 | setTimeout(() => { 91 | 92 | let second5 = new discord.MessageEmbed() 93 | .setColor("#ff7c00") 94 | .setTitle(`Fast Typer`) 95 | .setDescription(`Game begins in 5 seconds...\nGame begins in 4 seconds...\nGame begins in 3 seconds...\nGame begins in 2 seconds...\n**Game begins in 1 second...**\nThe word is...`) 96 | .setTimestamp() 97 | 98 | emsg.edit({ embeds: [second5] }) 99 | 100 | setTimeout(() => { 101 | 102 | let second6 = new discord.MessageEmbed() 103 | .setColor("#00ff00") 104 | .setTitle(`Fast Typer`) 105 | .setDescription(`Game begins in 5 seconds...\nGame begins in 4 seconds...\nGame begins in 3 seconds...\nGame begins in 2 seconds...\nGame begins in 1 second...\n**The word is... ${word}**`) 106 | .setTimestamp() 107 | 108 | emsg.edit({ embeds: [second6] }) 109 | 110 | }, 1000) 111 | 112 | }, 1000) 113 | 114 | }, 1000) 115 | 116 | }, 1000) 117 | 118 | }, 1000) 119 | 120 | }, 1000) 121 | 122 | }) 123 | } 124 | 125 | } 126 | 127 | module.exports = fastTyper 128 | -------------------------------------------------------------------------------- /games/tictactoe-game.js: -------------------------------------------------------------------------------- 1 | 2 | const { MessageActionRow, MessageButton, MessageEmbed } = require('discord.js'); 3 | 4 | class TicTacToe { 5 | 6 | /** 7 | * @name TicTacToe 8 | * @kind constructor 9 | * @param {Object} options options 10 | * @param {String} [options.xEmoji] x emoji 11 | * @param {any} [options.message] the discord message 12 | * @param {String} [options.xColor] x button color 13 | * @param {String} [options.oEmoji] o emoji 14 | * @param {String} [options.oColor] o button color 15 | * @param {String} [options.embedDescription] embedDescription 16 | * @param {any} [options.opponent] const opponent = .mentions.members.first() (NOT CHANGEABLE) 17 | */ 18 | 19 | constructor(options) { 20 | if (!options.xEmoji) throw new TypeError('Missing argument: xEmoji') 21 | if (typeof options.xEmoji !== 'string') throw new TypeError('Error: xEmoji must be a string') 22 | 23 | if (!options.oEmoji) throw new TypeError('Missing argument: oEmoji') 24 | if (typeof options.oEmoji !== 'string') throw new TypeError('Error: oEmoji must be a string') 25 | 26 | if (!options.xColor) throw new TypeError('Missing argument: xColor') 27 | if (typeof options.xColor !== 'string') throw new TypeError('Error: xColor must be a string') 28 | 29 | if (!options.oColor) throw new TypeError('Missing argument: oColor') 30 | if (typeof options.oColor !== 'string') throw new TypeError('Error: oColor must be a string') 31 | 32 | if (!options.opponent) throw new TypeError('Error: Missing argument opponent') 33 | 34 | if (!options.message) throw new TypeError('Error: Missing argument message') 35 | 36 | this.message = options.message; 37 | this.xEmoji = options.xEmoji 38 | this.oEmoji = options.oEmoji 39 | this.opponent = options.opponent 40 | this.xColor = options.xColor 41 | this.oColor = options.oColor 42 | this.embedDescription = options.embedDescription 43 | } 44 | async start() { 45 | let a1 = '⬜' 46 | let a2 = '⬜' 47 | let a3 = '⬜' 48 | let b1 = '⬜' 49 | let b2 = '⬜' 50 | let b3 = '⬜' 51 | let c1 = '⬜' 52 | let c2 = '⬜' 53 | let c3 = '⬜' 54 | 55 | function getRandomString(length) { 56 | var randomChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; 57 | var result = ''; 58 | for (var i = 0; i < length; i++) { 59 | result += randomChars.charAt(Math.floor(Math.random() * randomChars.length)) 60 | } 61 | return result 62 | } 63 | let a11 = (getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4)) 64 | let a22 = (getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4)) 65 | let a33 = (getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4)) 66 | let b11 = (getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4)) 67 | let b22 = (getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4)) 68 | let b33 = (getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4)) 69 | let c11 = (getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4)) 70 | let c22 = (getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4)) 71 | let c33 = (getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4) + '-' + getRandomString(4)) 72 | 73 | let player = 0; 74 | const author = this.message.author.id 75 | const member = this.opponent 76 | const authorName = this.message.author.username 77 | 78 | const midDuel = new Set() 79 | 80 | if (midDuel.has(author)) { 81 | return this.message.channel.send(`You're currently in a duel`) 82 | } else if (midDuel.has(member.id)) { 83 | return this.message.channel.send(`<@${member.id}> is currently in a duel`) 84 | } if (member.id === this.message.client.user.id) { 85 | return this.message.channel.send("You can't duel me lmfao") 86 | } 87 | const gameData = [ 88 | { member: this.message.author, em: this.xEmoji, color: this.xColor }, 89 | { member: member, em: this.oEmoji, color: this.oColor } 90 | ]; 91 | let Embed = new MessageEmbed() 92 | .setDescription(this.embedDescription || `🎮 ${authorName} VS ${this.opponent.username} 🎮`) 93 | .setColor(3426654) 94 | let A1 = new MessageButton() 95 | .setCustomId(a11) 96 | .setStyle('SECONDARY') 97 | .setLabel('~') 98 | let A2 = new MessageButton() 99 | .setCustomId(a22) 100 | .setStyle('SECONDARY') 101 | .setLabel('~') 102 | let A3 = new MessageButton() 103 | .setCustomId(a33) 104 | .setStyle('SECONDARY') 105 | .setLabel('~') 106 | let B1 = new MessageButton() 107 | .setCustomId(b11) 108 | .setStyle('SECONDARY') 109 | .setLabel('~') 110 | let B2 = new MessageButton() 111 | .setCustomId(b22) 112 | .setStyle('SECONDARY') 113 | .setLabel('~') 114 | let B3 = new MessageButton() 115 | .setCustomId(b33) 116 | .setStyle('SECONDARY') 117 | .setLabel('~') 118 | let C1 = new MessageButton() 119 | .setCustomId(c11) 120 | .setStyle('SECONDARY') 121 | .setLabel('~') 122 | let C2 = new MessageButton() 123 | .setCustomId(c22) 124 | .setStyle('SECONDARY') 125 | .setLabel('~') 126 | let C3 = new MessageButton() 127 | .setCustomId(c33) 128 | .setStyle('SECONDARY') 129 | .setLabel('~') 130 | this.message.channel.send({ 131 | embeds: [Embed], 132 | components: [ 133 | { 134 | type: 1, components: [ 135 | A1, A2, A3 136 | ] 137 | }, 138 | { 139 | type: 1, components: [ 140 | B1, B2, B3 141 | ] 142 | }, 143 | { 144 | type: 1, components: [ 145 | C1, C2, C3 146 | ] 147 | }, 148 | ] 149 | }).then(async (msg) => { 150 | midDuel.add(author) 151 | midDuel.add(member.id) 152 | const gameFilter = m => m.user.id === this.message.author.id || m.user.id === this.opponent.id 153 | 154 | const gameCollector = msg.createMessageComponentCollector({ gameFilter, componentType: 'BUTTON' }); 155 | 156 | 157 | 158 | gameCollector.on('collect', async btn => { 159 | if (btn.customId == a11 && gameData[player].member.id === btn.user.id) { 160 | btn.deferUpdate() 161 | if (btn.label == this.oEmoji || btn.label == this.xEmoji) { // User tries to place at an already claimed spot 162 | btn.reply('That spot is already occupied.') 163 | } else { 164 | try { 165 | a1 = gameData[player].em 166 | if (a1 == this.xEmoji && b1 == this.xEmoji && c1 == this.xEmoji || a1 == this.oEmoji && b1 == this.oEmoji && c1 == this.oEmoji) { 167 | this.message.channel.send(`${gameData[player].member} wins!`) 168 | gameCollector.stop() 169 | midDuel.delete(author) 170 | midDuel.delete(member.id) 171 | } else if (a2 == this.xEmoji && b2 == this.xEmoji && c2 == this.xEmoji || a2 == this.oEmoji && b2 == this.oEmoji && c2 == this.oEmoji) { 172 | this.message.channel.send(`${gameData[player].member} wins!`) 173 | gameCollector.stop() 174 | midDuel.delete(author) 175 | midDuel.delete(member.id) 176 | } else if (a3 == this.xEmoji && b3 == this.xEmoji && c3 == this.xEmoji || a3 == this.oEmoji && b3 == this.oEmoji && c3 == this.oEmoji) { 177 | this.message.channel.send(`${gameData[player].member} wins!`) 178 | gameCollector.stop() 179 | midDuel.delete(author) 180 | midDuel.delete(member.id) 181 | } else if (a1 == this.xEmoji && a2 == this.xEmoji && a3 == this.xEmoji || a1 == this.oEmoji && a2 == this.oEmoji && a3 == this.oEmoji) { 182 | 183 | this.message.channel.send(`${gameData[player].member} wins!`) 184 | gameCollector.stop() 185 | midDuel.delete(author) 186 | midDuel.delete(member.id) 187 | } else if (b1 == this.xEmoji && b2 == this.xEmoji && b3 == this.xEmoji || b1 == this.oEmoji && b2 == this.oEmoji && b3 == this.oEmoji) { 188 | this.message.channel.send(`${gameData[player].member} wins!`) 189 | gameCollector.stop() 190 | midDuel.delete(author) 191 | midDuel.delete(member.id) 192 | } else if (c1 == this.xEmoji && c2 == this.xEmoji && c3 == this.xEmoji || c1 == this.oEmoji && c2 == this.oEmoji && c3 == this.oEmoji) { 193 | player = (player + 1) % 2; 194 | this.message.channel.send(`${gameData[player].member} wins!`) 195 | gameCollector.stop() 196 | midDuel.delete(author) 197 | midDuel.delete(member.id) 198 | } else if (a1 == this.xEmoji && b2 == this.xEmoji && c3 == this.xEmoji || a1 == this.oEmoji && b2 == this.oEmoji && c3 == this.oEmoji) { 199 | 200 | this.message.channel.send(`${gameData[player].member} wins!`) 201 | gameCollector.stop() 202 | midDuel.delete(author) 203 | midDuel.delete(member.id) 204 | } else if (a3 == this.xEmoji && b2 == this.xEmoji && c1 == this.xEmoji || a3 == this.oEmoji && b2 == this.oEmoji && c1 == this.oEmoji) { 205 | this.message.channel.send(`${gameData[player].member} wins!`) 206 | gameCollector.stop() 207 | midDuel.delete(author) 208 | midDuel.delete(member.id) 209 | } 210 | } catch (e) { 211 | console.log(e) 212 | } 213 | player = (player + 1) % 2; 214 | A1 = new MessageButton() 215 | .setCustomId(a11) 216 | .setStyle(gameData[player].color) 217 | .setEmoji(gameData[player].em) 218 | .setDisabled() 219 | msg.edit({ 220 | embeds: [Embed], 221 | components: [ 222 | { 223 | type: 1, components: [ 224 | A1, A2, A3 225 | ] 226 | }, 227 | { 228 | type: 1, components: [ 229 | B1, B2, B3 230 | ] 231 | }, 232 | { 233 | type: 1, components: [ 234 | C1, C2, C3 235 | ] 236 | }, 237 | ] 238 | }) 239 | 240 | } 241 | } else if (btn.customId == a22 && gameData[player].member.id === btn.user.id) { 242 | btn.deferUpdate() 243 | if (btn.label == this.oEmoji || btn.label == this.xEmoji) { // User tries to place at an already claimed spot 244 | btn.reply('That spot is already occupied.') 245 | } else { 246 | try { 247 | a2 = gameData[player].em 248 | if (a1 == this.xEmoji && b1 == this.xEmoji && c1 == this.xEmoji || a1 == this.oEmoji && b1 == this.oEmoji && c1 == this.oEmoji) { 249 | this.message.channel.send(`${gameData[player].member} wins!`) 250 | gameCollector.stop() 251 | midDuel.delete(author) 252 | midDuel.delete(member.id) 253 | } else if (a2 == this.xEmoji && b2 == this.xEmoji && c2 == this.xEmoji || a2 == this.oEmoji && b2 == this.oEmoji && c2 == this.oEmoji) { 254 | this.message.channel.send(`${gameData[player].member} wins!`) 255 | gameCollector.stop() 256 | midDuel.delete(author) 257 | midDuel.delete(member.id) 258 | } else if (a3 == this.xEmoji && b3 == this.xEmoji && c3 == this.xEmoji || a3 == this.oEmoji && b3 == this.oEmoji && c3 == this.oEmoji) { 259 | this.message.channel.send(`${gameData[player].member} wins!`) 260 | gameCollector.stop() 261 | midDuel.delete(author) 262 | midDuel.delete(member.id) 263 | } else if (a1 == this.xEmoji && a2 == this.xEmoji && a3 == this.xEmoji || a1 == this.oEmoji && a2 == this.oEmoji && a3 == this.oEmoji) { 264 | 265 | this.message.channel.send(`${gameData[player].member} wins!`) 266 | gameCollector.stop() 267 | midDuel.delete(author) 268 | midDuel.delete(member.id) 269 | } else if (b1 == this.xEmoji && b2 == this.xEmoji && b3 == this.xEmoji || b1 == this.oEmoji && b2 == this.oEmoji && b3 == this.oEmoji) { 270 | this.message.channel.send(`${gameData[player].member} wins!`) 271 | gameCollector.stop() 272 | midDuel.delete(author) 273 | midDuel.delete(member.id) 274 | } else if (c1 == this.xEmoji && c2 == this.xEmoji && c3 == this.xEmoji || c1 == this.oEmoji && c2 == this.oEmoji && c3 == this.oEmoji) { 275 | player = (player + 1) % 2; 276 | this.message.channel.send(`${gameData[player].member} wins!`) 277 | gameCollector.stop() 278 | midDuel.delete(author) 279 | midDuel.delete(member.id) 280 | } else if (a1 == this.xEmoji && b2 == this.xEmoji && c3 == this.xEmoji || a1 == this.oEmoji && b2 == this.oEmoji && c3 == this.oEmoji) { 281 | 282 | this.message.channel.send(`${gameData[player].member} wins!`) 283 | gameCollector.stop() 284 | midDuel.delete(author) 285 | midDuel.delete(member.id) 286 | } else if (a3 == this.xEmoji && b2 == this.xEmoji && c1 == this.xEmoji || a3 == this.oEmoji && b2 == this.oEmoji && c1 == this.oEmoji) { 287 | this.message.channel.send(`${gameData[player].member} wins!`) 288 | gameCollector.stop() 289 | midDuel.delete(author) 290 | midDuel.delete(member.id) 291 | } 292 | } catch (e) { 293 | console.log(e) 294 | } 295 | player = (player + 1) % 2; 296 | A2 = new MessageButton() 297 | .setCustomId(a22) 298 | .setStyle(gameData[player].color) 299 | .setEmoji(gameData[player].em) 300 | .setDisabled() 301 | msg.edit({ 302 | embeds: [Embed], 303 | components: [ 304 | { 305 | type: 1, components: [ 306 | A1, A2, A3 307 | ] 308 | }, 309 | { 310 | type: 1, components: [ 311 | B1, B2, B3 312 | ] 313 | }, 314 | { 315 | type: 1, components: [ 316 | C1, C2, C3 317 | ] 318 | }, 319 | ] 320 | }) 321 | 322 | } 323 | } else if (btn.customId == a33 && gameData[player].member.id === btn.user.id) { 324 | btn.deferUpdate() 325 | if (btn.label == this.oEmoji || btn.label == this.xEmoji) { // User tries to place at an already claimed spot 326 | btn.reply('That spot is already occupied.') 327 | } else { 328 | try { 329 | a3 = gameData[player].em 330 | if (a1 == this.xEmoji && b1 == this.xEmoji && c1 == this.xEmoji || a1 == this.oEmoji && b1 == this.oEmoji && c1 == this.oEmoji) { 331 | this.message.channel.send(`${gameData[player].member} wins!`) 332 | gameCollector.stop() 333 | midDuel.delete(author) 334 | midDuel.delete(member.id) 335 | } else if (a2 == this.xEmoji && b2 == this.xEmoji && c2 == this.xEmoji || a2 == this.oEmoji && b2 == this.oEmoji && c2 == this.oEmoji) { 336 | this.message.channel.send(`${gameData[player].member} wins!`) 337 | gameCollector.stop() 338 | midDuel.delete(author) 339 | midDuel.delete(member.id) 340 | } else if (a3 == this.xEmoji && b3 == this.xEmoji && c3 == this.xEmoji || a3 == this.oEmoji && b3 == this.oEmoji && c3 == this.oEmoji) { 341 | this.message.channel.send(`${gameData[player].member} wins!`) 342 | gameCollector.stop() 343 | midDuel.delete(author) 344 | midDuel.delete(member.id) 345 | } else if (a1 == this.xEmoji && a2 == this.xEmoji && a3 == this.xEmoji || a1 == this.oEmoji && a2 == this.oEmoji && a3 == this.oEmoji) { 346 | 347 | this.message.channel.send(`${gameData[player].member} wins!`) 348 | gameCollector.stop() 349 | midDuel.delete(author) 350 | midDuel.delete(member.id) 351 | } else if (b1 == this.xEmoji && b2 == this.xEmoji && b3 == this.xEmoji || b1 == this.oEmoji && b2 == this.oEmoji && b3 == this.oEmoji) { 352 | this.message.channel.send(`${gameData[player].member} wins!`) 353 | gameCollector.stop() 354 | midDuel.delete(author) 355 | midDuel.delete(member.id) 356 | } else if (c1 == this.xEmoji && c2 == this.xEmoji && c3 == this.xEmoji || c1 == this.oEmoji && c2 == this.oEmoji && c3 == this.oEmoji) { 357 | player = (player + 1) % 2; 358 | this.message.channel.send(`${gameData[player].member} wins!`) 359 | gameCollector.stop() 360 | midDuel.delete(author) 361 | midDuel.delete(member.id) 362 | } else if (a1 == this.xEmoji && b2 == this.xEmoji && c3 == this.xEmoji || a1 == this.oEmoji && b2 == this.oEmoji && c3 == this.oEmoji) { 363 | 364 | this.message.channel.send(`${gameData[player].member} wins!`) 365 | gameCollector.stop() 366 | midDuel.delete(author) 367 | midDuel.delete(member.id) 368 | } else if (a3 == this.xEmoji && b2 == this.xEmoji && c1 == this.xEmoji || a3 == this.oEmoji && b2 == this.oEmoji && c1 == this.oEmoji) { 369 | this.message.channel.send(`${gameData[player].member} wins!`) 370 | gameCollector.stop() 371 | midDuel.delete(author) 372 | midDuel.delete(member.id) 373 | } 374 | } catch (e) { 375 | console.log(e) 376 | } 377 | player = (player + 1) % 2; 378 | A3 = new MessageButton() 379 | .setCustomId(a33) 380 | .setStyle(gameData[player].color) 381 | .setEmoji(gameData[player].em) 382 | .setDisabled() 383 | msg.edit({ 384 | embeds: [Embed], 385 | components: [ 386 | { 387 | type: 1, components: [ 388 | A1, A2, A3 389 | ] 390 | }, 391 | { 392 | type: 1, components: [ 393 | B1, B2, B3 394 | ] 395 | }, 396 | { 397 | type: 1, components: [ 398 | C1, C2, C3 399 | ] 400 | }, 401 | ] 402 | }) 403 | 404 | } 405 | } else if (btn.customId == b11 && gameData[player].member.id === btn.user.id) { 406 | btn.deferUpdate() 407 | if (btn.label == this.oEmoji || btn.label == this.xEmoji) { // User tries to place at an already claimed spot 408 | btn.reply('That spot is already occupied.') 409 | } else { 410 | 411 | try { 412 | b1 = gameData[player].em 413 | if (a1 == this.xEmoji && b1 == this.xEmoji && c1 == this.xEmoji || a1 == this.oEmoji && b1 == this.oEmoji && c1 == this.oEmoji) { 414 | this.message.channel.send(`${gameData[player].member} wins!`) 415 | gameCollector.stop() 416 | midDuel.delete(author) 417 | midDuel.delete(member.id) 418 | } else if (a2 == this.xEmoji && b2 == this.xEmoji && c2 == this.xEmoji || a2 == this.oEmoji && b2 == this.oEmoji && c2 == this.oEmoji) { 419 | this.message.channel.send(`${gameData[player].member} wins!`) 420 | gameCollector.stop() 421 | midDuel.delete(author) 422 | midDuel.delete(member.id) 423 | } else if (a3 == this.xEmoji && b3 == this.xEmoji && c3 == this.xEmoji || a3 == this.oEmoji && b3 == this.oEmoji && c3 == this.oEmoji) { 424 | this.message.channel.send(`${gameData[player].member} wins!`) 425 | gameCollector.stop() 426 | midDuel.delete(author) 427 | midDuel.delete(member.id) 428 | } else if (a1 == this.xEmoji && a2 == this.xEmoji && a3 == this.xEmoji || a1 == this.oEmoji && a2 == this.oEmoji && a3 == this.oEmoji) { 429 | 430 | this.message.channel.send(`${gameData[player].member} wins!`) 431 | gameCollector.stop() 432 | midDuel.delete(author) 433 | midDuel.delete(member.id) 434 | } else if (b1 == this.xEmoji && b2 == this.xEmoji && b3 == this.xEmoji || b1 == this.oEmoji && b2 == this.oEmoji && b3 == this.oEmoji) { 435 | this.message.channel.send(`${gameData[player].member} wins!`) 436 | gameCollector.stop() 437 | midDuel.delete(author) 438 | midDuel.delete(member.id) 439 | } else if (c1 == this.xEmoji && c2 == this.xEmoji && c3 == this.xEmoji || c1 == this.oEmoji && c2 == this.oEmoji && c3 == this.oEmoji) { 440 | player = (player + 1) % 2; 441 | this.message.channel.send(`${gameData[player].member} wins!`) 442 | gameCollector.stop() 443 | midDuel.delete(author) 444 | midDuel.delete(member.id) 445 | } else if (a1 == this.xEmoji && b2 == this.xEmoji && c3 == this.xEmoji || a1 == this.oEmoji && b2 == this.oEmoji && c3 == this.oEmoji) { 446 | 447 | this.message.channel.send(`${gameData[player].member} wins!`) 448 | gameCollector.stop() 449 | midDuel.delete(author) 450 | midDuel.delete(member.id) 451 | } else if (a3 == this.xEmoji && b2 == this.xEmoji && c1 == this.xEmoji || a3 == this.oEmoji && b2 == this.oEmoji && c1 == this.oEmoji) { 452 | this.message.channel.send(`${gameData[player].member} wins!`) 453 | gameCollector.stop() 454 | midDuel.delete(author) 455 | midDuel.delete(member.id) 456 | } 457 | } catch (e) { 458 | console.log(e) 459 | } 460 | player = (player + 1) % 2; 461 | B1 = new MessageButton() 462 | .setCustomId(b11) 463 | .setStyle(gameData[player].color) 464 | .setEmoji(gameData[player].em) 465 | .setDisabled() 466 | msg.edit({ 467 | embeds: [Embed], 468 | components: [ 469 | { 470 | type: 1, components: [ 471 | A1, A2, A3 472 | ] 473 | }, 474 | { 475 | type: 1, components: [ 476 | B1, B2, B3 477 | ] 478 | }, 479 | { 480 | type: 1, components: [ 481 | C1, C2, C3 482 | ] 483 | }, 484 | ] 485 | }) 486 | 487 | } 488 | } else if (btn.customId == b22 && gameData[player].member.id === btn.user.id) { 489 | btn.deferUpdate() 490 | if (btn.label == this.oEmoji || btn.label == this.xEmoji) { // User tries to place at an already claimed spot 491 | btn.reply('That spot is already occupied.') 492 | } else { 493 | try { 494 | b2 = gameData[player].em 495 | if (a1 == this.xEmoji && b1 == this.xEmoji && c1 == this.xEmoji || a1 == this.oEmoji && b1 == this.oEmoji && c1 == this.oEmoji) { 496 | this.message.channel.send(`${gameData[player].member} wins!`) 497 | gameCollector.stop() 498 | midDuel.delete(author) 499 | midDuel.delete(member.id) 500 | } else if (a2 == this.xEmoji && b2 == this.xEmoji && c2 == this.xEmoji || a2 == this.oEmoji && b2 == this.oEmoji && c2 == this.oEmoji) { 501 | this.message.channel.send(`${gameData[player].member} wins!`) 502 | gameCollector.stop() 503 | midDuel.delete(author) 504 | midDuel.delete(member.id) 505 | } else if (a3 == this.xEmoji && b3 == this.xEmoji && c3 == this.xEmoji || a3 == this.oEmoji && b3 == this.oEmoji && c3 == this.oEmoji) { 506 | this.message.channel.send(`${gameData[player].member} wins!`) 507 | gameCollector.stop() 508 | midDuel.delete(author) 509 | midDuel.delete(member.id) 510 | } else if (a1 == this.xEmoji && a2 == this.xEmoji && a3 == this.xEmoji || a1 == this.oEmoji && a2 == this.oEmoji && a3 == this.oEmoji) { 511 | 512 | this.message.channel.send(`${gameData[player].member} wins!`) 513 | gameCollector.stop() 514 | midDuel.delete(author) 515 | midDuel.delete(member.id) 516 | } else if (b1 == this.xEmoji && b2 == this.xEmoji && b3 == this.xEmoji || b1 == this.oEmoji && b2 == this.oEmoji && b3 == this.oEmoji) { 517 | this.message.channel.send(`${gameData[player].member} wins!`) 518 | gameCollector.stop() 519 | midDuel.delete(author) 520 | midDuel.delete(member.id) 521 | } else if (c1 == this.xEmoji && c2 == this.xEmoji && c3 == this.xEmoji || c1 == this.oEmoji && c2 == this.oEmoji && c3 == this.oEmoji) { 522 | player = (player + 1) % 2; 523 | this.message.channel.send(`${gameData[player].member} wins!`) 524 | gameCollector.stop() 525 | midDuel.delete(author) 526 | midDuel.delete(member.id) 527 | } else if (a1 == this.xEmoji && b2 == this.xEmoji && c3 == this.xEmoji || a1 == this.oEmoji && b2 == this.oEmoji && c3 == this.oEmoji) { 528 | 529 | this.message.channel.send(`${gameData[player].member} wins!`) 530 | gameCollector.stop() 531 | midDuel.delete(author) 532 | midDuel.delete(member.id) 533 | } else if (a3 == this.xEmoji && b2 == this.xEmoji && c1 == this.xEmoji || a3 == this.oEmoji && b2 == this.oEmoji && c1 == this.oEmoji) { 534 | this.message.channel.send(`${gameData[player].member} wins!`) 535 | gameCollector.stop() 536 | midDuel.delete(author) 537 | midDuel.delete(member.id) 538 | } 539 | } catch (e) { 540 | console.log(e) 541 | } 542 | player = (player + 1) % 2; 543 | B2 = new MessageButton() 544 | .setCustomId(b22) 545 | .setStyle(gameData[player].color) 546 | .setEmoji(gameData[player].em) 547 | .setDisabled() 548 | msg.edit({ 549 | embeds: [Embed], 550 | components: [ 551 | { 552 | type: 1, components: [ 553 | A1, A2, A3 554 | ] 555 | }, 556 | { 557 | type: 1, components: [ 558 | B1, B2, B3 559 | ] 560 | }, 561 | { 562 | type: 1, components: [ 563 | C1, C2, C3 564 | ] 565 | }, 566 | ] 567 | }) 568 | 569 | } 570 | } else if (btn.customId == b33 && gameData[player].member.id === btn.user.id) { 571 | btn.deferUpdate() 572 | if (btn.label == this.oEmoji || btn.label == this.xEmoji) { // User tries to place at an already claimed spot 573 | btn.reply('That spot is already occupied.') 574 | } else { 575 | try { 576 | b3 = gameData[player].em 577 | if (a1 == this.xEmoji && b1 == this.xEmoji && c1 == this.xEmoji || a1 == this.oEmoji && b1 == this.oEmoji && c1 == this.oEmoji) { 578 | this.message.channel.send(`${gameData[player].member} wins!`) 579 | gameCollector.stop() 580 | midDuel.delete(author) 581 | midDuel.delete(member.id) 582 | } else if (a2 == this.xEmoji && b2 == this.xEmoji && c2 == this.xEmoji || a2 == this.oEmoji && b2 == this.oEmoji && c2 == this.oEmoji) { 583 | this.message.channel.send(`${gameData[player].member} wins!`) 584 | gameCollector.stop() 585 | midDuel.delete(author) 586 | midDuel.delete(member.id) 587 | } else if (a3 == this.xEmoji && b3 == this.xEmoji && c3 == this.xEmoji || a3 == this.oEmoji && b3 == this.oEmoji && c3 == this.oEmoji) { 588 | this.message.channel.send(`${gameData[player].member} wins!`) 589 | gameCollector.stop() 590 | midDuel.delete(author) 591 | midDuel.delete(member.id) 592 | } else if (a1 == this.xEmoji && a2 == this.xEmoji && a3 == this.xEmoji || a1 == this.oEmoji && a2 == this.oEmoji && a3 == this.oEmoji) { 593 | 594 | this.message.channel.send(`${gameData[player].member} wins!`) 595 | gameCollector.stop() 596 | midDuel.delete(author) 597 | midDuel.delete(member.id) 598 | } else if (b1 == this.xEmoji && b2 == this.xEmoji && b3 == this.xEmoji || b1 == this.oEmoji && b2 == this.oEmoji && b3 == this.oEmoji) { 599 | this.message.channel.send(`${gameData[player].member} wins!`) 600 | gameCollector.stop() 601 | midDuel.delete(author) 602 | midDuel.delete(member.id) 603 | } else if (c1 == this.xEmoji && c2 == this.xEmoji && c3 == this.xEmoji || c1 == this.oEmoji && c2 == this.oEmoji && c3 == this.oEmoji) { 604 | player = (player + 1) % 2; 605 | this.message.channel.send(`${gameData[player].member} wins!`) 606 | gameCollector.stop() 607 | midDuel.delete(author) 608 | midDuel.delete(member.id) 609 | } else if (a1 == this.xEmoji && b2 == this.xEmoji && c3 == this.xEmoji || a1 == this.oEmoji && b2 == this.oEmoji && c3 == this.oEmoji) { 610 | 611 | this.message.channel.send(`${gameData[player].member} wins!`) 612 | gameCollector.stop() 613 | midDuel.delete(author) 614 | midDuel.delete(member.id) 615 | } else if (a3 == this.xEmoji && b2 == this.xEmoji && c1 == this.xEmoji || a3 == this.oEmoji && b2 == this.oEmoji && c1 == this.oEmoji) { 616 | this.message.channel.send(`${gameData[player].member} wins!`) 617 | gameCollector.stop() 618 | midDuel.delete(author) 619 | midDuel.delete(member.id) 620 | } 621 | } catch (e) { 622 | console.log(e) 623 | } 624 | player = (player + 1) % 2; 625 | B3 = new MessageButton() 626 | .setCustomId(b33) 627 | .setStyle(gameData[player].color) 628 | .setEmoji(gameData[player].em) 629 | .setDisabled() 630 | msg.edit({ 631 | embeds: [Embed], 632 | components: [ 633 | { 634 | type: 1, components: [ 635 | A1, A2, A3 636 | ] 637 | }, 638 | { 639 | type: 1, components: [ 640 | B1, B2, B3 641 | ] 642 | }, 643 | { 644 | type: 1, components: [ 645 | C1, C2, C3 646 | ] 647 | }, 648 | ] 649 | }) 650 | 651 | } 652 | } else if (btn.customId == c11 && gameData[player].member.id === btn.user.id) { 653 | btn.deferUpdate() 654 | if (btn.label == this.oEmoji || btn.label == this.xEmoji) { // User tries to place at an already claimed spot 655 | btn.reply('That spot is already occupied.') 656 | } else { 657 | try { 658 | c1 = gameData[player].em 659 | if (a1 == this.xEmoji && b1 == this.xEmoji && c1 == this.xEmoji || a1 == this.oEmoji && b1 == this.oEmoji && c1 == this.oEmoji) { 660 | this.message.channel.send(`${gameData[player].member} wins!`) 661 | gameCollector.stop() 662 | midDuel.delete(author) 663 | midDuel.delete(member.id) 664 | } else if (a2 == this.xEmoji && b2 == this.xEmoji && c2 == this.xEmoji || a2 == this.oEmoji && b2 == this.oEmoji && c2 == this.oEmoji) { 665 | this.message.channel.send(`${gameData[player].member} wins!`) 666 | gameCollector.stop() 667 | midDuel.delete(author) 668 | midDuel.delete(member.id) 669 | } else if (a3 == this.xEmoji && b3 == this.xEmoji && c3 == this.xEmoji || a3 == this.oEmoji && b3 == this.oEmoji && c3 == this.oEmoji) { 670 | this.message.channel.send(`${gameData[player].member} wins!`) 671 | gameCollector.stop() 672 | midDuel.delete(author) 673 | midDuel.delete(member.id) 674 | } else if (a1 == this.xEmoji && a2 == this.xEmoji && a3 == this.xEmoji || a1 == this.oEmoji && a2 == this.oEmoji && a3 == this.oEmoji) { 675 | 676 | this.message.channel.send(`${gameData[player].member} wins!`) 677 | gameCollector.stop() 678 | midDuel.delete(author) 679 | midDuel.delete(member.id) 680 | } else if (b1 == this.xEmoji && b2 == this.xEmoji && b3 == this.xEmoji || b1 == this.oEmoji && b2 == this.oEmoji && b3 == this.oEmoji) { 681 | this.message.channel.send(`${gameData[player].member} wins!`) 682 | gameCollector.stop() 683 | midDuel.delete(author) 684 | midDuel.delete(member.id) 685 | } else if (c1 == this.xEmoji && c2 == this.xEmoji && c3 == this.xEmoji || c1 == this.oEmoji && c2 == this.oEmoji && c3 == this.oEmoji) { 686 | player = (player + 1) % 2; 687 | this.message.channel.send(`${gameData[player].member} wins!`) 688 | gameCollector.stop() 689 | midDuel.delete(author) 690 | midDuel.delete(member.id) 691 | } else if (a1 == this.xEmoji && b2 == this.xEmoji && c3 == this.xEmoji || a1 == this.oEmoji && b2 == this.oEmoji && c3 == this.oEmoji) { 692 | 693 | this.message.channel.send(`${gameData[player].member} wins!`) 694 | gameCollector.stop() 695 | midDuel.delete(author) 696 | midDuel.delete(member.id) 697 | } else if (a3 == this.xEmoji && b2 == this.xEmoji && c1 == this.xEmoji || a3 == this.oEmoji && b2 == this.oEmoji && c1 == this.oEmoji) { 698 | this.message.channel.send(`${gameData[player].member} wins!`) 699 | gameCollector.stop() 700 | midDuel.delete(author) 701 | midDuel.delete(member.id) 702 | } 703 | } catch (e) { 704 | console.log(e) 705 | } 706 | player = (player + 1) % 2; 707 | C1 = new MessageButton() 708 | .setCustomId(c11) 709 | .setStyle(gameData[player].color) 710 | .setEmoji(gameData[player].em) 711 | .setDisabled() 712 | msg.edit({ 713 | embeds: [Embed], 714 | components: [ 715 | { 716 | type: 1, components: [ 717 | A1, A2, A3 718 | ] 719 | }, 720 | { 721 | type: 1, components: [ 722 | B1, B2, B3 723 | ] 724 | }, 725 | { 726 | type: 1, components: [ 727 | C1, C2, C3 728 | ] 729 | }, 730 | ] 731 | }) 732 | 733 | } 734 | } else if (btn.customId == c22 && gameData[player].member.id === btn.user.id) { 735 | btn.deferUpdate() 736 | if (btn.label == this.oEmoji || btn.label == this.xEmoji) { // User tries to place at an already claimed spot 737 | btn.reply('That spot is already occupied.') 738 | } else { 739 | try { 740 | c2 = gameData[player].em 741 | if (a1 == this.xEmoji && b1 == this.xEmoji && c1 == this.xEmoji || a1 == this.oEmoji && b1 == this.oEmoji && c1 == this.oEmoji) { 742 | this.message.channel.send(`${gameData[player].member} wins!`) 743 | gameCollector.stop() 744 | midDuel.delete(author) 745 | midDuel.delete(member.id) 746 | } else if (a2 == this.xEmoji && b2 == this.xEmoji && c2 == this.xEmoji || a2 == this.oEmoji && b2 == this.oEmoji && c2 == this.oEmoji) { 747 | this.message.channel.send(`${gameData[player].member} wins!`) 748 | gameCollector.stop() 749 | midDuel.delete(author) 750 | midDuel.delete(member.id) 751 | } else if (a3 == this.xEmoji && b3 == this.xEmoji && c3 == this.xEmoji || a3 == this.oEmoji && b3 == this.oEmoji && c3 == this.oEmoji) { 752 | this.message.channel.send(`${gameData[player].member} wins!`) 753 | gameCollector.stop() 754 | midDuel.delete(author) 755 | midDuel.delete(member.id) 756 | } else if (a1 == this.xEmoji && a2 == this.xEmoji && a3 == this.xEmoji || a1 == this.oEmoji && a2 == this.oEmoji && a3 == this.oEmoji) { 757 | 758 | this.message.channel.send(`${gameData[player].member} wins!`) 759 | gameCollector.stop() 760 | midDuel.delete(author) 761 | midDuel.delete(member.id) 762 | } else if (b1 == this.xEmoji && b2 == this.xEmoji && b3 == this.xEmoji || b1 == this.oEmoji && b2 == this.oEmoji && b3 == this.oEmoji) { 763 | this.message.channel.send(`${gameData[player].member} wins!`) 764 | gameCollector.stop() 765 | midDuel.delete(author) 766 | midDuel.delete(member.id) 767 | } else if (c1 == this.xEmoji && c2 == this.xEmoji && c3 == this.xEmoji || c1 == this.oEmoji && c2 == this.oEmoji && c3 == this.oEmoji) { 768 | player = (player + 1) % 2; 769 | this.message.channel.send(`${gameData[player].member} wins!`) 770 | gameCollector.stop() 771 | midDuel.delete(author) 772 | midDuel.delete(member.id) 773 | } else if (a1 == this.xEmoji && b2 == this.xEmoji && c3 == this.xEmoji || a1 == this.oEmoji && b2 == this.oEmoji && c3 == this.oEmoji) { 774 | 775 | this.message.channel.send(`${gameData[player].member} wins!`) 776 | gameCollector.stop() 777 | midDuel.delete(author) 778 | midDuel.delete(member.id) 779 | } else if (a3 == this.xEmoji && b2 == this.xEmoji && c1 == this.xEmoji || a3 == this.oEmoji && b2 == this.oEmoji && c1 == this.oEmoji) { 780 | this.message.channel.send(`${gameData[player].member} wins!`) 781 | gameCollector.stop() 782 | midDuel.delete(author) 783 | midDuel.delete(member.id) 784 | } 785 | } catch (e) { 786 | console.log(e) 787 | } 788 | player = (player + 1) % 2; 789 | C2 = new MessageButton() 790 | .setCustomId(c22) 791 | .setStyle(gameData[player].color) 792 | .setEmoji(gameData[player].em) 793 | .setDisabled() 794 | msg.edit({ 795 | embeds: [Embed], 796 | components: [ 797 | { 798 | type: 1, components: [ 799 | A1, A2, A3 800 | ] 801 | }, 802 | { 803 | type: 1, components: [ 804 | B1, B2, B3 805 | ] 806 | }, 807 | { 808 | type: 1, components: [ 809 | C1, C2, C3 810 | ] 811 | }, 812 | ] 813 | }) 814 | 815 | } 816 | } else if (btn.customId == c33 && gameData[player].member.id === btn.user.id) { 817 | btn.deferUpdate() 818 | if (btn.label == this.oEmoji || btn.label == this.xEmoji) { // User tries to place at an already claimed spot 819 | btn.reply('That spot is already occupied.') 820 | } else { 821 | try { 822 | c3 = gameData[player].em 823 | if (a1 == this.xEmoji && b1 == this.xEmoji && c1 == this.xEmoji || a1 == this.oEmoji && b1 == this.oEmoji && c1 == this.oEmoji) { 824 | this.message.channel.send(`${gameData[player].member} wins!`) 825 | gameCollector.stop() 826 | midDuel.delete(author) 827 | midDuel.delete(member.id) 828 | } else if (a2 == this.xEmoji && b2 == this.xEmoji && c2 == this.xEmoji || a2 == this.oEmoji && b2 == this.oEmoji && c2 == this.oEmoji) { 829 | this.message.channel.send(`${gameData[player].member} wins!`) 830 | gameCollector.stop() 831 | midDuel.delete(author) 832 | midDuel.delete(member.id) 833 | } else if (a3 == this.xEmoji && b3 == this.xEmoji && c3 == this.xEmoji || a3 == this.oEmoji && b3 == this.oEmoji && c3 == this.oEmoji) { 834 | this.message.channel.send(`${gameData[player].member} wins!`) 835 | gameCollector.stop() 836 | midDuel.delete(author) 837 | midDuel.delete(member.id) 838 | } else if (a1 == this.xEmoji && a2 == this.xEmoji && a3 == this.xEmoji || a1 == this.oEmoji && a2 == this.oEmoji && a3 == this.oEmoji) { 839 | 840 | this.message.channel.send(`${gameData[player].member} wins!`) 841 | gameCollector.stop() 842 | midDuel.delete(author) 843 | midDuel.delete(member.id) 844 | } else if (b1 == this.xEmoji && b2 == this.xEmoji && b3 == this.xEmoji || b1 == this.oEmoji && b2 == this.oEmoji && b3 == this.oEmoji) { 845 | this.message.channel.send(`${gameData[player].member} wins!`) 846 | gameCollector.stop() 847 | midDuel.delete(author) 848 | midDuel.delete(member.id) 849 | } else if (c1 == this.xEmoji && c2 == this.xEmoji && c3 == this.xEmoji || c1 == this.oEmoji && c2 == this.oEmoji && c3 == this.oEmoji) { 850 | player = (player + 1) % 2; 851 | this.message.channel.send(`${gameData[player].member} wins!`) 852 | gameCollector.stop() 853 | midDuel.delete(author) 854 | midDuel.delete(member.id) 855 | } else if (a1 == this.xEmoji && b2 == this.xEmoji && c3 == this.xEmoji || a1 == this.oEmoji && b2 == this.oEmoji && c3 == this.oEmoji) { 856 | 857 | this.message.channel.send(`${gameData[player].member} wins!`) 858 | gameCollector.stop() 859 | midDuel.delete(author) 860 | midDuel.delete(member.id) 861 | } else if (a3 == this.xEmoji && b2 == this.xEmoji && c1 == this.xEmoji || a3 == this.oEmoji && b2 == this.oEmoji && c1 == this.oEmoji) { 862 | this.message.channel.send(`${gameData[player].member} wins!`) 863 | gameCollector.stop() 864 | midDuel.delete(author) 865 | midDuel.delete(member.id) 866 | } else if (a1 !== '⬜' && a2 !== '⬜' && a3 !== '⬜' && b1 !== '⬜' && b2 !== '⬜' && b3 !== '⬜' && c1 !== '⬜' && c2 !== '⬜' && c3 !== '⬜') { 867 | this.message.channel.send(`Tie!`) 868 | gameCollector.stop() 869 | midDuel.delete(author) 870 | midDuel.delete(member.id) 871 | } 872 | } catch (e) { 873 | console.log(e) 874 | } 875 | player = (player + 1) % 2; 876 | C3 = new MessageButton() 877 | .setCustomId(c33) 878 | .setStyle(gameData[player].color) 879 | .setEmoji(gameData[player].em) 880 | .setDisabled() 881 | msg.edit({ 882 | embeds: [Embed], 883 | components: [ 884 | { 885 | type: 1, components: [ 886 | A1, A2, A3 887 | ] 888 | }, 889 | { 890 | type: 1, components: [ 891 | B1, B2, B3 892 | ] 893 | }, 894 | { 895 | type: 1, components: [ 896 | C1, C2, C3 897 | ] 898 | }, 899 | ] 900 | }) 901 | } 902 | } else { 903 | return btn.reply({ content: "Wait for Opponent!", ephemeral: true }) 904 | } 905 | 906 | 907 | }) 908 | 909 | }) 910 | } 911 | 912 | } 913 | 914 | module.exports = TicTacToe; --------------------------------------------------------------------------------