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_notificationmust 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
- Clone the repo =)
- Go to the discord developer portal
- Click the
New Applicationbutton and fill the form
- After selecting the newly created application, click the
Bottab in the left - Click the
Copybutton belowTOKEN - Paste the copied token in the
BOT_TOKENfield of theconstants.jsonfile 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_KEYfield of theconstants.jsonfile 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_IDfield of theconstants.jsonfile present in the repository
You can set the bot prefix to anything you want by changing the COMMAND_PREFIX field in constants.json.
Change the DB_USERNAME and DB_PASSWORD to anything you want in constants.json. 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_KEYfield inconstants.json. - Put your challonge username in the
CHALLONGE_USERNAMEfield inconstants.json.
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 FernetFernet.generate_key()- Copy the generated key and paste it in the
ENCRYPTION_KEYfield inconstants.json.
You have 2 options to start the bot: create a service or use the script.
Still, the better option is the service, as it will restart even if the script gets killed.
Just use the tosurnament.sh script at the root of the repository.
- Create a new service file. For example:
/etc/systemd/system/tosurnament.service. - Fill the file with:
[Unit]
Description=Tosurnament bot service
After=mysqld.service
StartLimitIntervalSec=0
[Service]
Restart=always
RestartSec=1
ExecStart=/path/to/tosurnament.sh
[Install]
WantedBy=multi-user.target
- Modify
ExecStartwith the path to thetosurnament.shscript. - Start the service with
sudo systemctl start tosurnament, wheretosurnamentis the name of your service file (without the.serviceextension).