Make sure you have Python 3.6+ and virtualenv (pip install virtualenv
)
- Clone the repo
- Go into the newly cloned repo using a CLI
- Create a python virtual environment using
python3 -m virtualenv env
- Load the virtual environment by using
source env/bin/activate
(for Windows mans, useC:\<path_to_botdiff>\env\Scripts\activate.bat
) - Finally, install the dependencies by using
pip install -r requirements.txt
Setting up a Discord bot is important when testing features.
For more information, go check out the offical Discord dev docs
You will need to get your own API tokens from Riot. These dev tokens refresh every 24 hours.
To get your own token, go to Riot's dev pages
With this project, API tokens are needed to communicate with both Discord API and Riot API.
To handle these tokens, we store the files in a .env
file (is coved by .gitignore).
Here are the token names we use:
DISCORD_TOKEN
- This is where the Discord API token will be stored(ATM This is not used, can be ignored)DISCORD_GUILD
- This is where the Discord GUILD will be storedRIOT_TOKEN
- This is where the Riot API token will be stored
You will need to create this file yourself (in root) and paste your own tokens.
Before making any changes to the code, you must create your own branch/fork.
For the sake of continuity, branches should follow this specific format: <name>-<main_changes>
For example: chetan-cool-new-feature
With the structure of this repo, we want to make sure logic isn't bloating main.py
.
To do this, we are following a file structure that puts logic away in another file.
This logic is then called when running the command.
To follow this structure, do the following:
- In
main.py
create an async function with the following format:
@bot.command()
async def <name>(ctx):
await ctx.send(<name>_command())
- Place
<name>_command()
infunctions/<name>.py
- Import this file into
main.py
by usingfrom functions.<name> import <name>_command
- Test the function/bot by running
python3 main.py
- Use
snake_case
for variables and function names - Use
PascalCase
for class names
git checkout -b "<branch name>"
- Creates a branch from your current branchgit status
- Checks the status of changesgit add .
- Adds all changes/filesgit commit -m "<Message>"
- Creates a commit (ORgit commit
to open vim like a l33t chad :3)git push
- Pushes the branch to GitHub
git checkout main
- Switches your branch to maingit pull
- Pulls the most recent code from maingit checkout <branch name>
- Switches back to the branch you are working on/want to rebasegit rebase main
- Starts the rebasing with main, conflicts might occur just solve them with your IDEgit push -f
- Force pushes your branch to origin, ready for PR
git checkout <branch name>
- Swaps to a branch (doesn't create one)git fetch
- Notes any differences between local and origin
This project could not be possible without the help of opensource projects.
Here's the main projects that we use:
- Discord.py - The Python wrapper for Discord API
- Riot Watcher - The Python wrapper for Riot API
- python-dotenv - Handles the tokens