@wolfstar/plugin-gateway 0.2.0 → 0.3.0-next-20260927143825

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 CHANGED
@@ -25,7 +25,7 @@ sharding, reconnects, and session resumes. Actions turn dispatches into events c
25
25
  such as `Message`, `User`, and `Guild`; `EventGatewayListener` lets pieces in the `listeners`
26
26
  directory handle those events. Managers such as `client.users` and `client.guilds` read from an
27
27
  optional [`@wolfstar/plugin-cache`](../plugin-cache) cache and fetch missing data through
28
- `@discordjs/core`. The same core API is available as `client.core.api`.
28
+ `@discordjs/core`. The same core API is available as `client.api`.
29
29
 
30
30
  > [!NOTE]
31
31
  > A gateway connection is long-lived: a `GatewayClient` needs a persistent process, unlike a bot
@@ -73,9 +73,30 @@ On top of the `Client` options:
73
73
  | `dispatchTimeout` | `30_000` | Milliseconds after which a dispatch still processing is reported as a `DispatchTimeoutError`. `null` disables it. |
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
+ | `partials` | `[]` | The structures to build partially for uncached entities, see [Partials](#partials). |
76
77
 
77
78
  `client.gateway` exposes the underlying `WebSocketManager`, e.g. to send presence updates.
78
79
 
80
+ ### Partials
81
+
82
+ Like discord.js's `partials`, `Partials` lists the structures the client builds from the IDs a dispatch carries when
83
+ an event concerns an entity it has not cached: `User`, `Channel` (direct messages only), `GuildMember`, `Message`,
84
+ `Reaction`, `GuildScheduledEvent`, `ThreadMember`, `Poll`, `PollAnswer`, and `SoundboardSound`.
85
+
86
+ Unlike discord.js, events are emitted either way: without the partial, the uncached entity is `null` as usual. With
87
+ it, it is a structure whose `partial` is `true`. Only its IDs are reliable, and `fetch()` completes it. Partial
88
+ structures are never written to the cache. The reactions and poll answers of uncached messages are always partial, so
89
+ `Partials.Reaction` and `Partials.PollAnswer` change nothing and exist for parity.
90
+
91
+ ```ts
92
+ const client = new GatewayClient({ intents, partials: [Partials.Message, Partials.User] });
93
+
94
+ client.on("messageDelete", async (message) => {
95
+ if (message?.partial)
96
+ console.log(`Uncached message ${message.id} deleted in ${message.channelId}`);
97
+ });
98
+ ```
99
+
79
100
  ## Events
80
101
 
81
102
  | Event | Arguments |
@@ -142,7 +163,7 @@ previous state, then builds and emits events after the cache has been updated. T
142
163
  use the `DispatchHandlers` and `MultiDispatchHandlers` tables. Dispatches they do not cover are
143
164
  still written to the cache and emitted as `raw`. `INTERACTION_CREATE` is handled by the HTTP endpoint.
144
165
 
145
- REST operations use `client.core.api` from `@discordjs/core`. A few endpoints without a matching
166
+ REST operations use `client.api` from `@discordjs/core`. A few endpoints without a matching
146
167
  core method (cursor-based message pins, guild creation from a template, and thread member queries
147
168
  with extra parameters) use the same core client's underlying REST transport.
148
169
 
@@ -592,8 +613,8 @@ console.log(widget.presenceCount, widget.imageURL(GuildWidgetStyle.Banner2));
592
613
 
593
614
  ### Webhooks
594
615
 
595
- `client.webhooks` fetches, creates, edits, and deletes webhooks, and posts with their token like
596
- discord.js's `WebhookClient`. Text, announcement, voice, stage, forum, and media channels have
616
+ `client.webhooks` fetches, creates, edits, and deletes webhooks, and posts with their token, without
617
+ the bot's authorization. Text, announcement, voice, stage, forum, and media channels have
597
618
  `fetchWebhooks` and `createWebhook`, guilds `fetchWebhooks`, and announcement channels
598
619
  `addFollower`. Webhooks are not cached: Discord only says that they changed (`webhooksUpdate`).
599
620