Skip to content

Commit c0e69e6

Browse files
committed
Refactor bot contributing docs
1 parent a6a0538 commit c0e69e6

13 files changed

Lines changed: 160 additions & 271 deletions

pydis_site/apps/content/resources/guides/pydis-guides/contributing.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ GitHub is a website based on Git that stores project files in the cloud. We use
9494

9595
*Note: Members of the Python Discord staff can create feature branches directly on the repo without forking it.*
9696

97-
Check out our [**guide on forking a GitHub repo**](./forking-repository/).
98-
99-
Now that you have your own fork you need to be able to make changes to the code. You can clone the repo to your local machine, commit changes to it there, then push those changes to GitHub.
100-
101-
Check out our [**guide on cloning a GitHub repo**](./cloning-repository/).
97+
Check out our [**guide on forking and cloning a GitHub repository**](./forking-and-cloning/).
10298

10399
### 2. Set up the project
104100
You have the source code on your local computer, now how do you actually run it? We have detailed guides on setting up the environment for each of our main projects:

pydis_site/apps/content/resources/guides/pydis-guides/contributing/bot.md

Lines changed: 50 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -4,131 +4,95 @@ description: A guide to setting up and configuring Bot.
44
icon: fab fa-github
55
toc: 3
66
---
7-
The purpose of this guide is to get you a running local version of [the Python bot](https://github.com/python-discord/bot).
8-
You should have already forked the repository and cloned it to your local machine. If not, check out our [detailed walkthrough](../#1-fork-and-clone-the-repo).
9-
10-
This page will focus on the quickest steps one can take, with mentions of alternatives afterwards.
7+
This guide will walk you through setting up and running [the Python bot](https://github.com/python-discord/bot) locally,
8+
and get you ready to contribute to it.
119

1210
---
1311
## Setting up the project
1412

15-
### Setup Project Dependencies
16-
Below are the dependencies you **must** have installed to get started with the bot.
17-
18-
1. Make sure you have [Python 3.14](https://www.python.org/downloads/) installed. uv [can also be used to](https://docs.astral.sh/uv/guides/install-python/#installing-python) install Python, if desired.
19-
2. [Install uv](https://github.com/astral-sh/uv#installation).
20-
3. [Install the project's dependencies](../installing-project-dependencies).
21-
4. Docker.
22-
23-
<div class="card">
24-
<button type="button" class="card-header collapsible">
25-
<span class="card-header-title subtitle is-6 my-2 ml-2">Getting started with Docker</span>
26-
<span class="card-header-icon">
27-
<i class="fas fa-fw fa-angle-down title is-5" aria-hidden="true"></i>
28-
</span>
29-
</button>
30-
<div class="collapsible-content collapsed">
31-
<div class="card-content">
32-
The requirements for Docker are:
33-
<ul>
34-
<li><a href="https://docs.docker.com/install">Docker CE</a></li>
35-
<li>Docker Compose. If you're using macOS and Windows, this already comes bundled with the previous installation. Otherwise, you can download it either from the <a href="https://docs.docker.com/compose/install">website</a>, or by running <code>pip install docker-compose</code>.</li>
36-
</ul>
37-
<p class="notification is-warning">If you get any Docker related errors, reference the <a href="../docker#possible-issues">Possible Issue</a> section of the Docker page.</p>
38-
</div>
39-
</div>
40-
</div>
41-
<br>
13+
### Install Project Requirements
14+
The following are needed to run the bot. Follow the links for installation instructions.
15+
16+
- [uv](https://docs.astral.sh/uv/getting-started/installation/).
17+
- [Python 3.14](https://www.python.org/downloads/). This can be installed [using uv](https://docs.astral.sh/uv/guides/install-python/#installing-python).
18+
- [Docker](https://docs.docker.com/get-started/get-docker/).
19+
20+
### Set Up a Development Environment
21+
22+
To start, ensure you have forked and cloned the [bot repository](https://github.com/python-discord/bot) to your local machine. For help with this, check out our [forking and cloning guide](../forking-and-cloning).
23+
24+
From the root of the cloned repository, run the following command to install the project dependencies:
25+
26+
```shell
27+
$ uv sync
28+
```
29+
30+
You should also install our pre-commit hooks, which will lint your code before you commit it.
31+
```shell
32+
$ uv run task precommit
33+
```
4234

4335
### Set Up a Test Server
44-
The Python bot is tightly coupled with the Python Discord server, so to have a functional version of the bot you need a server with channels it can use.
45-
It's possible to set the bot to use a single channel for all cogs, but that will cause extreme spam and will be difficult to work with.
36+
The Python bot is tightly coupled with the Python Discord server, so the bot expects the existence of certain
37+
channels, roles, and other server configurations to be able to run.
4638

47-
You can start your own server and set up channels as you see fit, but for your convenience we have a template for a development server you can use: [https://discord.new/zmHtscpYN9E3](https://discord.new/zmHtscpYN9E3).
39+
It is highly recommended to use our [server template](https://discord.new/zmHtscpYN9E3),
40+
as it allows most configuration to be automatically generated for you.
4841

49-
Keep in mind that this is not an exact mirror of the Python server, but a reduced version for testing purposes.
50-
The channels there are mostly the ones needed by the bot.
51-
---
42+
This is not an exact mirror of the Python server, but a reduced version for testing purposes.
5243

5344
### Set Up a Bot Account
5445
You will need your own bot account on Discord to test your changes to the bot.
55-
See [here](../creating-bot-account) for help with setting up a bot account. Once you have a bot account, invite it to the test server you created in the previous section.
46+
See [our guide](../creating-bot-account) for help with setting up a bot account, and inviting it to your server.
5647

57-
#### Privileged Intents
48+
If you want to use an existing test bot account, ensure that:
5849

59-
It is necessary to explicitly request that your Discord bot receives certain gateway events.
60-
The Python bot requires `Server Member Intent` and `Message Content Intent` to function.
61-
In order to enable it, visit the [Developer Portal](https://discord.com/developers/applications/) (from where you copied your bot's login token) and scroll down to the `Privileged Gateway Intents` section.
62-
The `Presence Intent` is not necessary and can be left disabled.
63-
64-
If your bot fails to start with a `PrivilegedIntentsRequired` exception, this indicates that the required intents were not enabled.
65-
66-
---
50+
- It has the `Server Members Intent` and `Message Content Intent` intents enabled.
51+
- It was invited to your server with the `bot` scope and `Administrator` permission.
6752

6853
### Configure the Bot
69-
You now have both the bot's code and a server to run it on. It's time for you to connect the two by setting the bot's configuration.
7054

71-
Both `.env` and `.env.server` files we talk about below are ignored by git, so they do not get accidentally commit to the repository.
55+
The bot reads variables for configuration from two files, `.env`, and `.env.server`. These files are ignored by git, as they contain information specific to your local environment.
7256

7357
#### .env
74-
This file will contain sensitive information such as your bot's token, do not share it with anybody!
7558

76-
To start, create a `.env` file in the project root with the below content.
59+
Create a file called `.env` in the project root with the below content, and insert your bot token and guild ID. Remember that your bot token is sensitive information, and should not be shared with anyone.
7760

7861
```text
7962
BOT_TOKEN=YourDiscordBotTokenHere
8063
GUILD_ID=YourDiscordTestServerIdHere
81-
BOT_PREFIX=YourDesiredPrefixHere
8264
```
8365
See [here](../creating-bot-account) for help with obtaining the bot token, and [here](../obtaining-discord-ids#guild-id) for help with obtaining the guild's ID.
8466

85-
Other values will be added to your `.env` over time as you need to interact with other parts of the bot, but those are not needed for a basic setup. For a full list of support values see the ENV file option [appendix](#appendix-full-env-file-options)
67+
This is all that is needed for a basic setup. See the [appendix](#appendix-full-env-file-options) for a full list of available variables.
8668

8769
#### .env.server
88-
All server related configuration values are saved in this file, which also needs to be at the root directory of the project.
8970

90-
We provide a script to automatically generate a server config.
91-
**Note**: The script **only** works with servers created with the template mentioned above.
71+
This file is automatically generated by our bootstrap script, which connects
72+
to your server and extracts configuration needed for the bot to run.
9273

93-
If you want to setup the bot from an existing guild read out [manual configuration guide](../bot-extended-configuration-options#manual-constants-configuration). This is far more complicated and time consuming.
94-
95-
Running the below command will use the `BOT_TOKEN` and `GUILD_ID` from the `.env` file you created above to download all of the relevant IDs from the template guild into your `.env.server`
96-
97-
**Note**: This script will overwrite the `.env.server` file. We suggest you put any configuration not generated by this script in to `.env` instead
74+
To run the script, execute the following command in the project root:
9875
```shell
9976
$ uv run task configure
10077
```
10178

102-
Once the script has finished running, you'll notice the creation of a new file called `.env.server` at your project's root directory.
103-
This file will contain the extracted IDs from your server which are necessary for your bot to run.
79+
**Note**: The script only works with servers created with the template mentioned above. To configure the bot manually, see our [manual configuration guide](../bot-extended-configuration-options#manual-constants-configuration).
80+
{: .notification }
10481

105-
**Congratulations**, you have finished the configuration and can now [run your bot](#run-it).
82+
**Note**: This script will overwrite the `.env.server` file. We suggest you put any configuration not generated by this script in to `.env` instead.
83+
{: .notification }
10684

10785

108-
<div class="card">
109-
<button type="button" class="card-header collapsible">
110-
<span class="card-header-title subtitle is-6 my-2 ml-2">Why do you need a separate config file?</span>
111-
<span class="card-header-icon">
112-
<i class="fas fa-fw fa-angle-down title is-5" aria-hidden="true"></i>
113-
</span>
114-
</button>
115-
<div class="collapsible-content collapsed">
116-
<div class="card-content">
117-
While it's technically possible to edit the values in <code>constants.py</code> to match your server, it is heavily discouraged.
118-
This file's purpose is to provide the configurations the Python bot needs to run in the Python server in production, and should remain as such.
119-
In contrast, the <code>.env.server</code> file can remain in your local copy of the code, and will be ignored by commits via the project's <code>.gitignore</code>.
120-
</div>
121-
</div>
122-
</div>
123-
<br>
86+
Ensure that this runs successfully, and that the `.env.server` file is created in the project root.
12487

88+
---
12589

126-
### Run it!
127-
#### With Docker
128-
You are now almost ready to run the Python bot. The simplest way to do so is with Docker.
90+
**Congratulations**, you have finished the configuration and can now [run your bot](#run-it).
12991

92+
### Run it!
93+
You are now ready to run the bot. The simplest way to do so is with Docker.
13094

131-
With all of the above setup, you can run the project with `docker compose up`. This will start the bot and all required services! Enter your server and type `!help` (or whatever prefix you chose instead of `!`) to see the bot in action!
95+
Start the project by running the command `docker compose up`. This will start the bot and all required services! Enter your server and type `!help` to see the bot in action!
13296

13397
Some other useful docker commands are as follows:
13498

@@ -139,6 +103,8 @@ Your bot is now running, all inside Docker.
139103

140104
**Note**: If you want to read about how to make debugging with an IDE a easier, or for additional running methods, check out our [extended configuration guide](../bot-extended-configuration-options).
141105

106+
If you encounter issues with docker, check out our [docker guide](../docker), which lists some common issues and their solutions.
107+
142108
---
143109

144110
## Development Tips

pydis_site/apps/content/resources/guides/pydis-guides/contributing/cloning-repository.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

pydis_site/apps/content/resources/guides/pydis-guides/contributing/creating-bot-account.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ title: Setting up a Bot Account
33
description: How to set up a bot account.
44
icon: fab fa-discord
55
---
6-
1. Go to the [Discord Developers Portal](https://discordapp.com/developers/applications/).
7-
2. Click on the `New Application` button, enter your desired bot name, and click `Create`.
8-
3. In your new application, go to the `Bot` tab, click `Add Bot`, and confirm `Yes, do it!`
9-
4. Change your bot's `Public Bot` setting off so only you can invite it, save, and then get your **Bot Token** with the `Copy` button.
10-
> **Note:** **DO NOT** post your bot token anywhere public. If you do it can and will be compromised.
11-
5. Save your **Bot Token** somewhere safe to use in the project settings later.
12-
6. In the `General Information` tab, grab the **Application ID**.
13-
7. Replace `<APPLICATION_ID_HERE>` in the following URL and visit it in the browser to invite your bot to your new test server.
14-
```plaintext
15-
https://discordapp.com/api/oauth2/authorize?client_id=<APPLICATION_ID_HERE>&permissions=8&scope=bot
16-
```
17-
Optionally, you can generate your own invite url in the `OAuth` tab, after selecting `bot` as the scope.
6+
1. Go to the [Discord Developers Portal](https://discord.com/developers/applications).
7+
1. Click on the `New Application` button, enter your desired bot name, and click `Create`.
8+
1. In the `Installation` tab, set `Install Link` to `None` and click `Save Changes`.
9+
1. In the `Bot` tab:
10+
11+
- Turn off the `Public Bot` setting.
12+
- Turn on the `Message Content Intent` setting.
13+
- If setting up Python Bot, also turn on the `Server Members Intent` setting.
14+
- ...and click `Save Changes`.
15+
16+
1. Click the `Reset Token` button and then `Copy` the generated token. Save it somewhere safe, as you will need it later.
17+
18+
**Note**: Do not post this token anywhere public, as it grants complete control of your bot.
19+
{: .notification .is-warning }
20+
21+
1. In the `OAuth2` tab, select the `bot` scope and `Administrator` permission, and visit the generated URL in your Discord app or browser to invite the bot to your server.

pydis_site/apps/content/resources/guides/pydis-guides/contributing/docker.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ icon: fab fa-docker
55
toc: 2
66
---
77

8-
Both our [Site](../site/) and [Bot](../bot/) projects use Docker and Docker-Compose during development in order to provide an easy to setup and consistent development environment.
8+
Both our [Site](../site/) and [Bot](../bot/) projects use Docker and Docker Compose during development in order to provide an easy to setup and consistent development environment.
99

1010
Consider reading some of the following topics if you're interested in learning more about Docker itself:
1111

@@ -15,12 +15,12 @@ Consider reading some of the following topics if you're interested in learning m
1515

1616
# Docker Installation
1717
You can find installation guides available for your respective OS from the official Docker documentation:
18-
[https://docs.docker.com/install/](https://docs.docker.com/install/)
18+
[https://docs.docker.com/get-started/get-docker/](https://docs.docker.com/get-started/get-docker/)
1919

2020
## After Installing on Linux
2121
If you're on Linux, there's a few extra things you should do:
2222

23-
1. [**Add your user to the `docker` user group so you don't have to use `sudo` when running docker or docker-compose.**](#add-user-group)
23+
1. [**Add your user to the `docker` user group so you don't have to use `sudo` when running docker**](#add-user-group)
2424
2. [**Start up the Docker service.**](#run-the-service)
2525
3. [**Set the Docker service to start on boot.**](#start-on-boot) **(optional)**
2626

@@ -67,7 +67,7 @@ Remove the existing `~/.docker/` directory. It will be automatically re-created
6767
6868
### Drive has not been shared (Windows users)
6969
70-
When attempting to run the `docker-compose up` command on a Windows machine, you receive the following or similar error message:
70+
When attempting to run the `docker compose up` command on a Windows machine, you receive the following or similar error message:
7171
```text
7272
ERROR: for bot_bot_1 Cannot create container for service bot: b'Drive has not been shared'
7373
```
@@ -85,7 +85,7 @@ Windows has not been configured to share drives with Docker.
8585
8686
3. Click "Apply" and enter appropriate Windows credentials (likely just your own account, if you have administrative privileges).
8787
88-
4. Re-run the `docker-compose up` command.
88+
4. Re-run the `docker compose up` command.
8989
9090
### Issues running on Apple Silicon
9191
@@ -104,8 +104,8 @@ DOCKER_DEFAULT_PLATFORM=linux/amd64
104104
```
105105
106106
# Compose Project Names
107-
When you launch services from a docker-compose, you'll notice the name of the containers aren't just the service name.
108-
You'll see this when launching your compose, as well as being able to be seen in the command `docker-compose ps` which will list the containers.
107+
When you launch services using Docker Compose, you'll notice the name of the containers aren't just the service name.
108+
You'll see this when launching your compose, as well as being able to be seen in the command `docker compose ps` which will list the containers.
109109
It should match something like this:
110110
```
111111
site_site_1

0 commit comments

Comments
 (0)