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: docs/webgroup/blockbot.md
+50-14
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,10 @@ All bot files are under `src/`.
24
24
- Contains example extensions with commands, components and more as reference for developers.
25
25
-`config.py`
26
26
- Configuration secrets and important constants (such as identifiers) are stored here. The secrets are loaded from environment variables, so you can set them in your shell or in a `.env` file.
27
+
-`database.py`
28
+
- Contains database configuration and models. Uses [SQLAlchemy](https://www.sqlalchemy.org/)
29
+
-`hooks.py`
30
+
- Contains command hooks - functions which run before command invocation to determine whether or not the command should actually be run (e.g. permissions check).
27
31
-`utils.py`
28
32
- Utility functions are stored here, that can be reused across the codebase.
29
33
@@ -43,20 +47,22 @@ As a prerequisite, you need to have an application registered on the Discord dev
43
47
#### Bot Token
44
48
45
49
1. Open the application on the Discord developer portal.
46
-
2. Go to *"Bot"* on the left sidebar, click `Reset Token`.
50
+
2. Go to *"Bot"* on the left sidebar and click `Reset Token`.
47
51
3. Copy the newly generated token.
48
52
49
53
### Running from source (deprecated)
50
54
55
+
Blockbot uses [`uv`](https://docs.astral.sh/uv/) to manage dependencies and run the project.
56
+
51
57
1. Fork, `git clone` and `cd` into the [blockbot repository](https://github.com/redbrick/blockbot).
52
58
53
59
> [!TIP]
54
60
> Read the [contributing docs](./contributing.md) for more information on using Git and GitHub.
55
61
56
-
2. It is generally advised to work in a Python [virtual environment](https://docs.python.org/3/library/venv.html):
62
+
2. It is generally advised to work in a Python [virtual environment](https://docs.astral.sh/uv/reference/cli/#uv-venv):
57
63
58
64
```sh
59
-
python3 -m venv .venv
65
+
uv venv
60
66
source .venv/bin/activate
61
67
```
62
68
@@ -66,8 +72,11 @@ As a prerequisite, you need to have an application registered on the Discord dev
66
72
TOKEN=<Discord bot token here>
67
73
```
68
74
69
-
4. Run `pip install -r requirements.txt` to install the required packages.
70
-
5. Start the bot by running `python3 -m src`.
75
+
4. Run `uv sync --frozen` to install the required packages.
76
+
5. Start the bot by running `uv run -m src`.
77
+
78
+
> [!NOTE]
79
+
> Currently a valid database connection is required for the bot to start. Therefore we recommend running Blockbot with docker compose (the compose file includes a PostgreSQL service).
71
80
72
81
### Running with Docker Compose
73
82
@@ -83,16 +92,44 @@ As a prerequisite, you need to have an application registered on the Discord dev
83
92
TOKEN=<Discord bot token here>
84
93
```
85
94
86
-
3. Run the `compose.yaml` file: `docker compose up --build`
95
+
3. Run the bot: `docker compose up --build bot`
96
+
This will also start the database.
87
97
88
-
## Library Resources
98
+
### Contributing Tools
99
+
100
+
Blockbot adheres to various code styling and typing rules (listed under `[tool.ruff.format]` and `[tool.ruff.lint]`in`pyproject.toml`).
101
+
To make sure you're following these rules when developing Blockbot, we use [`nox`](https://nox.thea.codes/en/stable/index.html).
102
+
103
+
`nox` is configured in a `noxfile.py` file, located [here](https://github.com/redbrick/blockbot/blob/main/noxfile.py) for Blockbot.
0 commit comments