Proxima Discord Bot
Proxima is a Remainder Application, like many others, which primarily uses Discord to deliver the remainders to the user.
It provides an API interface to be embedded in other services, using Bearer Token Authentication.
The Discord bot provides basic functionality for convenience to the user as well.
This is the source code for the discord bot.
The bot allows the user to manage (add, edit, remove, list) its own remainders on the installed servers.
This bot is intended to be run as a docker container, see below.
For more details, see: Proxima -> Discord Bot
Main Technologies used
- Based on commandstring/dphp-bot package
- PHP 8.2+
- composer
- ReactPHP
- discord-php/DiscordPHP
- team-reflex/discord-php
- Smarty
- and many more...
What is needed to run the bot
- A working docker instance with compose.
- A Discord account: Discord
- A Discord application: Discord Developer Portal
- A dedicated Discord server where the bot can send important notifications.
Running with Docker compose
Follow these easy steps to set up and your own bot:
NOTE: The program inside the container is running under a non-privileged user with
UID:1000andGID:1000.The storage folder must be writable for that user!
In the example, we just make it writable to everyone (please use proper access control instead!)
Or you can build your own image with different
UID/GIDvalues.
1. Create the directory structure (bash)
mkdir -p volumes/bot/{storage,env}
2. Update directory permissions to allow write access to the restricted docker user
This is for demonstration only, please use proper access control!
chmod o+w volumes/bot/storage
3. Create the .env file from src/.env.example file
wget -O volumes/bot/env/.env https://proxima.goliath.hu/proxima/discord-bot/raw/branch/main/src/.env.example
-OR-
curl -f -o volumes/bot/env/.env https://proxima.goliath.hu/proxima/discord-bot/raw/branch/main/src/.env.example
4. Customize the .env.config file
nano volumes/bot/env/.env
4.1 Fill in the bot application informations
-
Change the
APPLICATION_IDfor the discord bot application id.<YOUR_APPLICATION>->General Information->Application ID -
Change the
PUBLIC_KEYfor the discord bot public key.<YOUR_APPLICATION>->General Information->Public Key -
Change the
TOKENfor the discord bot token.<YOUR_APPLICATION>->Bot->Token
4.2 Fill in the bot home server informations
-
Change the
HOME_SERVER_IDfor dedicated discord server ID.see: Discord
NOTE: This can be used to manage the bot.
-
Change the
LOG_CHANNEL_IDfor dedicated channel on the discord server.see: Discord
NOTE: The system messages will be sent here.
4.3 Fill in the backend informations
-
Fill in the
API_URLfor backend api url.ex.:
http://<your_backand_address>/api/v1/NOTE: If it runs on localhost, teh address is:
http://backend:9000/api/v1/
4.3.1 Get the authentication token from the backend
-
Go visit the webpage backend
/adminpage and log in. -
Go to the your
Profilepage. -
Here you can change your
name,email,passwordat any time. hjfNdG68K2vbOrTn9bXVqDZBpNDER20rt5FRB1Sv2acd4353 -
Click on the
Craete Tokenbutton, and create an access token for theBot. -
You can name the token anything you want.
-
Make sure you check all the
Ablitiescheckboxes. -
You can set an expire date if you want or leave empty (the token will not expire).
-
Press
createand copy the newtokenand temporary save it. (If you lose it, you can always generate a new one, just delete the old now useless one).
4.3.2 Fill in the authentication token
- Fill in the
BACKEND_TOKENfor backend api token created by the 4.3.1 section.
5. Create the docker-compose.yaml file:
---
services:
discord-bot:
image: proxima.goliath.hu/proxima/discord-bot:latest
container_name: bot
volumes:
- "./volumes/bot/env/.env:/app/Bot/.env:ro"
- "./volumes/bot/storage:/app/Bot/Storage"
restart: unless-stopped
networks:
- proxima
networks:
proxima:
external: true
NOTE: the external network is only neded if the backend and bot are on the same host, so they can communicate by the hostname.
You can create the network with the following command:
docker network create proxima
6 Start up service
docker compose up -d

