Inspiration

A tweet where someone said they were playing connect 4 on Discord. They were doing it manually, so I decided to automate it.

What it does

It lets you play connect 4. To start, simply type !c4 play @player2 (player2 is the @mention of someone else you want to play). The bot will pull up a game board, and the person who typed !c4 play goes first. Each person then takes turns clicking on the reaction that corresponds to the column they want to play in.

How I built it

I used a library called discord.py for writing bots in Python.

Challenges I ran into

Win detection. I had to figure out how to detect who won the game. Fortunately, someone did that for me, and I could just incorporate their open-source code in my bot.

What's next for connect4-bot

  • Letting people change the prefix.
  • Letting people resume games if the bot is restarted
  • Showing the name of the player who's turn it is at the top, rather than just Player 1 or Player 2

Built With

Share this project:

Updates