@wolfstar/plugin-gateway 0.6.0 → 0.7.0-next-20260928141845

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
@@ -709,6 +709,27 @@ const { items } = await client.messages.fetchPins(channelId);
709
709
  const users = await message.reactions.resolve("🐺")?.users.fetch();
710
710
  ```
711
711
 
712
+ ## Errors
713
+
714
+ Like discord.js's `DiscordjsError`, every error the package throws or emits carries a `code` from
715
+ `GatewayErrorCodes`, and its message comes from `GatewayErrorMessages`. `GatewayError`,
716
+ `GatewayTypeError`, and `GatewayRangeError` extend `Error`, `TypeError`, and `RangeError`, and are
717
+ named after their code (`GatewayError [WebhookTokenUnavailable]`). The errors with extra data
718
+ (`DispatchTimeoutError`, `GuildMembersTimeoutError`, `GuildMembersRateLimitError`, and
719
+ `GatewaySessionStoreError`) extend `GatewayError`.
720
+
721
+ ```typescript
722
+ import { GatewayError, GatewayErrorCodes } from "@wolfstar/plugin-gateway";
723
+
724
+ try {
725
+ await webhook.send("Awoo");
726
+ } catch (error) {
727
+ if (error instanceof GatewayError && error.code === GatewayErrorCodes.WebhookTokenUnavailable) {
728
+ // The webhook was fetched without its token.
729
+ }
730
+ }
731
+ ```
732
+
712
733
  ## Limitations
713
734
 
714
735
  - A `GatewayClient` connects its gateway shards from a single process (`@discordjs/ws`'s
@@ -716,3 +737,11 @@ const users = await message.reactions.resolve("🐺")?.users.fetch();
716
737
  processes, use [`@wolfstar/plugin-sharder`](../plugin-sharder) and spread
717
738
  `shardClient.gatewayOptions` into the client's options.
718
739
  - Interaction payloads keep being handled as today, they do not read through `client.users` & co.
740
+
741
+ ## Credits
742
+
743
+ The error system (`src/errors/`) is adapted from discord.js's
744
+ [`errors`](https://github.com/discordjs/discord.js/tree/main/packages/discord.js/src/errors)
745
+ module, Copyright 2021 Noel Buechler and Copyright 2015 Amish Shah, licensed under the
746
+ [Apache License 2.0](https://github.com/discordjs/discord.js/blob/main/packages/discord.js/LICENSE).
747
+ The structures and managers follow discord.js's API as well.