A Discord bot for organizing in-house 5v5 matches of Counter-Strike, Valorant, Overwatch, etc
One user starts a group, and 9 other users click the "join" button to be placed on a team.
Teams are shown in the bot's message, and can be shuffled by the group leader.
Startup Message
Empty Teams
Full Teams
Project is open for contributions!
The bot is written in Elixir and uses the Nostrum library to interact with Discord.
The core data layer is using the Ash framework and is backed by a PostgreSQL database (definitely overkill, but the official Ash SQLite integration wasn't available yet!).
The production instance is deployed on Fly.io.
Things you'll need in order to contribute
- Elixir
- https://elixir-lang.org
- I'm using version 1.15 with Erlang/OTP 26
- A PostgreSQL database
- https://www.postgresql.org
- If you have docker, there's a
docker-compose
file in this repository which will run a dev database for you. Find it at lfg_bot_pgsql/docker-compose.yml
- A Discord developer app for testing your changes locally
- An environment variable on your system called
LFG_NOSTRUM_TOKEN
- Once you've made an app in the Discord developer portal (see section above), you can get your token from the settings page in the "Bot" section, under the "Build-A-Bot" header.
- Copy the token and set yourself an environment variable named
LFG_NOSTRUM_TOKEN
- Keep your token secret!
- A Discord server for testing your changes
- It's recommended to use a personal server for this, just in case
- Once you've made an app in the Discord developer portal (see section above), you can add that bot to your server by:
- Getting your client ID from the
OAuth2
section - Substituting your client ID in this URL:
https://discord.com/api/oauth2/authorize?client_id=<YOUR_CLIENT_ID_HERE>&permissions=53687158848&scope=bot
- (Permissions code last updated Oct 26 2023 // permissions calculator)
- Opening that URL in your browser
- Getting your client ID from the
Unless I've missed something, after all this, you should be able to run the elixir application and interact with the bot in your testing server.
- lib/lfg_bot/discord/consumer.ex
- The module that listens for Discord events and sends them over to domain-specific handler functions
- lib/lfg_bot/discord/interaction_handlers.ex
- Handlers for Discord Interactions (button clicks etc)
- lib/lfg_bot/discord/message_handlers.ex
- Handlers for Discord messages
- lib/lfg_bot/lfg_system/resources/registered_guild_channel.ex
RegisteredGuildChannel
database model- Represents a Discord server & channel wherein the bot can be controlled
- lib/lfg_bot/lfg_system/resources/session.ex
Session
database model- Represents a group/session and stores the team player lists