@wolfstar/plugin-gateway 0.3.0 → 0.4.0-next-20260927180344
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/dist/esm/index.d.ts +4474 -4347
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +168 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -74,6 +74,7 @@ On top of the `Client` options:
|
|
|
74
74
|
| `sessionStore` | `undefined` | A `GatewaySessionStore` keeping the shards' sessions across restarts, see [Resuming sessions](#resuming-sessions-across-restarts). |
|
|
75
75
|
| `sessionStoreTimeout` | `5_000` | Milliseconds a shard waits for `sessionStore` to read its session before identifying. `null` waits forever. |
|
|
76
76
|
| `partials` | `[]` | The structures to build partially for uncached entities, see [Partials](#partials). |
|
|
77
|
+
| `waitGuildTimeout` | `15_000` | Milliseconds `clientReady` waits for initially unavailable guilds before emitting anyway, see [Events](#events). |
|
|
77
78
|
|
|
78
79
|
`client.gateway` exposes the underlying `WebSocketManager`, e.g. to send presence updates.
|
|
79
80
|
|
|
@@ -99,10 +100,18 @@ client.on("messageDelete", async (message) => {
|
|
|
99
100
|
|
|
100
101
|
## Events
|
|
101
102
|
|
|
103
|
+
`GatewayEvents` mirrors the keys of the table below, like `@wolfstar/http-framework`'s own `Events`: each member's
|
|
104
|
+
value is the plain event name, so it is interchangeable with the string literal.
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
client.on(GatewayEvents.MessageCreate, (message) => console.log(message.content));
|
|
108
|
+
```
|
|
109
|
+
|
|
102
110
|
| Event | Arguments |
|
|
103
111
|
| --------------------------------------------------------- | ---------------------------------------------- |
|
|
104
112
|
| `raw` | `payload`, `shardId` — every dispatch |
|
|
105
113
|
| `shardReady` | `shardId`, `user` |
|
|
114
|
+
| `clientReady` | `client` — once, see below |
|
|
106
115
|
| `shardResume` / `shardClose` / `shardError` | `shardId` / `shardId, code` / `error, shardId` |
|
|
107
116
|
| `guildCreate` | `guild` |
|
|
108
117
|
| `guildUpdate` | `oldGuild \| null`, `newGuild` |
|
|
@@ -158,6 +167,17 @@ The previous state of update events and the entity of delete events come from th
|
|
|
158
167
|
`null` when it was not cached (or when the client has no cache). `data` is the raw dispatch data,
|
|
159
168
|
which always identifies the deleted entity.
|
|
160
169
|
|
|
170
|
+
`clientReady` is emitted once, like discord.js's `Client#clientReady`: after every shard this client manages has
|
|
171
|
+
connected, and every guild `READY` listed as initially unavailable became available (or `waitGuildTimeout`, `15_000`
|
|
172
|
+
by default, elapsed — that timeout only bounds the wait on guilds, never on shards connecting).
|
|
173
|
+
`client.isClientReady()` and `client.clientReadyAt` report it after the fact.
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
client.on(GatewayEvents.ClientReady, (client) =>
|
|
177
|
+
console.log(`Logged in as ${client.user!.username}`),
|
|
178
|
+
);
|
|
179
|
+
```
|
|
180
|
+
|
|
161
181
|
`client.actions` holds an `Action` for each handled gateway dispatch. Each action captures the
|
|
162
182
|
previous state, then builds and emits events after the cache has been updated. The built-in actions
|
|
163
183
|
use the `DispatchHandlers` and `MultiDispatchHandlers` tables. Dispatches they do not cover are
|