@@ -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
2023By 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
3535By default, the Gateway simply outputs to standard output. If you'd like to run a quick test,
3636here'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
4848This is the JSON format used when using the STDIO mode of the gateway. ` event `
4949is 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 ]
6694type = " amqp"
67- group = " gateway"
68- message_timeout = " 2m"
6995
7096[amqp ]
7197url = " amqp://localhost"
0 commit comments