Skip to content

Commit fad0865

Browse files
author
Will Nelson
committed
Update documentation
1 parent 54efb5c commit fad0865

File tree

2 files changed

+59
-29
lines changed

2 files changed

+59
-29
lines changed

docs/gateway.md

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ ratelimiting, and sharding and outputs a continuous stream of events to your app
99

1010
## Config
1111

12-
The Spectacles Gateway has a variety of configuration options, but there are only 2 values that
13-
you *must* provide for the Gateway to work: your bot token and a list of events to publish.
12+
The Spectacles Gateway has a variety of configuration options, but there are only 3 values that
13+
you *must* provide for the Gateway to work: your bot token, a list of
14+
[events](https://discord.com/developers/docs/topics/gateway#event-names) to publish, and
15+
[intents](https://discord.com/developers/docs/topics/gateway#gateway-intents).
1416

1517
```toml
16-
token = "" # Discord token
17-
events = [] # array of gateway event names to publish
18+
token = ""
19+
events = ["GUILD_CREATE"]
20+
intents = ["GUILD"]
1821
```
1922

2023
By default, the Gateway reads its config file from `gateway.toml` in the current working directory.
@@ -25,25 +28,22 @@ You can also specify this config using environment variables.
2528

2629
- `DISCORD_TOKEN`: your token
2730
- `DISCORD_EVENTS`: comma-separated string of gateway event names
28-
29-
### Gateway event names
30-
31-
Gateway events are documented on the [Discord API documentation](https://discord.com/developers/docs/topics/gateway#event-names).
31+
- `DISCORD_INTENTS`: comma-separated string of intents
3232

3333
## Standard IO
3434

3535
By default, the Gateway simply outputs to standard output. If you'd like to run a quick test,
3636
here's a Docker command you can run to see incoming `MESSAGE_CREATE` events.
3737

3838
```
39-
docker run --rm -it \
40-
--name gateway \
41-
-e DISCORD_TOKEN="your token" \
42-
-e DISCORD_EVENTS=MESSAGE_CREATE \
39+
docker run --rm -it
40+
-e DISCORD_TOKEN="your token"
41+
-e DISCORD_EVENTS=MESSAGE_CREATE
42+
-e DISCORD_INTENTS=GUILD,GUILD_MESSAGES
4343
spectacles/gateway
4444
```
4545

46-
You can even publish data *back* to the gateway if you input JSON to the terminal.
46+
You can even publish data *back* to the gateway if you input MessagePack to the terminal.
4747

4848
This is the JSON format used when using the STDIO mode of the gateway. `event`
4949
is mapped to the `t` property and `data` is mapped to the `d` property of a
@@ -56,16 +56,42 @@ is mapped to the `t` property and `data` is mapped to the `d` property of a
5656
}
5757
```
5858

59+
## Redis
60+
61+
Change your config to specify Redis as the broker type and provide Redis connection options.
62+
63+
```toml
64+
# base config here
65+
66+
[broker]
67+
type = "redis"
68+
69+
[redis]
70+
url = "localhost:6379"
71+
```
72+
73+
You can now consume events from this Redis instance. To verify that this is working, simply execute
74+
`XREAD STREAMS {event_name} 0-0` on Redis, where `{event_name}` is replaced with a Discord event
75+
you are expecting (e.g. GUILD_CREATE).
76+
77+
You can also change the shard store to Redis. This will allow your gateway sessions to persist past
78+
restarts in case your gateway dies.
79+
80+
```toml
81+
[shard_store]
82+
type = "redis"
83+
prefix = "gateway"
84+
```
85+
5986
## AMQP
6087

61-
Most of the time, you'll want to use a proper message broker for getting data from the Gateway to
62-
your applications. Change your config to specify AMQP as the broker type by adding the TOML below.
88+
Change your config to specify AMQP as the broker type and provide AMQP connection options.
6389

6490
```toml
91+
# base config here
92+
6593
[broker]
6694
type = "amqp"
67-
group = "gateway"
68-
message_timeout = "2m"
6995

7096
[amqp]
7197
url = "amqp://localhost"

docs/introduction.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@ id: introduction
44
title: Introduction
55
---
66

7-
Spectacles is a collection of applications and libraries designed to help you make stable,
8-
microservice-oriented Discord bots.
7+
Spectacles is a distributed Discord bot framework.
98

109
![Architecture](../static/img/architecture.svg)
1110

1211
A basic Spectacles bot runs 4 services:
1312

1413
1. Gateway
1514
2. Proxy
16-
3. RabbitMQ
15+
3. Message broker
1716
4. Command handler
1817

19-
The Spectacles organization provides the gateway and proxy services. RabbitMQ is developed
20-
independently. You are responsible for writing your own command handler (that's why you're here,
21-
afterall).
18+
The Spectacles organization provides the gateway and proxy services. You are responsible for
19+
writing your own command handler (that's why you're here, after all).
2220

2321
Each of these services is fully stateless and can be easily scaled up or down across machines.
2422

@@ -33,24 +31,30 @@ gateway:
3331
- Reconnection
3432
- Gateway ratelimits
3533

34+
[More info](gateway)
35+
3636
## Proxy
3737

3838
The proxy is responsible for handling all of the outgoing HTTP requests to Discord. It ensures that
3939
your bot complies with Discord's ratelimits under any circumstance. Eventually, the proxy will also
4040
cache data and ensure that you never run into a performance bottleneck while fetching Discord data
4141
in your application.
4242

43-
Your applications publish requests to RabbitMQ. The proxy consumes these and sends them to
44-
Discord as soon as possible. The proxy is responsible for:
43+
Your applications publish requests to the message broker. The proxy consumes these and sends them
44+
to Discord as soon as possible. The proxy is responsible for:
4545

4646
- HTTP ratelimits
4747
- Caching (soon)
4848

49-
## RabbitMQ
49+
## Message Broker
50+
51+
Spectacles supports 2 message broker options:
52+
53+
1. Redis
54+
2. RabbitMQ
5055

51-
RabbitMQ is a message broker that Spectacles relies on to consistently deliver messages to each
52-
service. You don't need to know how it works or how to use it, only that it's responsible for
53-
delivering messages between your applications.
56+
We recommend Redis, since it is generally more performant and you will need to use it with the
57+
gateway and proxy.
5458

5559
## Command Handler
5660

0 commit comments

Comments
 (0)