You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pydis_site/apps/content/resources/guides/pydis-guides/contributing.md
+1-5Lines changed: 1 addition & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,11 +94,7 @@ GitHub is a website based on Git that stores project files in the cloud. We use
94
94
95
95
*Note: Members of the Python Discord staff can create feature branches directly on the repo without forking it.*
96
96
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/).
102
98
103
99
### 2. Set up the project
104
100
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:
Copy file name to clipboardExpand all lines: pydis_site/apps/content/resources/guides/pydis-guides/contributing/bot.md
+50-84Lines changed: 50 additions & 84 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,131 +4,95 @@ description: A guide to setting up and configuring Bot.
4
4
icon: fab fa-github
5
5
toc: 3
6
6
---
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.
11
9
12
10
---
13
11
## Setting up the project
14
12
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.
<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.
-[Python 3.14](https://www.python.org/downloads/). This can be installed [using uv](https://docs.astral.sh/uv/guides/install-python/#installing-python).
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
+
```
42
34
43
35
### 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.
46
38
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.
48
41
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.
52
43
53
44
### Set Up a Bot Account
54
45
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.
56
47
57
-
#### Privileged Intents
48
+
If you want to use an existing test bot account, ensure that:
58
49
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.
67
52
68
53
### 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.
70
54
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.
72
56
73
57
#### .env
74
-
This file will contain sensitive information such as your bot's token, do not share it with anybody!
75
58
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.
77
60
78
61
```text
79
62
BOT_TOKEN=YourDiscordBotTokenHere
80
63
GUILD_ID=YourDiscordTestServerIdHere
81
-
BOT_PREFIX=YourDesiredPrefixHere
82
64
```
83
65
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.
84
66
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.
86
68
87
69
#### .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.
89
70
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.
92
73
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:
98
75
```shell
99
76
$ uv run task configure
100
77
```
101
78
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 }
104
81
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.
<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.
124
87
88
+
---
125
89
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).
129
91
92
+
### Run it!
93
+
You are now ready to run the bot. The simplest way to do so is with Docker.
130
94
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!
132
96
133
97
Some other useful docker commands are as follows:
134
98
@@ -139,6 +103,8 @@ Your bot is now running, all inside Docker.
139
103
140
104
**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).
141
105
106
+
If you encounter issues with docker, check out our [docker guide](../docker), which lists some common issues and their solutions.
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.
Copy file name to clipboardExpand all lines: pydis_site/apps/content/resources/guides/pydis-guides/contributing/docker.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ icon: fab fa-docker
5
5
toc: 2
6
6
---
7
7
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 DockerCompose during development in order to provide an easy to setup and consistent development environment.
9
9
10
10
Consider reading some of the following topics if you're interested in learning more about Docker itself:
11
11
@@ -15,12 +15,12 @@ Consider reading some of the following topics if you're interested in learning m
15
15
16
16
# Docker Installation
17
17
You can find installation guides available for your respective OS from the official Docker documentation:
0 commit comments