A simple Discord bot that allows you to play Four In A Row (Connect 4) with other users!
This is a Discord bot, and the players interact with the bot through commands. Essentially, this is the game of Connect 4.
You challenge another player on Discord. You win when you get 4 of your discs in a row (horizontally, vertically, or diagonally) while preventing the opponent from getting the four-in-a-row.
- Run the command
!challenge @User#1234
, replacing the user with an actual username - React with emojis (1-7) to select a column to place your disc in
- React with ❌ to forfeit
- Go to the Discord Developer Portal
- Click
New Application
- Click on
Bot
on the left side to switch to that tab - Click
Add Bot
on the right side to add a bot - Copy the token and put it aside for later
- Click on
OAuth2
on the left side - Under Scopes, check the
bot
option - Open the link to invite the bot to your server
- The link should look like this:
https://discord.com/api/oauth2/authorize?client_id=732668501328641883&permissions=0&scope=bot
- The link should look like this:
Alternatively, use this link to skip Steps 8-9. Replace the <client_id>
with your client ID from the General Information
page
- For the target Discord channel, make sure the bot has the following permissions:
- Send Messages
- Allows the bot to send the board into the chat
- Manage Messages
- Deletes older instances of the game board when if refreshes
- Read Message History
- Safety check, ensure that the bot can find old instances of the board that need to be deleted
- Add Reactions
- The game is interacted with through reactions, so this is necessary to create the buttons
- Send Messages
If you fail to provide the correct permissions, games will not run as intended! 10. Make sure you have Java installed on your target computer (version 8 minimum) 11. Download (or compile) the JAR file for this bot 12. To run the program, type:
java -jar FourInARow.jar --token <token you just copied>
If you want to whitelist channels, add this to the end of your command:
--whitelist <channel ID #1> <channel ID #2...>
Or you can blacklist channels:
--blacklist <channel ID #1> <channel ID #2...>
You can add as many channel ID's as you need, but you cannot use whitelist AND blacklist together.
###Example command with whitelisting:
java -jar FourInARow.jar --token Nzk4NTg5Nzg1NDEyMzM3NzQ1.X_3OsQ.J9O6BvG-RfCTXlpXtb-Ck34qffY --whitelist 617175382444032030 652809232755943378
- Java Runtime Environment (JRE) version 1.8.0_271
- Java Discord API (JDA) version 4.2.0_168
- Simple Logging Facade for Java (SLF4J) version 1.7.9