A simple bot for polling your FiveM server endpoint and displaying the current amount of players online.
- Install the required modules (discord etc..) with:
pip3 install -r requirements.txt
- Execute
export DISCORDM=<token>
to set an environment variable with your bot token
- Head to https://discord.com/developers/ and create a bot
- Obtain your Token
- Invite the bot to your server.
- Run the script with
python3 discord-bot.py -S <IP/Domain>
- Your bot should now be online and display a player count.
- Sends a request to the
players.json
endpoint which is found on pretty much every FiveM Server - Parses the JSON array which is returned in the request
- Iterates though all of the
name
keys - Returns the total count of players which are currently online
- Updates the bots status with how many players are online
I couldn't really find a simple script that could do as i wanted without too much hassle. A lot of the scripts i found online were written using NodeJS and required some setup so decided to write my own. It's a bit 'hacky' but it does the job!