Discord bot providing Fortnite-related functionalities to Discord server.
Credits and resources:
- Discord.py: https://discordpy.readthedocs.io/en/stable/index.html
- Fortnite IO API: https://fortniteapi.io/
Pulls the item shop via API, generates a summary image and posts it in Discord
Posts a summary containing all upcoming tournaments. Preferred regions and type of tournaments can be configured.
- Once a day (configurable), it can generate an image with the latest item shop content and post it in a given channel
- Every X (configurable) minutes, it checks whether a tourney is about to start and posts a reminder in a given channel if needed
You need to register your bot to Discord, and invite the bot to your Discord server. Follow the instructions from https://discordpy.readthedocs.io/en/stable/discord.html . Save the bot token somewhere, you will need it later.
This project uses the Fortniteio API. To be able to use it, you need to register here: https://fortniteapi.io/ . Save the api key somewhere, you will need it later.
python3 -m venv venv
. ./venv/bin/activate
pip install -r requirements.txt
This bot uses the python library imgkit
to convert html to images. It relies on the lightweight program wkhtmltopdf
to be installed. Instructions about how to install wkhtmltopdf
can be found here: https://pypi.org/project/imgkit/
You need to create a file called .env
at the root of this project. This is very important as this is where you can add the secret tokens and API keys, and configure further the bot.
Its content should look like:
DISCORD_TOKEN="SOME_TOKEN"
FORTNITE_IO_KEY="SOME_API_KEY"
SHOP_CHANNEL_ID="CHANNEL_ID_WHERE_UPDATES_WILL_BE_POSTED"
Check the file settings.py
for more configuration parameters. Look for lines containing os.getenv()
. ./venv/bin/activate
python -m fordibot.bot.py
docker-compose -f docker/docker-compose.yml up --build -d
This is what you need to do to enable the bot when your device boots. This has been tested on Raspberry Pi (Raspbian Buster 10).
cd /lib/systemd/system
sudo vi dns-ready.service
[Unit]
Description=Wait for DNS to come up using 'host'
After=nss-lookup.target
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'until host fortniteapi.io; do sleep 1; done'
[Install]
WantedBy=multi-user.target
cd /lib/systemd/system
sudo vi fordibot.service
[Unit]
Description=Fordibot discord bot
After=dns-ready.service
[Service]
Type=idle
# The three following lines may vary depending on your setup and where the code lives on your device
User=pi
ExecStart=/home/pi/fordibot/venv/bin/python -m fordibot.bot.py
WorkingDirectory=/home/pi/fordibot
[Install]
WantedBy=multi-user.target
sudo systemctl enable dns-ready --now
sudo systemctl enable fordibot --now