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
- 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
- Paste the copied token in the
BOT_TOKEN
field of theconstants.json
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 theconstants.json
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 theconstants.json
file 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_KEY
field inconstants.json
. - Put your challonge username in the
CHALLONGE_USERNAME
field 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 Fernet
Fernet.generate_key()
- Copy the generated key and paste it in the
ENCRYPTION_KEY
field 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
ExecStart
with the path to thetosurnament.sh
script. - Start the service with
sudo systemctl start tosurnament
, wheretosurnament
is the name of your service file (without the.service
extension).