lunibee 0.3.3 → 0.4.0

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 (125) hide show
  1. package/README.md +1 -1
  2. package/dist/builders/commands.d.ts +1 -1
  3. package/dist/builders/components.d.ts +9 -11
  4. package/dist/builders/embed.d.ts +1 -1
  5. package/dist/builders/index.d.ts +1 -1
  6. package/dist/builders/index.js +87 -1298
  7. package/dist/builders/index.js.map +3 -11
  8. package/dist/chunks/index-0wn81eng.js +2492 -0
  9. package/dist/chunks/index-0wn81eng.js.map +17 -0
  10. package/dist/chunks/index-2en489j6.js +40 -0
  11. package/dist/chunks/index-2en489j6.js.map +10 -0
  12. package/dist/chunks/index-3hyps48a.js +203 -0
  13. package/dist/chunks/index-3hyps48a.js.map +11 -0
  14. package/dist/chunks/index-57c5n3ms.js +2274 -0
  15. package/dist/chunks/index-57c5n3ms.js.map +19 -0
  16. package/dist/chunks/index-5yx92e36.js +1170 -0
  17. package/dist/chunks/index-5yx92e36.js.map +14 -0
  18. package/dist/chunks/index-690bp093.js +95 -0
  19. package/dist/chunks/index-690bp093.js.map +10 -0
  20. package/dist/chunks/index-7fp2hvmg.js +2155 -0
  21. package/dist/chunks/index-7fp2hvmg.js.map +24 -0
  22. package/dist/chunks/index-cnmsajvk.js +1119 -0
  23. package/dist/chunks/index-cnmsajvk.js.map +12 -0
  24. package/dist/chunks/index-fdvgk2sw.js +1310 -0
  25. package/dist/chunks/index-fdvgk2sw.js.map +21 -0
  26. package/dist/chunks/index-gyvps8b9.js +214 -0
  27. package/dist/chunks/index-gyvps8b9.js.map +12 -0
  28. package/dist/chunks/index-jzg4bh99.js +1533 -0
  29. package/dist/chunks/index-jzg4bh99.js.map +21 -0
  30. package/dist/chunks/index-mgw2yvrm.js +3547 -0
  31. package/dist/chunks/index-mgw2yvrm.js.map +25 -0
  32. package/dist/chunks/index-yh76b55h.js +3449 -0
  33. package/dist/chunks/index-yh76b55h.js.map +29 -0
  34. package/dist/collection/index.js +9 -1118
  35. package/dist/collection/index.js.map +3 -6
  36. package/dist/core/api.d.ts +3 -3
  37. package/dist/core/channel-create.d.ts +2 -2
  38. package/dist/core/commands.d.ts +3 -3
  39. package/dist/core/events.d.ts +4 -4
  40. package/dist/core/handles.d.ts +4 -4
  41. package/dist/core/index.d.ts +25 -20
  42. package/dist/core/index.js +68 -10130
  43. package/dist/core/index.js.map +3 -65
  44. package/dist/core/permissions.d.ts +1 -1
  45. package/dist/core/redis-cache.d.ts +1 -1
  46. package/dist/formatters/index.js +41 -110
  47. package/dist/formatters/index.js.map +3 -4
  48. package/dist/handlers/index.js +5 -37
  49. package/dist/handlers/index.js.map +3 -4
  50. package/dist/index.d.ts +21 -21
  51. package/dist/index.js +641 -16325
  52. package/dist/index.js.map +3 -92
  53. package/dist/managers/advanced.d.ts +3 -3
  54. package/dist/managers/application.d.ts +2 -2
  55. package/dist/managers/base.d.ts +1 -1
  56. package/dist/managers/emoji.d.ts +2 -2
  57. package/dist/managers/guild-resources.d.ts +6 -6
  58. package/dist/managers/guild.d.ts +3 -3
  59. package/dist/managers/index.d.ts +4 -8
  60. package/dist/managers/index.js +51 -4060
  61. package/dist/managers/index.js.map +3 -29
  62. package/dist/managers/member.d.ts +2 -2
  63. package/dist/managers/message.d.ts +14 -6
  64. package/dist/managers/role.d.ts +2 -2
  65. package/dist/managers/thread.d.ts +3 -3
  66. package/dist/managers/user.d.ts +7 -4
  67. package/dist/rest/index.d.ts +10 -35
  68. package/dist/rest/index.js +57 -2184
  69. package/dist/rest/index.js.map +3 -18
  70. package/dist/rest/limiter.d.ts +9 -1
  71. package/dist/rest/webhook.d.ts +2 -8
  72. package/dist/sharding/bus.d.ts +2 -2
  73. package/dist/sharding/cluster.d.ts +45 -5
  74. package/dist/sharding/context.d.ts +45 -3
  75. package/dist/sharding/gateway-bot.d.ts +2 -1
  76. package/dist/sharding/health.d.ts +1 -1
  77. package/dist/sharding/identify.d.ts +12 -0
  78. package/dist/sharding/index.d.ts +44 -11
  79. package/dist/sharding/index.js +60 -4620
  80. package/dist/sharding/index.js.map +3 -33
  81. package/dist/sharding/supervisor.d.ts +4 -2
  82. package/dist/structures/audit-log.d.ts +1 -1
  83. package/dist/structures/base.d.ts +6 -6
  84. package/dist/structures/channels.d.ts +1 -1
  85. package/dist/structures/embed.d.ts +1 -1
  86. package/dist/structures/index.d.ts +14 -14
  87. package/dist/structures/index.js +109 -2382
  88. package/dist/structures/index.js.map +3 -16
  89. package/dist/structures/interactions.d.ts +13 -9
  90. package/dist/structures/options.d.ts +1 -1
  91. package/dist/structures/permissions.d.ts +2 -2
  92. package/dist/structures/resources.d.ts +10 -10
  93. package/dist/structures/sticker.d.ts +1 -1
  94. package/dist/types/gateway.d.ts +2 -79
  95. package/dist/types/index.d.ts +0 -6
  96. package/dist/types/index.js +41 -272
  97. package/dist/types/index.js.map +3 -6
  98. package/dist/utils/index.js +23 -209
  99. package/dist/utils/index.js.map +3 -5
  100. package/dist/voice/connection.d.ts +200 -0
  101. package/dist/voice/crypto.d.ts +50 -0
  102. package/dist/voice/dave.d.ts +85 -0
  103. package/dist/voice/effects.d.ts +31 -0
  104. package/dist/voice/emitter.d.ts +14 -0
  105. package/dist/voice/gateway.d.ts +59 -0
  106. package/dist/voice/index.d.ts +25 -228
  107. package/dist/voice/index.js +111 -442
  108. package/dist/voice/index.js.map +3 -4
  109. package/dist/voice/libopus.d.ts +88 -0
  110. package/dist/voice/networking.d.ts +80 -0
  111. package/dist/voice/ogg.d.ts +24 -0
  112. package/dist/voice/opus.d.ts +18 -0
  113. package/dist/voice/player.d.ts +79 -0
  114. package/dist/voice/protocol.d.ts +76 -0
  115. package/dist/voice/receiver.d.ts +59 -0
  116. package/dist/voice/resource.d.ts +102 -0
  117. package/dist/voice/udp.d.ts +40 -0
  118. package/dist/ws/close-codes.d.ts +1 -1
  119. package/dist/ws/index.d.ts +25 -4
  120. package/dist/ws/index.js +47 -1336
  121. package/dist/ws/index.js.map +3 -17
  122. package/dist/ws/protocol.d.ts +1 -1
  123. package/dist/ws/send-budget.d.ts +0 -2
  124. package/dist/ws/state.d.ts +0 -10
  125. package/package.json +19 -16
