This is a Discord bot written in Python, with the purpose of helping our guild manage the scholars in our Discord server. The purpose of this bot is that it can be used for guilds with multiple scholars and different managers, who each have their own scholars and wallets.
To run this bot you need to host it yourself, meaning that you should have something that functions as a server. I use my Raspberry PI for this, but there are many other options available for hosting a Discord bot, such as virtual private servers provided by Google, Amazon, Microsoft, and more.
This bot was made with configurability in mind, meaning that every feature listed below can be turned on or off, and be changed easily. If you do not want a feature, just turn it off, all automation and listeners works for your custom roles and channels, so be sure to check out the settings in config_example.yaml and change them to your liking!
!announce
: Make announcements, using the bot as message sender. Usage!announce <#channel>
, followed by a next<text>
.!clear
: Clear a number of messages. Usage!clear <number>
, or!clear <number> <@user>
to clear messages of specific user.!encrypt
: Encrypt messages, necessary for encrypting private keys and storing them, using your personal uniquely generated encryption key. Usage!encrypt <message>
.!funds
: For managers to add their funds account address to the database. Usage!funds <ronin address>
.!help
: Custom written!help
command.!issue
: Make a new issue for this bot or any other public GitHub repository. Usage!issue <title>
followed by the description and labels. Needs your personal GitHub token to work, so this is disabled by default.!manager
: Scholars can request information about their manager using this command. Great if there are multiple managers in one server.!mute
/!unmute
: Mute and unmute specific users. Usage!mute <@user>
, this gives a user the 'mute' role.!mydata
: Scholar can request their up to date data, consisting of: in game slp, MMR, rank, payout day, and the number of days untill payout day.!price
: Request suggested prices for selling your axie. Usage!price <axie ID>
, gives maximum 4 different prices based on different criteria.!scholar
: Adds a scholar to the database of scholars. Usage!scholar <scholar_discord_name> <address> <split> <payout_address> <encrypted_key> <[manager]>
. See the example below of how the values should look like.!tryout
: Start tryouts, divides users with role 'tryout' in specific channels. More about this below.!qr
: Scholars can request their QR-code in a dedicated channel. The bot will send them a private message containing their QR-code for login.
In config_example.yaml this is also called 'Loops', you can customize each channel that these automated messages will get send in.
- Axie Alert: Automated alerts of axies specified in a Google Spreadsheet. More about this below.
- Axie Trades: Automated buy, sell and listing alerts of other managers.
- Clean Channel: The channel specified will get cleaned every x hours, useful if a channel is full with messages often.
- Instagram: If you have a Instagram account that you want server users to be aware of. This will send every new post in the dedicated channel.
- Leaderboard: Every 4 hours an updated leaderboard gets posted in the dedicated channel, showing the top performing scholars ranked by MMR.
- Prices: Every 4 hours the new SLP, AXS, ETH, and Axie floor prices get posted in the dedicated channel.
- SLP Warning: 1 hour before the daily reset scholars get mentioned if they have not yet completed all quests or are below 800 MMR.
This section is about the other type of automation, which is based on events.
- On Command: If a user uses a bot command it will get shown in the console.
- On Member Join: If a new user joins the server they will get a specific role, disabled by default.
- On Member Update:
- If a user gets the role 'scholar' then the bot will send them a video containing an explanation about how everything works.
- If a user gets the role 'tryout' then the bot will send them a video containing an explanation about how everything works.
- On Message: Deletes all messages in specific channel that are not send by the bot (by using the
!announcement
command). - On Raw Reaction Add:
- If you react using the 💎 emoji below an axie alert, you will be the only one able to view this axie.
- Users get the role 'verified' if the click the ✅ below an announcement.
- Translate: Automatically translates certain languages to another language based on your preferences. For instance from Tagalog to English, the translated messages will be send to a dedicated channel to remove clutter.
Tryouts are used to select a new scholar from a group of people (with the role 'tryout'). For each account that is available for a new scholar a new tryout group can be made, it is also possible to make less groups and pick the first and second best players. Currently we let every tryout play for 3 hours on the account and after all tryouts are done the best will be picked. This is done by selecting the tryout that had the best winrate. At the moment the API for that is offline, so after a tryout is done they should send screenshots of their match history.
The code for the !qr
command was inspired by ZracheSs | xyZ, check out their repo for the original code.
The required packages to run this code can be found in the requirements.txt
file. To run this file, execute the following code block:
$ pip install -r requirements.txt
Alternatively, you can install the required packages manually like this:
$ pip install <package>
This part is about creating the Discord bot, setting up the basics, and inviting it to your server. For the first part you can watch this video (watch until 2:20).
Or follow these written instructions:
- Setup your own Discord bot, following this written tutorial or this
- Give the bot admin rights and all permissions possible, since this is the easiest way to set it up.
- Invite the bot to your server.
Then you need to add the custom emojis to the server (can be skipped).
- Download the custom emoji pictures here.
- Add them to your server (instructions).
Last you need to fill in the important information in config_example.yaml
, so the bot knows which server it should be connected to.
- Open
config_example.yaml
- Write your bot token behind
TOKEN:
(line 2) - Write your server name behind
GUILD_NAME:
(line 3) - If you changed the custom emoji names, change them in the file too (line 37, 40, 41).
This part needs to be done and is a bit technical, so follow the steps carefully. Or follow the instructions from this (starts from 1:58) video
If you prefer written instructions follow the instructions below:
- Enable API access for the new project instructions.
- Creating the
authentication.json file
instructions.
After follow the instructions above, last things you need to do is this:
- Save your
authentication.json
file in the same folder as you saved the files for this bot. - Open
authentication.json
and copy the email behind"client_email":
- Open Google Drive and go to the folder that you want the bot to make the spreadsheets in, right click on that folder and press share
- Share the folder with the client email out of
authentication.json
Because no one likes to go through the process of making all the new channels, roles, and spreadsheets themselves I have written a script to do it for you. To run it you need to have followed the steps above, so you should have installed the dependencies, made the bot, and gave it access to your preferred Google Drive folder. If you have done all that you can execute the following code:
$ python src/setup.py
This will also rename config_example.yaml
to just config.yaml
so you do not need to worry about renaming that as well. The result will look like this:
So as the last step for the setup you need to copy your Fernet key to config.yaml
line 107, and after that is done you are ready for deploying the bot.
As you might have noticed the bot created a spreadsheet called Scholars. This spreadsheet functions as a database of your scholars. You can fill the values in by using the !scholar <scholar_discord_name> <address> <split> <payout_address> <encrypted_key> <[manager]>
command or by adding it manually to the sheet. The picture below shows how the values should look like.
As you might have noticed the bot also created a spreadsheet called Axie Alerts. This spreadsheet specifies the Axies that should be alerted in the server, for instance if they have a low price or good genes. Below an example is shown of how you can fill in this spreadsheet.
Example of an alert that the bot automatically sends:
- Clone the repository and install dependencies as specified above.
- Follow the steps mentioned in setup.
- Run
$ python src/main.py
- Copy the private key of the scholar you want to add to the database.
- Encrypt it by sending a private message to the bot using
!encrypt <private_key>
and use this in the step below. - Add a scholar using the
!scholar <scholar_discord_name> <address> <split> <payout_address> <encrypted_key> <[manager]>
command. - Add your funds address using
!funds <ronin_address>
so it can track your buys and sells. - Give your server users their dedicated roles.
- See the results.