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
+56-20Lines changed: 56 additions & 20 deletions
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,39 @@ 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
53
+
### Running with Docker Compose (recommended)
54
+
55
+
1. Fork, `git clone` and `cd` into the [blockbot repository](https://github.com/redbrick/blockbot).
56
+
57
+
> [!TIP]
58
+
> Read the [contributing docs](./contributing.md) for more information on using Git and GitHub.
59
+
60
+
61
+
2. Rename `.env.sample` to `.env` inside the repo folder and fill in the environment variables with your secrets. e.g.:
62
+
63
+
```
64
+
TOKEN=<Discord bot token here>
65
+
```
66
+
67
+
3. Run the bot: `docker compose up --build bot`
68
+
This will also start the database.
69
+
49
70
### Running from source (deprecated)
50
71
72
+
Blockbot uses [`uv`](https://docs.astral.sh/uv/) to manage dependencies and run the project.
73
+
51
74
1. Fork, `git clone` and `cd` into the [blockbot repository](https://github.com/redbrick/blockbot).
52
75
53
76
> [!TIP]
54
77
> Read the [contributing docs](./contributing.md) for more information on using Git and GitHub.
55
78
56
-
2. It is generally advised to work in a Python [virtual environment](https://docs.python.org/3/library/venv.html):
79
+
2. It is generally advised to work in a Python [virtual environment](https://docs.astral.sh/uv/reference/cli/#uv-venv):
57
80
58
81
```sh
59
-
python3 -m venv .venv
82
+
uv venv
60
83
source .venv/bin/activate
61
84
```
62
85
@@ -66,33 +89,47 @@ As a prerequisite, you need to have an application registered on the Discord dev
66
89
TOKEN=<Discord bot token here>
67
90
```
68
91
69
-
4. Run `pip install -r requirements.txt` to install the required packages.
70
-
5. Start the bot by running `python3 -m src`.
92
+
4. Run `uv sync --frozen` to install the required packages.
93
+
5. Start the bot by running `uv run -m src`.
71
94
72
-
### Running with Docker Compose
95
+
> [!NOTE]
96
+
> 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).
73
97
74
-
1. Fork, `git clone` and `cd` into the [blockbot repository](https://github.com/redbrick/blockbot).
98
+
### Contributing Tools
75
99
76
-
> [!TIP]
77
-
> Read the [contributing docs](./contributing.md) for more information on using Git and GitHub.
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).
78
102
103
+
`nox` is configured in a `noxfile.py` file, located [here](https://github.com/redbrick/blockbot/blob/main/noxfile.py) for Blockbot.
79
104
80
-
2. Rename `.env.sample` to `.env` inside the repo folder and fill in the environment variables with your secrets. e.g.:
105
+
1. Install `nox`
81
106
107
+
```sh
108
+
uv sync --group nox --frozen
82
109
```
83
-
TOKEN=<Discord bot token here>
110
+
111
+
2. Run `nox`
112
+
113
+
```sh
114
+
uv run nox
84
115
```
85
116
86
-
3. Run the `compose.yaml` file: `docker compose up --build`
0 commit comments