Getting Started¶
Follow this guide to learn how to set up the project, add changes, test, and merge your changes.
Prerequisites¶
Installation¶
Step 1¶
If you are not in the GitHub organization (uwaterloo-tron):
- Fork the discord-bot repository to your GitHub account using the "fork" button on the top-right of the
project repo page. Then clone it using one of the following commands:
# For HTTPS git clone https://github.com/YOUR_GITHUB_USERNAME/discord-bot.git && cd discord-bot # For SSH git clone git@github.com:YOUR_GITHUB_USERNAME/discord-bot.git && cd discord-bot
If you are in the GitHub organization:
- Clone the project repo directly using one of the following commands:
# For HTTPS git clone https://github.com/uwaterloo-tron/discord-bot.git && cd discord-bot # For SSH git clone git@github.com:uwaterloo-tron/discord-bot.git && cd discord-bot
NOTE:
If you would like to become a member of the organization, raise an issue asking for an invitation with your Discord ID (e.g.
@username#1234
), or send a DM to@Roton#5439
on Discord including your GitHub username.We will also send you an invitation to the organization if you make any contributions.
Step 2¶
Create a new branch for development:
git checkout -b "BRANCH-NAME"
Step 3¶
Run the following command in the project directory:
poetry install
Development¶
Check out the discord.py docs for help. Here are some useful pages:
- Commands
(functions that activate via
<prefix>command-name
, e.g.?=help
) - Tasks (functions which automatically run every set period of time)
- Event listeners (functions which run on specific Discord events, e.g. when joining a guild)
Please read through the code conventions before you start
If you modify the docs or database in your changes, read through their respective convention pages as well:
Testing¶
-
Create a file named
.env
in the project directory. Inside the file, add the following lines:DISCORD_TOKEN=[paste token here] STAGE=[your stage (optional)] LOG_LEVEL=[desired log level (optional)]
Note: Don't include the square brackets
- Where you can get your token
- Which stage you should use
-
LOG_LEVEL
must be one of the following:CRITICAL
,ERROR
,WARNING
(default),INFO
,DEBUG
-
Start the bot and database with the following command:
docker-compose up --build -d
- If you make any changes, run this command again to update the container
- If you ever want to wipe the database, run this command:
WARNING: this cannot be undone
docker-compose down -v && docker-compose up --build -d
-
When you are done, tear down by running the following command:
docker-compose down
- Recommended: remove all dangling images (previous versions):
docker image prune -f
- Recommended: remove all dangling images (previous versions):
Creating a Pull Request¶
Here's how you can add your changes to the production server for the bot.
Steps¶
-
Make sure your changes follow the code conventions and database conventions
- Update the docs if necessary check here for more details
-
Commit and push your changes
- See this guide on how to write great commit messages
-
Open a pull request (PR) on the main project repo
That's all! Once your PR is approved, your changes will be automatically deployed to the production server.
If you're still confused, check out this guide.