Skip to content

Commit 41e94b0

Browse files
authored
Update blockbot docs (#50)
* update blockbot docs * move docker compose method up
1 parent af24120 commit 41e94b0

File tree

1 file changed

+56
-20
lines changed

1 file changed

+56
-20
lines changed

docs/webgroup/blockbot.md

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ All bot files are under `src/`.
2424
- Contains example extensions with commands, components and more as reference for developers.
2525
- `config.py`
2626
- 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).
2731
- `utils.py`
2832
- Utility functions are stored here, that can be reused across the codebase.
2933

@@ -43,20 +47,39 @@ As a prerequisite, you need to have an application registered on the Discord dev
4347
#### Bot Token
4448

4549
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`.
4751
3. Copy the newly generated token.
4852

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+
4970
### Running from source (deprecated)
5071
72+
Blockbot uses [`uv`](https://docs.astral.sh/uv/) to manage dependencies and run the project.
73+
5174
1. Fork, `git clone` and `cd` into the [blockbot repository](https://github.com/redbrick/blockbot).
5275
5376
> [!TIP]
5477
> Read the [contributing docs](./contributing.md) for more information on using Git and GitHub.
5578
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):
5780
5881
```sh
59-
python3 -m venv .venv
82+
uv venv
6083
source .venv/bin/activate
6184
```
6285
@@ -66,33 +89,47 @@ As a prerequisite, you need to have an application registered on the Discord dev
6689
TOKEN=<Discord bot token here>
6790
```
6891
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`.
7194
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).
7397
74-
1. Fork, `git clone` and `cd` into the [blockbot repository](https://github.com/redbrick/blockbot).
98+
### Contributing Tools
7599
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).
78102
103+
`nox` is configured in a `noxfile.py` file, located [here](https://github.com/redbrick/blockbot/blob/main/noxfile.py) for Blockbot.
79104
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`
81106
107+
```sh
108+
uv sync --group nox --frozen
82109
```
83-
TOKEN=<Discord bot token here>
110+
111+
2. Run `nox`
112+
113+
```sh
114+
uv run nox
84115
```
85116
86-
3. Run the `compose.yaml` file: `docker compose up --build`
117+
To run a specific session (e.g. `format_fix`):
118+
```sh
119+
uv run nox -s format_fix
120+
```
87121
88-
## Library Resources
122+
3. Fix any issues `nox` reports. This could be:
89123
90-
- [`hikari` Documentation](https://docs.hikari-py.dev/en/latest/)
91-
- [`hikari` Examples](https://github.com/hikari-py/hikari/tree/master/examples)
92-
- [`hikari-arc` Documentation](https://arc.hypergonial.com/)
93-
- [`hikari-arc` Examples](https://github.com/hypergonial/hikari-arc/tree/main/examples/gateway)
94-
- [`hikari-miru` Documentation](https://miru.hypergonial.com/)
95-
- [`hikari-miru` Examples](https://github.com/hypergonial/hikari-miru/tree/main/examples)
124+
* code style issues, most of which [`ruff`](https://docs.astral.sh/ruff/) (the code linter/formatter) will try to fix automatically
125+
* typing issues found by [`pyright`](https://github.com/microsoft/pyright). These will need to be fixed manually.
126+
127+
Contact the webmaster if you need assistance fixing any issues!
128+
129+
## Library Resources
130+
- `hikari` [Documentation](https://docs.hikari-py.dev/en/latest/) & [Examples](https://github.com/hikari-py/hikari/tree/master/examples)
131+
- `hikari-arc` [Documentation](https://arc.hypergonial.com/) & [Examples](https://github.com/hypergonial/hikari-arc/tree/main/examples/gateway)
132+
- `hikari-miru` [Documentation](https://miru.hypergonial.com/) & [Examples](https://github.com/hypergonial/hikari-miru/tree/main/examples)
96133
97134
## Usage Guides
98135
@@ -116,7 +153,6 @@ As a prerequisite, you need to have an application registered on the Discord dev
116153
### What's the difference between `hikari`, `hikari-arc` and `hikari-miru`?
117154
118155
* `hikari` - the Discord API wrapper. Can be used to, for example:
119-
* [add roles to server members](https://docs.hikari-py.dev/en/stable/reference/hikari/api/rest/#hikari.api.rest.RESTClient.add_role_to_member)
120156
* [create threads](https://docs.hikari-py.dev/en/stable/reference/hikari/api/rest/#hikari.api.rest.RESTClient.create_thread)
121157
* [send individual messages](https://docs.hikari-py.dev/en/stable/reference/hikari/api/rest/#hikari.api.rest.RESTClient.create_message)
122158
* [fetch guild (server) information](https://docs.hikari-py.dev/en/stable/reference/hikari/api/rest/#hikari.api.rest.RESTClient.fetch_guild)

0 commit comments

Comments
 (0)