Discord bot to help in Discord/spreadsheet relationships
You can check out the tutorial to know how to setup the Tosurnament Bot in your Discord server.
You can also check the commands directly if you are an experienced user.
First, you need to clone the repository. Then, in the folder backend/bot/replies
, you will see multiple subfolders with en.json
file in them. You need to copy this file in the same folder, rename it to the language code in the language you want to translate (fr.json
for French for example). Now you only need to translate every entries, but beware of:
- entries containing
$
, you must not modify the path name to another language (example:$./no_staff_notification Some other text
,$./no_staff_notification
must not be changed, but what is after should be changed) - entries containing
%
, you must not modify the number following them After you're done translating, just open a Pull Request in this repo and I will check it.
Prerequisite:
- Linux on where you want to host the bot (server or on your personal computer)
- mysql/mariadb installed
- python3.8 or later installed
- Docker compose
- Clone the repo =)
- Go to the discord developer portal
- Click the
New Application
button and fill the form
- After selecting the newly created application, click the
Bot
tab in the left - Click the
Copy
button belowTOKEN
. You might need to click theReset Token
button first. - Paste the copied token in the
BOT_TOKEN
field of the.env.production.secret
file present in the repository
- This can be a little annoying to get, but you need to go to https://osu.ppy.sh/p/api/, login, then close the tab, copy paste the url in the adress bar, and do Shift+ENTER, it should lead you to the correct page and here you can generate/get your osu api key.
- Paste the copied api key in the
OSU_API_KEY
field of the.env.production.secret
file present in the repository
- Activate developer mode in discord if not already done:
Settings -> Appearance -> Advanced -> Developer Mode
- Right-click on your name in any channel and click
Copy ID
- Paste the copied id in the
BOT_OWNER_ID
field of the.env
file present in the repository
You can set the bot prefix to anything you want by changing the COMMAND_PREFIX
field in .env.production.secret
.
Change the MYSQL_USER
and MYSQL_PASSWORD
to anything you want in .env.production.secret
. You don't need to create the user, it will be created automatically by the setup.sh
script.
- Go to https://challonge.com/settings/developer and copy your API key.
- Paste the copied id in the
CHALLONGE_API_KEY
field in.env.production.secret
. - Put your challonge username in the
CHALLONGE_USERNAME
field in.env.production.secret
.
Go to the root of the repository and do ./setup.sh
. It will install all the required python dependencies and setup the database.
To get an encryption key you need to:
- Open a python shell (
python3
) from cryptography.fernet import Fernet
Fernet.generate_key()
- Copy the generated key and paste it in the
ENCRYPTION_KEY
field in.env.production.secret
.
- Go to the discord developer portal
- Select your bot application and click
OAuth2
on the left - Copy your
CLIENT ID
and paste it in theDISCORD_CLIENT_ID
field in.env.production.secret
- Click
Reset Secret
and copy and paste it in theDISCORD_CLIENT_SECRET
field in.env.production.secret
- Add your redirect uri, it must be your dashboard url followed by
/redirect
. For example:https://mydashboard.com/redirect
Copy it and paste it in theTOSURNAMENT_DASHBOARD_URI
field in.env.production
TODO
- In your Caddyfile (
/etc/caddy/Caddyfile
usually), add the following lines:
my.api.url {
handle {
reverse_proxy * http://localhost:5001
}
}
my.dashboard.url {
handle {
reverse_proxy * http://localhost:3000
}
}
- Change the urls to use your domain
- Use
caddy reload
This part is TODO.
For now, you can start the docker with docker compose build
, then docker compose up
.
If the db is unhealthy at first start, you can do docker compose down
then docker compose up
again.
- Create a new service file. For exmaple:
/etc/systemd/system/tosurnament.service
- Fill the file with:
[Unit]
Description=Tosurnament api
[Service]
WorkingDirectory=/path/to/dir/tosurnament
ExecStart=TODO
Restart=always
[Install]
WantedBy=multi-user.target
- Modify
WorkingDirectory
with the path to thetosurnament
directory. - Start the service with
sudo systemctl start tosurnament
, wheretosurnament
is the name of your service file (without the.service
extension).