lunibee 0.3.1 → 0.3.2

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.
Files changed (79) hide show
  1. package/dist/builders/attachment.d.ts +1 -0
  2. package/dist/builders/clone.d.ts +10 -0
  3. package/dist/builders/commands.d.ts +1 -1
  4. package/dist/builders/components.d.ts +24 -5
  5. package/dist/builders/index.js +64 -17
  6. package/dist/builders/index.js.map +10 -9
  7. package/dist/collection/index.d.ts +1 -0
  8. package/dist/collection/index.js +297 -19
  9. package/dist/collection/index.js.map +5 -4
  10. package/dist/collection/redis.d.ts +98 -0
  11. package/dist/core/collector.d.ts +8 -0
  12. package/dist/core/events.d.ts +1 -0
  13. package/dist/core/index.d.ts +3 -0
  14. package/dist/core/index.js +6213 -4716
  15. package/dist/core/index.js.map +46 -39
  16. package/dist/core/permissions.d.ts +3 -402
  17. package/dist/core/redis-cache.d.ts +85 -0
  18. package/dist/formatters/index.d.ts +5 -1
  19. package/dist/formatters/index.js +7 -3
  20. package/dist/formatters/index.js.map +3 -3
  21. package/dist/handlers/index.js +11 -2
  22. package/dist/handlers/index.js.map +3 -3
  23. package/dist/index.js +8272 -6085
  24. package/dist/index.js.map +64 -58
  25. package/dist/managers/application.d.ts +10 -6
  26. package/dist/managers/base.d.ts +4 -1
  27. package/dist/managers/guild.d.ts +3 -1
  28. package/dist/managers/index.d.ts +6 -1
  29. package/dist/managers/index.js +365 -103
  30. package/dist/managers/index.js.map +19 -22
  31. package/dist/managers/member.d.ts +3 -1
  32. package/dist/managers/message.d.ts +13 -4
  33. package/dist/managers/thread.d.ts +3 -3
  34. package/dist/rest/decoder.d.ts +2 -0
  35. package/dist/rest/errors.d.ts +5 -2
  36. package/dist/rest/headers.d.ts +31 -0
  37. package/dist/rest/identity.d.ts +31 -0
  38. package/dist/rest/index.d.ts +97 -6
  39. package/dist/rest/index.js +1350 -220
  40. package/dist/rest/index.js.map +16 -13
  41. package/dist/rest/limiter.d.ts +75 -10
  42. package/dist/rest/redis.d.ts +103 -22
  43. package/dist/rest/scheduler.d.ts +13 -0
  44. package/dist/rest/store.d.ts +135 -12
  45. package/dist/rest/telemetry.d.ts +151 -0
  46. package/dist/rest/webhook.d.ts +18 -6
  47. package/dist/sharding/bus.d.ts +4 -2
  48. package/dist/sharding/cluster.d.ts +1 -1
  49. package/dist/sharding/health.d.ts +1 -1
  50. package/dist/sharding/host.d.ts +6 -0
  51. package/dist/sharding/identify.d.ts +2 -0
  52. package/dist/sharding/index.d.ts +6 -0
  53. package/dist/sharding/index.js +205 -39
  54. package/dist/sharding/index.js.map +14 -14
  55. package/dist/sharding/remote.d.ts +18 -2
  56. package/dist/sharding/supervisor.d.ts +1 -1
  57. package/dist/sharding/transport.d.ts +6 -5
  58. package/dist/sharding/worker.d.ts +11 -1
  59. package/dist/structures/base.d.ts +16 -5
  60. package/dist/structures/index.d.ts +1 -1
  61. package/dist/structures/index.js +57 -91
  62. package/dist/structures/index.js.map +10 -18
  63. package/dist/structures/options.d.ts +3 -2
  64. package/dist/structures/permissions.d.ts +409 -0
  65. package/dist/structures/resources.d.ts +4 -1
  66. package/dist/types/gateway.d.ts +4 -0
  67. package/dist/types/index.d.ts +14 -4
  68. package/dist/types/index.js.map +3 -3
  69. package/dist/utils/args.d.ts +3 -1
  70. package/dist/utils/index.d.ts +6 -1
  71. package/dist/utils/index.js +17 -10
  72. package/dist/utils/index.js.map +4 -4
  73. package/dist/voice/index.d.ts +7 -1
  74. package/dist/voice/index.js +33 -10
  75. package/dist/voice/index.js.map +3 -3
  76. package/dist/ws/index.d.ts +2 -0
  77. package/dist/ws/index.js +32 -4
  78. package/dist/ws/index.js.map +5 -5
  79. package/package.json +19 -16
