A simple discord bot that updates a channel name with the current player count of an A2S protocol supported server. This was made for DayZ servers but should work for others as well as long as the python-a2s library can connect to them.
- Create a new Discord bot and get the token.
- Add the bot to your server, and make sure it has permission to manage the channels you want to update. I like to create a voice channels and disallow connection to them for all users.
cp config.py.example config.pyand fill out the variables. Alternatively template the file with whatever deployment orchestration system you use.
An example config file for a server can be seen here:
# Format is server_name, ip, port, channel_id
SERVERS = [("Namalsk", "158.51.123.148", 2303, 1433272621092307004)]
WAIT = 120
BOT_TOKEN = "redacted"You may run into rate limiting if you are updating too many channels too frequently. Feel free to mess around with the values or add aditional waits in between servers.
pip install -r requirements.txtto install the dependencies. I recommend using a virtual environment as most distros no longer support globally installing pip packages.python main.py
docker build . --tag discord-a2s-player-count:latestdocker run -d discord-a2s-player-count:latestto run in background ordocker run -it discord-a2s-player-count:latestto run in current terminal.
- Players in queue.
Feel free to open an issue or a PR to fix or improve the project.