lunibee 0.1.4 → 0.1.6

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 (42) hide show
  1. package/README.md +12 -23
  2. package/dist/builders/components.d.ts +108 -0
  3. package/dist/builders/index.d.ts +1 -1
  4. package/dist/builders/index.js +178 -2
  5. package/dist/builders/index.js.map +3 -3
  6. package/dist/collection/index.d.ts +6 -0
  7. package/dist/collection/index.js +33 -2
  8. package/dist/collection/index.js.map +4 -4
  9. package/dist/core/events.d.ts +67 -3
  10. package/dist/core/index.d.ts +120 -90
  11. package/dist/core/index.js +816 -1021
  12. package/dist/core/index.js.map +20 -21
  13. package/dist/formatters/index.js.map +1 -1
  14. package/dist/index.d.ts +5 -4
  15. package/dist/index.js +2215 -1392
  16. package/dist/index.js.map +29 -26
  17. package/dist/managers/guild.d.ts +30 -0
  18. package/dist/managers/index.d.ts +56 -75
  19. package/dist/managers/index.js +339 -48
  20. package/dist/managers/index.js.map +16 -12
  21. package/dist/managers/message.d.ts +7 -12
  22. package/dist/managers/user.d.ts +20 -0
  23. package/dist/rest/index.d.ts +83 -1
  24. package/dist/rest/index.js +48 -8
  25. package/dist/rest/index.js.map +4 -4
  26. package/dist/rest/routes.d.ts +4 -1
  27. package/dist/sharding/index.js +4 -1
  28. package/dist/sharding/index.js.map +4 -4
  29. package/dist/structures/base.d.ts +99 -48
  30. package/dist/structures/embed.d.ts +65 -0
  31. package/dist/structures/index.d.ts +45 -25
  32. package/dist/structures/index.js +569 -36
  33. package/dist/structures/index.js.map +10 -8
  34. package/dist/structures/interactions.d.ts +72 -17
  35. package/dist/structures/resources.d.ts +9 -5
  36. package/dist/types/index.d.ts +530 -85
  37. package/dist/types/index.js +71 -1
  38. package/dist/types/index.js.map +3 -3
  39. package/dist/voice/index.js.map +1 -1
  40. package/dist/ws/index.js +4 -1
  41. package/dist/ws/index.js.map +4 -4
  42. package/package.json +15 -15