@@ -1,10 +1,12 @@
1
1
  import { type RESTFileAttachment } from "./index.js";
2
- import type { APIEmbed, APIMessage, APIMessageComponent } from "@lunibee/types";
2
+ import type { AllowedMentions, APIEmbed, APIMessage, APIMessageComponent } from "@lunibee/types";
3
+ /** Where a `WebhookClient` sends: a Discord webhook `url`, or its `id` and `token`. */
3
4
  export interface WebhookClientOptions {
4
5
  id?: string;
5
6
  token?: string;
6
7
  url?: string;
7
8
  }
9
+ /** A webhook message for `send()` and `editMessage()`; camelCase aliases (`avatarURL`, `threadId`, `allowedMentions`) are accepted beside the wire names. */
8
10
  export interface WebhookMessageOptions {
9
11
  content?: string;
10
12
  username?: string;
@@ -20,6 +22,13 @@ export interface WebhookMessageOptions {
20
22
  files?: RESTFileAttachment[];
21
23
  flags?: number;
22
24
  thread_id?: string;
25
+ /** Discord.js-familiar alias of `avatar_url`. */
26
+ avatarURL?: string;
27
+ /** Discord.js-familiar alias of `thread_id`. */
28
+ threadId?: string;
29
+ /** Discord.js-familiar alias of `allowed_mentions`. */
30
+ allowedMentions?: AllowedMentions;
31
+ allowed_mentions?: AllowedMentions;
23
32
  }
24
33
  /** Standalone client for sending Discord webhooks. */
25
34
  export declare class WebhookClient {
@@ -34,11 +43,14 @@ export declare class WebhookClient {
34
43
  });
35
44
  /** Sends a message to the webhook. */
36
45
  send(options: string | WebhookMessageOptions): Promise<APIMessage>;
37
- /** Edits a previously sent webhook message. */
38
- editMessage(messageId: string, options: string | {
39
- content?: string;
40
- embeds?: APIEmbed[];
46
+ /** Fetches a message this webhook sent (`threadId` for a message inside a thread). */
47
+ fetchMessage(messageId: string, options?: {
48
+ threadId?: string;
41
49
  }): Promise<APIMessage>;
50
+ /** Edits a previously sent webhook message. Takes the same options as {@link WebhookClient.send}, files included. */
51
+ editMessage(messageId: string, options: string | WebhookMessageOptions): Promise<APIMessage>;
42
52
  /** Deletes a previously sent webhook message. */
43
- deleteMessage(messageId: string): Promise<void>;
53
+ deleteMessage(messageId: string, options?: {
54
+ threadId?: string;
55
+ }): Promise<void>;
44
56
  }
@@ -55,7 +55,7 @@ export declare class ShardBus {
55
55
  /** Registers a message handler. @param type Message type. @param handler Handler callback. @returns This bus. @throws {TypeError} If type or handler is invalid. */
56
56
  on<T>(type: string, handler: ShardMessageHandler<T>): this;
57
57
  /** Removes a message handler. @param type Message type. @param handler Handler callback. @returns This bus. */
58
- off<T>(type: string, handler: ShardMessageHandler<T>): this;
58
+ off<T>(type: string, handler: ShardMessageHandler<T> | ((data: T, message: ShardMessage<T>) => unknown)): this;
59
59
  /** Registers a listener for errors thrown or rejected by message handlers. Without one, handler errors are isolated and dropped. @param handler Error listener. @returns This bus. @throws {TypeError} If handler is invalid. */
60
60
  onError(handler: ShardBusErrorHandler): this;
61
61
  /** Removes a handler error listener. @param handler Error listener. @returns This bus. */
@@ -78,7 +78,9 @@ export declare class ShardBus {
78
78
  request<R = unknown, T = unknown>(target: number, type: string, data: T, timeoutMs?: number): Promise<R>;
79
79
  /**
80
80
  * Sends a request to every other shard and collects replies until
81
- * `expected` have arrived or `timeoutMs` elapses (never rejects).
81
+ * `expected` have arrived or `timeoutMs` elapses. A timeout or a shard
82
+ * going away does not reject; a closed bus, a blank type or too many
83
+ * pending requests does.
82
84
  */
83
85
  broadcastRequest<R = unknown, T = unknown>(type: string, data: T, options?: {
84
86
  timeoutMs?: number;
@@ -287,6 +287,6 @@ export declare class ClusterManager {
287
287
  * @param timeoutMs Grace period per child before force-kill. Defaults to the configured `shutdownTimeout` (5000 ms).
288
288
  */
289
289
  shutdownAll(timeoutMs?: number): Promise<void>;
290
- /** Immediately force-kills all active cluster processes and clears the cluster map. Prefer {@link shutdownAll} for a graceful stop. */
290
+ /** Immediately sends SIGTERM to every cluster process (no grace period, no SIGKILL escalation) and clears the cluster map. Prefer {@link shutdownAll} for a graceful stop. */
291
291
  killAll(): void;
292
292
  }
@@ -78,7 +78,7 @@ export interface ClusterHealth {
78
78
  lastReadyAt?: number;
79
79
  /** Per-shard health from the worker's last report. Empty until it reports. */
80
80
  shards: ShardHealth[];
81
- /** Present when requested with `health({ metrics: true })` and the worker answered. */
81
+ /** Present when requested with `refreshHealth({ metrics: true })` and the worker answered. */
82
82
  metrics?: WorkerMetrics;
83
83
  /** When `shards` and `metrics` were reported (epoch ms). */
84
84
  reportedAt?: number;
@@ -20,6 +20,12 @@ export interface ClusterHostOptions {
20
20
  reconnectDelay?: number;
21
21
  /** Longest delay between reconnect attempts, in ms. Default 30,000. */
22
22
  maxReconnectDelay?: number;
23
+ /**
24
+ * Attempts `connect()` makes while the coordinator is busy (it answers
25
+ * "too many connections" or the hello timed out) before it gives up.
26
+ * Default 10. A refusal (bad secret, unknown or duplicate id) is final.
27
+ */
28
+ connectAttempts?: number;
23
29
  }
24
30
  /** What a {@link ClusterHost} emits. */
25
31
  export interface ClusterHostEvents {
@@ -6,6 +6,8 @@ export interface IdentifyBudget {
6
6
  remaining: number;
7
7
  /** Milliseconds until `remaining` resets, counted from construction. */
8
8
  resetAfter: number;
9
+ /** Milliseconds between resets after that one. Discord resets the budget every 24 hours (the default). */
10
+ period?: number;
9
11
  }
10
12
  /** Options for an {@link IdentifyCoordinator}. */
11
13
  export interface IdentifyCoordinatorOptions {
@@ -91,6 +91,12 @@ export interface ShardManagerEvents {
91
91
  shardError: [shardId: number, error: Error];
92
92
  /** Every shard this manager owns is ready. Emitted again after a shard drops and recovers. */
93
93
  ready: [];
94
+ /**
95
+ * A shard's `Gateway` was created and has not connected yet: attach dispatch
96
+ * listeners here so none of its events are missed. Fires again for the new
97
+ * Gateways after `destroy()` + `connect()` or `reshard()`.
98
+ */
99
+ shardCreate: [shardId: number, gateway: Gateway];
94
100
  /** A shard reconnected too often too fast and is backing off (see `Gateway` `unstable`). */
95
101
  shardUnstable: [
96
102
  shardId: number,