@@ -1,5 +1,5 @@
1
- import { REST } from "@lunibee/rest";
2
- import { GuildMember, type ResourceContext } from "@lunibee/structures";
1
+ import { REST } from "../rest/index.js";
2
+ import { GuildMember, type ResourceContext } from "../structures/index.js";
3
3
  import { ResourceManager } from "./base.js";
4
4
  /** Fields that can change when editing a guild member (nickname, roles, voice state, timeout). */
5
5
  export interface MemberEditOptions {
@@ -1,4 +1,4 @@
1
- import { Collection } from "@lunibee/collection";
1
+ import { Collection } from "../collection/index.js";
2
2
  /** Opt-in per-channel message cache. Messages are temporary data, so they
3
3
  * use bounded TTL/LRU storage rather than permanent resource storage. */
4
4
  export interface MessageCacheOptions {
@@ -7,9 +7,9 @@ export interface MessageCacheOptions {
7
7
  /** Sliding TTL in ms. Omit for no expiry. */
8
8
  ttl?: number;
9
9
  }
10
- import { REST, type RESTFileAttachment } from "@lunibee/rest";
11
- import type { AllowedMentions, MessageCreateOptions, MessageEditOptions, MessageFile, MessageFileSource } from "@lunibee/types";
12
- import { Message, type ResourceContext } from "@lunibee/structures";
10
+ import { REST, type RESTFileAttachment } from "../rest/index.js";
11
+ import type { AllowedMentions, MessageCreateOptions, MessageEditOptions, MessageFile, MessageFileSource } from "../types/index.js";
12
+ import { Message, type ResourceContext } from "../structures/index.js";
13
13
  export type { MessageCreateOptions, MessageEditOptions, MessageFile, MessageFileSource, };
14
14
  /**
15
15
  * Turns message files into REST uploads, encoding string data as UTF-8. A file
@@ -27,9 +27,9 @@ export declare function toAttachments(files: readonly (MessageFile | MessageFile
27
27
  * @throws {TypeError} If the object is invalid.
28
28
  */
29
29
  export declare function assertAllowedMentions(mentions: AllowedMentions): void;
30
- export declare function toRequest(options: MessageCreateOptions, allowedMentions?: AllowedMentions): Omit<MessageCreateOptions, "files"> | {
30
+ export declare function toRequest(options: MessageCreateOptions, allowedMentions?: AllowedMentions): {
31
31
  body: Omit<MessageCreateOptions, "files">;
32
- files: RESTFileAttachment[];
32
+ files?: RESTFileAttachment[];
33
33
  };
34
34
  export declare class MessageManager {
35
35
  #private;
@@ -38,7 +38,15 @@ export declare class MessageManager {
38
38
  constructor(rest: REST, context: ResourceContext, channelId: string, cache?: MessageCacheOptions, allowedMentions?: AllowedMentions);
39
39
  resolve(messageId: string): Promise<Message>;
40
40
  send(options: MessageCreateOptions): Promise<Message>;
41
+ /**
42
+ * Fetches a message. Concurrent fetches of one message share a request.
43
+ * If the message is stored or deleted (e.g. by a Gateway event) while the
44
+ * request is in flight, the result is returned but not cached, so it
45
+ * cannot overwrite fresher state or bring back a deleted message.
46
+ */
41
47
  fetch(messageId: string): Promise<Message>;
48
+ /** Stores a message as the cached version (when caching is on), replacing any cached one. @returns This manager. */
49
+ set(messageId: string, message: Message): this;
42
50
  fetchMany(messageIds: Iterable<string>): Promise<Message[]>;
43
51
  upsert(data: ConstructorParameters<typeof Message>[0]): Message;
44
52
  delete(messageId: string): boolean;
@@ -1,5 +1,5 @@
1
- import { REST } from "@lunibee/rest";
2
- import { Role } from "@lunibee/structures";
1
+ import { REST } from "../rest/index.js";
2
+ import { Role } from "../structures/index.js";
3
3
  import { ResourceManager } from "./base.js";
4
4
  /** Role fields shared by create and edit. */
5
5
  interface RoleStyleOptions {
@@ -1,6 +1,6 @@
1
- import { REST } from "@lunibee/rest";
2
- import { Channel, type ResourceContext } from "@lunibee/structures";
3
- import type { AllowedMentions, APIGuildMember, APIThreadMember, MessageCreateOptions } from "@lunibee/types";
1
+ import { REST } from "../rest/index.js";
2
+ import { Channel, type ResourceContext } from "../structures/index.js";
3
+ import type { AllowedMentions, APIGuildMember, APIThreadMember, MessageCreateOptions } from "../types/index.js";
4
4
  /** Options shared by every way of starting a thread. */
5
5
  export interface ThreadCreateOptions {
6
6
  name: string;
@@ -1,7 +1,7 @@
1
1
  import { ResourceManager } from "./base.js";
2
- import { User } from "@lunibee/structures";
3
- import { type REST } from "@lunibee/rest";
4
- import type { APIChannel } from "@lunibee/types";
2
+ import { User } from "../structures/index.js";
3
+ import { type REST } from "../rest/index.js";
4
+ import type { APIChannel } from "../types/index.js";
5
5
  /** A guild as `GET /users/@me/guilds` lists it. */
6
6
  export interface APIPartialGuild {
7
7
  id: string;
@@ -19,7 +19,10 @@ export interface UserEditOptions {
19
19
  }
20
20
  export declare class UserManager extends ResourceManager<string, User> {
21
21
  #private;
22
- constructor(rest: REST);
22
+ /** @param options.maxSize Most users kept; the least recently used go first. Default: unbounded. */
23
+ constructor(rest: REST, options?: {
24
+ maxSize?: number;
25
+ });
23
26
  /** Gets the currently logged-in bot user. */
24
27
  fetchMe(): Promise<User>;
25
28
  /** Modifies the currently logged-in bot user. */
@@ -1,5 +1,4 @@
1
1
  import { type RateLimitStore } from "./store.js";
2
- import { RESTError } from "./errors.js";
3
2
  import { type RESTQuery } from "./route.js";
4
3
  import { type CoordinationMode, type RESTTelemetry } from "./telemetry.js";
5
4
  import { HttpTransport } from "./transport.js";
@@ -13,9 +12,8 @@ export interface RESTFileAttachment {
13
12
  /**
14
13
  * Options controlling an individual REST request.
15
14
  *
16
- * Lunibee's canonical call shape is positional (`post(path, body)`); these options
17
- * add the Discord.js-`@discordjs/rest`-familiar per-request knobs (`query`, `headers`,
18
- * `reason`, `auth`) additively without changing that positional default.
15
+ * The body is positional (`post(path, body, options)`); these options carry the
16
+ * per-request knobs (`query`, `headers`, `reason`, `auth`, `signal`, `maxQueueWait`).
19
17
  */
20
18
  export interface RESTRequestOptions {
21
19
  /** Abort signal used to cancel the request and any queued wait. */
@@ -36,28 +34,15 @@ export interface RESTRequestOptions {
36
34
  maxQueueWait?: number;
37
35
  }
38
36
  /**
39
- * Discord.js-familiar request payload. Superset of {@link RESTRequestOptions} that also
40
- * carries the `body` and `files`, matching `@discordjs/rest`'s `RequestData`. It powers the
41
- * additive `method(path, { body })` overloads without breaking the positional signature.
37
+ * Request options plus `files` (which upgrade the request to multipart) and, for
38
+ * `get()` and `delete()` (which take no positional body), an optional `body`.
42
39
  */
43
40
  export interface RequestData extends RESTRequestOptions {
44
- /** Request body. Encoded as JSON unless `files` are present (then multipart). */
41
+ /** Request body for `get()` and `delete()`; `request()`, `post()`, `put()` and `patch()` take theirs positionally. */
45
42
  body?: unknown;
46
43
  /** File attachments; presence upgrades the request to `multipart/form-data`. */
47
44
  files?: RESTFileAttachment[];
48
45
  }
49
- /**
50
- * The single-object form of {@link REST.request}, matching `@discordjs/rest`:
51
- * the route is `path` (or its Discord.js name, `fullRoute`).
52
- */
53
- export interface RequestOptionsObject extends RequestData {
54
- /** HTTP method. */
55
- method: string;
56
- /** API path, starting with `/`. */
57
- path?: string;
58
- /** Alias of `path`, as `@discordjs/rest` names it. */
59
- fullRoute?: string;
60
- }
61
46
  /** Context passed to `RESTHooks.onRequest`. */
62
47
  export interface RESTRequestContext {
63
48
  method: string;
@@ -219,23 +204,19 @@ export declare class REST {
219
204
  * @param method HTTP method.
220
205
  * @param path API path.
221
206
  * @param body Optional JSON body, FormData for file uploads, or undefined.
222
- * @param options Request options: cancellation `signal` plus the Discord.js-familiar
223
- * `query`, `headers`, `reason`, `auth`, and `files` (which upgrade to multipart).
207
+ * @param options Request options: cancellation `signal`, `query`, `headers`,
208
+ * `reason`, `auth`, and `files` (which upgrade to multipart).
224
209
  * @returns Decoded response body.
225
210
  * @throws {RESTError} If Discord or transport rejects the request.
226
211
  */
227
- request<T>(options: RequestOptionsObject): Promise<T>;
228
212
  request<T>(method: string, path: string, body?: unknown, options?: RequestData): Promise<T>;
229
213
  /** Sends a GET request. @param path API path. @param options Request options (`query`, `headers`, `signal`, …). @returns Decoded response. @throws {RESTError} When the request fails. */
230
214
  get<T>(path: string, options?: RequestData): Promise<T>;
231
- /** Sends a POST request. Accepts a raw body (`post(path, body)`) or a Discord.js-familiar `post(path, { body })`. @param path API path. @param body Optional JSON body, or a `RequestData` wrapper. @param options Request options. @returns Decoded response. @throws {RESTError} When the request fails. */
232
- post<T>(path: string, options: RequestData): Promise<T>;
215
+ /** Sends a POST request. @param path API path. @param body Optional JSON body. @param options Request options (`files`, `reason`, `query`, `headers`, `signal`, …). @returns Decoded response. @throws {RESTError} When the request fails. */
233
216
  post<T>(path: string, body?: unknown, options?: RequestData): Promise<T>;
234
- /** Sends a PATCH request. Accepts a raw body (`patch(path, body)`) or a Discord.js-familiar `patch(path, { body })`. @param path API path. @param body Optional JSON body, or a `RequestData` wrapper. @param options Request options. @returns Decoded response. @throws {RESTError} When the request fails. */
235
- patch<T>(path: string, options: RequestData): Promise<T>;
217
+ /** Sends a PATCH request. @param path API path. @param body Optional JSON body. @param options Request options (`files`, `reason`, `query`, `headers`, `signal`, …). @returns Decoded response. @throws {RESTError} When the request fails. */
236
218
  patch<T>(path: string, body?: unknown, options?: RequestData): Promise<T>;
237
- /** Sends a PUT request. Accepts a raw body (`put(path, body)`) or a Discord.js-familiar `put(path, { body })`. @param path API path. @param body Optional JSON body, or a `RequestData` wrapper. @param options Request options. @returns Decoded response. @throws {RESTError} When the request fails. */
238
- put<T>(path: string, options: RequestData): Promise<T>;
219
+ /** Sends a PUT request. @param path API path. @param body Optional JSON body. @param options Request options (`files`, `reason`, `query`, `headers`, `signal`, …). @returns Decoded response. @throws {RESTError} When the request fails. */
239
220
  put<T>(path: string, body?: unknown, options?: RequestData): Promise<T>;
240
221
  /** Sends a DELETE request. @param path API path. @param options Request options (`reason`, `headers`, `signal`, …). @returns Decoded response. @throws {RESTError} When the request fails. */
241
222
  delete<T>(path: string, options?: RequestData): Promise<T>;
@@ -275,9 +256,3 @@ export { ResponseDecoder, type DecodedError } from "./decoder.js";
275
256
  export { type RateLimitStore, type BucketState, type BucketUpdate, type Reservation, type ReserveOptions, MemoryRateLimitStore, } from "./store.js";
276
257
  export { RedisRateLimitStore, fromBunRedis, type RedisRateLimitStoreOptions, type RedisFailurePolicy, type RedisStoreDiagnostics, type MinimalRedisClient, } from "./redis.js";
277
258
  export { WebhookClient, type WebhookClientOptions, type WebhookMessageOptions, } from "./webhook.js";
278
- /**
279
- * Discord.js-familiar alias for {@link RESTError}. `@discordjs/rest` throws `DiscordAPIError`
280
- * on a Discord-rejected request; Lunibee keeps `RESTError` as the canonical class and exports
281
- * this alias so Discord.js-shaped `catch (err) { if (err instanceof DiscordAPIError) … }` works.
282
- */
283
- export { RESTError as DiscordAPIError };