package/README.md CHANGED
@@ -2,26 +2,12 @@
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/lunibee.svg)](https://www.npmjs.com/package/lunibee)
4
4
  [![NPM Downloads](https://img.shields.io/npm/dt/lunibee.svg?style=flat-square)](https://www.npmjs.com/package/lunibee)
5
+ [![Discord](https://img.shields.io/badge/Discord-%235865F2.svg?style=flat-square&logo=discord&logoColor=white)](https://discord.gg/SSADgyBpgw)
5
6
 
6
7
  [![NPM Graph](https://nodei.co/npm/lunibee.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/lunibee)
7
8
 
8
9
  A lightweight, Bun-first Discord API library for TypeScript.
9
10
 
10
- ## Production-readiness status
11
-
12
- Lunibee's production-readiness work is being developed on `feat/production-readiness`. **Do not use `master` for active development.**
13
-
14
- The roadmap covers:
15
-
16
- - strict package dependency boundaries and installability
17
- - Discord Gateway lifecycle, heartbeat ACK handling, resume/reconnect, and zombie detection
18
- - canonical resource caching and shared REST/Gateway hydration
19
- - bucket-aware REST rate limits, retries, timeouts, and `AbortSignal` cancellation
20
- - typed permissions and ergonomic interaction APIs
21
- - compile-time-safe component and embed builders
22
- - graceful client and shard shutdown
23
- - public API documentation
24
-
25
11
  ## Requirements
26
12
 
27
13
  - [Bun](https://bun.sh/) for the supported runtime and package manager
@@ -42,6 +28,10 @@ For application usage, install the published `lunibee` package when a release is
42
28
  bun add lunibee
43
29
  ```
44
30
 
31
+ ## Documentation
32
+
33
+ Full documentation, practical guides, and API references are available at **[lunibee.js.org](https://lunibee.js.org)**.
34
+
45
35
  ## Getting started
46
36
 
47
37
  ```ts
@@ -168,13 +158,12 @@ Available lifecycle methods include `reply()`, `deferReply()`, `editReply()`, `d
168
158
 
169
159
  ## Builders
170
160
 
171
- Lunibee provides strict builders for Discord payloads, including:
161
+ Lunibee provides strict builders for Discord payloads (Discord.js V2 compatible), including:
172
162
 
173
- - `EmbedBuilder`
174
- - `ButtonBuilder`
175
163
  - `ActionRowBuilder`
176
- - `StringSelectBuilder`
177
- - `EntitySelectBuilder`
164
+ - `ButtonBuilder`
165
+ - `StringSelectMenuBuilder`
166
+ - `EmbedBuilder`
178
167
  - `ModalBuilder`
179
168
  - `TextInputBuilder`
180
169
 
@@ -223,11 +212,11 @@ bun install
223
212
  bunx tsc --noEmit
224
213
  ```
225
214
 
226
- Keep production-readiness work on the active feature branch and commit each completed phase separately. Changes must not be made directly on `master`.
215
+ ## Documentation & API Reference
227
216
 
228
- ## API reference
217
+ The full, official API reference and practical guides are available at **[lunibee.js.org](https://lunibee.js.org)**.
229
218
 
230
- The source is the authoritative API surface while Lunibee remains pre-1.0. Public exports are intentionally split by responsibility so applications can import either the high-level `lunibee` package or individual packages when appropriate.
219
+ The source remains the authoritative API surface while Lunibee is pre-1.0. Public exports are intentionally split by responsibility so applications can import either the high-level `lunibee` package or individual packages when appropriate.
231
220
 
232
221
  ## Status
233
222
 
@@ -8,6 +8,14 @@ export declare const ComponentType: {
8
8
  readonly RoleSelect: 6;
9
9
  readonly MentionableSelect: 7;
10
10
  readonly ChannelSelect: 8;
11
+ readonly Section: 9;
12
+ readonly TextDisplay: 10;
13
+ readonly Thumbnail: 11;
14
+ readonly MediaGallery: 12;
15
+ readonly File: 13;
16
+ readonly Separator: 14;
17
+ readonly ContentInventoryEntry: 16;
18
+ readonly Container: 17;
11
19
  };
12
20
  export declare const ButtonStyle: {
13
21
  readonly Primary: 1;
@@ -82,6 +90,53 @@ export interface APIActionRowComponent {
82
90
  type: typeof ComponentType.ActionRow;
83
91
  components: APIActionRowChild[];
84
92
  }
93
+ export interface APISectionComponent {
94
+ type: typeof ComponentType.Section;
95
+ components?: APIComponent[];
96
+ accessory?: APIComponent;
97
+ }
98
+ export interface APITextDisplayComponent {
99
+ type: typeof ComponentType.TextDisplay;
100
+ content: string;
101
+ }
102
+ export interface APIMediaGalleryComponent {
103
+ type: typeof ComponentType.MediaGallery;
104
+ items: {
105
+ media: {
106
+ url: string;
107
+ description?: string;
108
+ };
109
+ }[];
110
+ }
111
+ export interface APIFileComponent {
112
+ type: typeof ComponentType.File;
113
+ file: {
114
+ url: string;
115
+ };
116
+ spoiler?: boolean;
117
+ }
118
+ export interface APISeparatorComponent {
119
+ type: typeof ComponentType.Separator;
120
+ spacing?: 1 | 2;
121
+ divider?: boolean;
122
+ }
123
+ export interface APIThumbnailComponent {
124
+ type: typeof ComponentType.Thumbnail;
125
+ url: string;
126
+ proxy_url?: string;
127
+ width?: number;
128
+ height?: number;
129
+ }
130
+ export interface APIContentInventoryEntryComponent {
131
+ type: typeof ComponentType.ContentInventoryEntry;
132
+ id: string;
133
+ }
134
+ export interface APIContainerComponent {
135
+ type: typeof ComponentType.Container;
136
+ components: APIComponent[];
137
+ accent_color?: number;
138
+ }
139
+ export type APIComponent = APIActionRowComponent | APIButtonComponent | APIStringSelectComponent | APIEntitySelectComponent | APITextInputComponent | APISectionComponent | APITextDisplayComponent | APIThumbnailComponent | APIMediaGalleryComponent | APIFileComponent | APISeparatorComponent | APIContentInventoryEntryComponent | APIContainerComponent;
85
140
  export declare class ActionRowBuilder<T extends {
86
141
  toJSON(): APIActionRowChild;
87
142
  } = {
@@ -149,3 +204,56 @@ export declare class TextInputBuilder {
149
204
  setValue(value: string): this;
150
205
  toJSON(): APITextInputComponent;
151
206
  }
207
+ export declare class ContainerBuilder {
208
+ #private;
209
+ addComponents(...components: {
210
+ toJSON(): APIComponent;
211
+ }[]): this;
212
+ setAccentColor(color: number): this;
213
+ toJSON(): APIContainerComponent;
214
+ }
215
+ export declare class SectionBuilder {
216
+ #private;
217
+ addComponents(...components: {
218
+ toJSON(): APIComponent;
219
+ }[]): this;
220
+ setAccessory(accessory: {
221
+ toJSON(): APIComponent;
222
+ }): this;
223
+ toJSON(): APISectionComponent;
224
+ }
225
+ export declare class TextDisplayBuilder {
226
+ #private;
227
+ setContent(content: string): this;
228
+ toJSON(): APITextDisplayComponent;
229
+ }
230
+ export declare class MediaGalleryBuilder {
231
+ #private;
232
+ addItems(...items: {
233
+ url: string;
234
+ description?: string;
235
+ }[]): this;
236
+ toJSON(): APIMediaGalleryComponent;
237
+ }
238
+ export declare class FileComponentBuilder {
239
+ #private;
240
+ setUrl(url: string): this;
241
+ setSpoiler(spoiler?: boolean): this;
242
+ toJSON(): APIFileComponent;
243
+ }
244
+ export declare class SeparatorBuilder {
245
+ #private;
246
+ setSpacing(spacing: 1 | 2): this;
247
+ setDivider(divider?: boolean): this;
248
+ toJSON(): APISeparatorComponent;
249
+ }
250
+ export declare class ThumbnailBuilder {
251
+ #private;
252
+ setUrl(url: string): this;
253
+ toJSON(): APIThumbnailComponent;
254
+ }
255
+ export declare class ContentInventoryEntryBuilder {
256
+ #private;
257
+ setId(id: string): this;
258
+ toJSON(): APIContentInventoryEntryComponent;
259
+ }
@@ -1,5 +1,5 @@
1
1
  export { EmbedBuilder } from "./embed.js";
2
2
  export type { EmbedField } from "./embed.js";
3
- export { ButtonBuilder, ButtonStyle, ComponentType, ActionRowBuilder, StringSelectBuilder, EntitySelectBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, } from "./components.js";
3
+ export { ButtonBuilder, ButtonStyle, ComponentType, ActionRowBuilder, StringSelectBuilder, EntitySelectBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ContainerBuilder, SectionBuilder, TextDisplayBuilder, MediaGalleryBuilder, FileComponentBuilder, SeparatorBuilder, ThumbnailBuilder, ContentInventoryEntryBuilder, } from "./components.js";
4
4
  export { SlashCommandBuilder, StringOptionBuilder, IntegerOptionBuilder, NumberOptionBuilder, BooleanOptionBuilder, UserOptionBuilder, ChannelOptionBuilder, RoleOptionBuilder, MentionableOptionBuilder, AttachmentOptionBuilder, SubcommandBuilder, SubcommandGroupBuilder, ApplicationCommandOptionType, } from "./commands.js";
5
5
  export { AttachmentBuilder, type AttachmentData } from "./attachment.js";
@@ -119,7 +119,15 @@ var ComponentType = {
119
119
  UserSelect: 5,
120
120
  RoleSelect: 6,
121
121
  MentionableSelect: 7,
122
- ChannelSelect: 8
122
+ ChannelSelect: 8,
123
+ Section: 9,
124
+ TextDisplay: 10,
125
+ Thumbnail: 11,
126
+ MediaGallery: 12,
127
+ File: 13,
128
+ Separator: 14,
129
+ ContentInventoryEntry: 16,
130
+ Container: 17
123
131
  };
124
132
  var ButtonStyle = {
125
133
  Primary: 1,
@@ -379,6 +387,166 @@ class TextInputBuilder {
379
387
  return structuredClone(this.#data);
380
388
  }
381
389
  }
390
+
391
+ class ContainerBuilder {
392
+ #components = [];
393
+ #accentColor;
394
+ addComponents(...components) {
395
+ if (!components.length)
396
+ throw new TypeError("At least one component is required.");
397
+ this.#components.push(...components);
398
+ return this;
399
+ }
400
+ setAccentColor(color) {
401
+ if (!Number.isInteger(color) || color < 0 || color > 16777215) {
402
+ throw new RangeError("Accent color must be an integer between 0 and 16777215 (0xFFFFFF).");
403
+ }
404
+ this.#accentColor = color;
405
+ return this;
406
+ }
407
+ toJSON() {
408
+ return {
409
+ type: ComponentType.Container,
410
+ components: this.#components.map((c) => c.toJSON()),
411
+ accent_color: this.#accentColor
412
+ };
413
+ }
414
+ }
415
+
416
+ class SectionBuilder {
417
+ #components = [];
418
+ #accessory;
419
+ addComponents(...components) {
420
+ if (!components.length)
421
+ throw new TypeError("At least one component is required.");
422
+ this.#components.push(...components);
423
+ return this;
424
+ }
425
+ setAccessory(accessory) {
426
+ this.#accessory = accessory;
427
+ return this;
428
+ }
429
+ toJSON() {
430
+ return {
431
+ type: ComponentType.Section,
432
+ components: this.#components.length ? this.#components.map((c) => c.toJSON()) : undefined,
433
+ accessory: this.#accessory?.toJSON()
434
+ };
435
+ }
436
+ }
437
+
438
+ class TextDisplayBuilder {
439
+ #content = "";
440
+ setContent(content) {
441
+ validateText(content, 4000, "Text display content");
442
+ this.#content = content;
443
+ return this;
444
+ }
445
+ toJSON() {
446
+ return {
447
+ type: ComponentType.TextDisplay,
448
+ content: this.#content
449
+ };
450
+ }
451
+ }
452
+
453
+ class MediaGalleryBuilder {
454
+ #items = [];
455
+ addItems(...items) {
456
+ if (!items.length) {
457
+ throw new TypeError("At least one media gallery item is required.");
458
+ }
459
+ if (this.#items.length + items.length > 10) {
460
+ throw new RangeError("MediaGallery can only contain up to 10 items.");
461
+ }
462
+ this.#items.push(...items.map((item) => ({ media: item })));
463
+ return this;
464
+ }
465
+ toJSON() {
466
+ return {
467
+ type: ComponentType.MediaGallery,
468
+ items: structuredClone(this.#items)
469
+ };
470
+ }
471
+ }
472
+
473
+ class FileComponentBuilder {
474
+ #url = "";
475
+ #spoiler;
476
+ setUrl(url2) {
477
+ validateText(url2, 2048, "File component URL");
478
+ this.#url = url2;
479
+ return this;
480
+ }
481
+ setSpoiler(spoiler = true) {
482
+ this.#spoiler = spoiler;
483
+ return this;
484
+ }
485
+ toJSON() {
486
+ if (!this.#url)
487
+ throw new Error("File component must have a URL.");
488
+ const data = {
489
+ type: ComponentType.File,
490
+ file: { url: this.#url }
491
+ };
492
+ if (this.#spoiler !== undefined)
493
+ data.spoiler = this.#spoiler;
494
+ return data;
495
+ }
496
+ }
497
+
498
+ class SeparatorBuilder {
499
+ #spacing;
500
+ #divider;
501
+ setSpacing(spacing) {
502
+ this.#spacing = spacing;
503
+ return this;
504
+ }
505
+ setDivider(divider = true) {
506
+ this.#divider = divider;
507
+ return this;
508
+ }
509
+ toJSON() {
510
+ const data = {
511
+ type: ComponentType.Separator
512
+ };
513
+ if (this.#spacing !== undefined)
514
+ data.spacing = this.#spacing;
515
+ if (this.#divider !== undefined)
516
+ data.divider = this.#divider;
517
+ return data;
518
+ }
519
+ }
520
+
521
+ class ThumbnailBuilder {
522
+ #url = "";
523
+ setUrl(url2) {
524
+ validateText(url2, 2048, "Thumbnail URL");
525
+ this.#url = url2;
526
+ return this;
527
+ }
528
+ toJSON() {
529
+ return {
530
+ type: ComponentType.Thumbnail,
531
+ url: this.#url
532
+ };
533
+ }
534
+ }
535
+
536
+ class ContentInventoryEntryBuilder {
537
+ #id = "";
538
+ setId(id) {
539
+ validateText(id, 100, "Content inventory entry ID");
540
+ this.#id = id;
541
+ return this;
542
+ }
543
+ toJSON() {
544
+ return {
545
+ type: ComponentType.ContentInventoryEntry,
546
+ id: this.#id
547
+ };
548
+ }
549
+ }
382
550
  function validateText(value, max, field) {
383
551
  if (typeof value !== "string")
384
552
  throw new TypeError(`${field} must be a string.`);
@@ -808,21 +976,29 @@ export {
808
976
  ButtonStyle,
809
977
  ChannelOptionBuilder,
810
978
  ComponentType,
979
+ ContainerBuilder,
980
+ ContentInventoryEntryBuilder,
811
981
  EmbedBuilder,
812
982
  EntitySelectBuilder,
983
+ FileComponentBuilder,
813
984
  IntegerOptionBuilder,
985
+ MediaGalleryBuilder,
814
986
  MentionableOptionBuilder,
815
987
  ModalBuilder,
816
988
  NumberOptionBuilder,
817
989
  RoleOptionBuilder,
990
+ SectionBuilder,
991
+ SeparatorBuilder,
818
992
  SlashCommandBuilder,
819
993
  StringOptionBuilder,
820
994
  StringSelectBuilder,
821
995
  SubcommandBuilder,
822
996
  SubcommandGroupBuilder,
997
+ TextDisplayBuilder,
823
998
  TextInputBuilder,
824
999
  TextInputStyle,
1000
+ ThumbnailBuilder,
825
1001
  UserOptionBuilder
826
1002
  };
827
1003
 
828
- //# debugId=2D9849BFEE96124664756E2164756E21
1004
+ //# debugId=14619C67BE7B82B464756E2164756E21