Skip to content

Commit f81b9ea

Browse files
committed
update blockbot docs
1 parent af24120 commit f81b9ea

File tree

1 file changed

+50
-14
lines changed

1 file changed

+50
-14
lines changed

docs/webgroup/blockbot.md

+50-14
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,22 @@ 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

4953
### Running from source (deprecated)
5054

55+
Blockbot uses [`uv`](https://docs.astral.sh/uv/) to manage dependencies and run the project.
56+
5157
1. Fork, `git clone` and `cd` into the [blockbot repository](https://github.com/redbrick/blockbot).
5258

5359
> [!TIP]
5460
> Read the [contributing docs](./contributing.md) for more information on using Git and GitHub.
5561
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):
5763

5864
```sh
59-
python3 -m venv .venv
65+
uv venv
6066
source .venv/bin/activate
6167
```
6268

@@ -66,8 +72,11 @@ As a prerequisite, you need to have an application registered on the Discord dev
6672
TOKEN=<Discord bot token here>
6773
```
6874

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).
7180

7281
### Running with Docker Compose
7382

@@ -83,16 +92,44 @@ As a prerequisite, you need to have an application registered on the Discord dev
8392
TOKEN=<Discord bot token here>
8493
```
8594

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.
8797

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.
104+
105+
1. Install `nox`
106+
107+
```sh
108+
uv sync --group nox --frozen
109+
```
110+
111+
2. Run `nox`
89112
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)
113+
```sh
114+
uv run nox
115+
```
116+
117+
To run a specific session (e.g. `format_fix`):
118+
```sh
119+
uv run nox -s format_fix
120+
```
121+
122+
3. Fix any issues `nox` reports. This could be:
123+
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)