lunibee 0.1.6 → 0.1.7

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 (55) hide show
  1. package/README.md +3 -3
  2. package/dist/builders/commands.d.ts +37 -0
  3. package/dist/builders/components.d.ts +19 -12
  4. package/dist/builders/embed.d.ts +3 -1
  5. package/dist/builders/index.d.ts +1 -1
  6. package/dist/builders/index.js +146 -19
  7. package/dist/builders/index.js.map +8 -7
  8. package/dist/collection/index.d.ts +30 -0
  9. package/dist/collection/index.js +78 -5
  10. package/dist/collection/index.js.map +4 -4
  11. package/dist/core/events.d.ts +2 -0
  12. package/dist/core/index.d.ts +38 -0
  13. package/dist/core/index.js +754 -175
  14. package/dist/core/index.js.map +24 -22
  15. package/dist/core/permissions.d.ts +112 -53
  16. package/dist/formatters/index.d.ts +43 -3
  17. package/dist/formatters/index.js +64 -1
  18. package/dist/formatters/index.js.map +3 -3
  19. package/dist/handlers/index.js.map +2 -2
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +1762 -291
  22. package/dist/index.js.map +43 -38
  23. package/dist/managers/emoji.d.ts +38 -0
  24. package/dist/managers/guild.d.ts +112 -1
  25. package/dist/managers/index.d.ts +31 -1
  26. package/dist/managers/index.js +803 -77
  27. package/dist/managers/index.js.map +21 -20
  28. package/dist/rest/index.d.ts +101 -11
  29. package/dist/rest/index.js +301 -45
  30. package/dist/rest/index.js.map +8 -6
  31. package/dist/rest/redis.d.ts +37 -0
  32. package/dist/rest/routes.d.ts +22 -0
  33. package/dist/rest/store.d.ts +38 -0
  34. package/dist/rest/webhook.d.ts +2 -2
  35. package/dist/sharding/cluster.d.ts +61 -0
  36. package/dist/sharding/index.d.ts +8 -0
  37. package/dist/sharding/index.js +286 -18
  38. package/dist/sharding/index.js.map +8 -7
  39. package/dist/structures/audit-log.d.ts +26 -0
  40. package/dist/structures/base.d.ts +32 -0
  41. package/dist/structures/index.d.ts +29 -1
  42. package/dist/structures/index.js +1022 -86
  43. package/dist/structures/index.js.map +14 -10
  44. package/dist/structures/resources.d.ts +192 -4
  45. package/dist/types/index.d.ts +76 -0
  46. package/dist/types/index.js.map +2 -2
  47. package/dist/utils/index.js.map +2 -2
  48. package/dist/voice/index.d.ts +88 -0
  49. package/dist/voice/index.js +204 -5
  50. package/dist/voice/index.js.map +3 -3
  51. package/dist/ws/index.d.ts +40 -1
  52. package/dist/ws/index.js +102 -18
  53. package/dist/ws/index.js.map +4 -4
  54. package/package.json +16 -16
  55. package/dist/structures/permissions.d.ts +0 -73
package/README.md CHANGED
@@ -132,10 +132,10 @@ REST-created and Gateway-updated resources are routed through manager cache muta
132
132
 
133
133
  ## Permissions
134
134
 
135
- `PermissionsBitField` provides named and raw permission checks:
135
+ `PermissionSet` provides named and raw permission checks:
136
136
 
137
137
  ```ts
138
- if (member.permissions.has("ManageMessages")) {
138
+ if (member.permissions.has(Permission.manageMessages)) {
139
139
  // permitted
140
140
  }
141
141
  ```
@@ -162,7 +162,7 @@ Lunibee provides strict builders for Discord payloads (Discord.js V2 compatible)
162
162
 
163
163
  - `ActionRowBuilder`
164
164
  - `ButtonBuilder`
165
- - `StringSelectMenuBuilder`
165
+ - `StringSelectBuilder`
166
166
  - `EmbedBuilder`
167
167
  - `ModalBuilder`
168
168
  - `TextInputBuilder`
@@ -116,3 +116,40 @@ export declare class NumberOptionBuilder extends CommandOptionBuilder {
116
116
  /** Creates a subcommand group. */ constructor();
117
117
  /** Adds a subcommand to this group. */ addSubcommand(configure: (option: SubcommandBuilder) => SubcommandBuilder): this;
118
118
  }
119
+ /** Base builder for application commands that appear in right-click context menus. */
120
+ declare class ContextMenuCommandBuilder {
121
+ protected readonly data: Record<string, unknown>;
122
+ constructor(type: 2 | 3);
123
+ /** Sets the command name (shown in the right-click menu).
124
+ * Unlike CHAT_INPUT commands, USER (type 2) and MESSAGE (type 3) context-menu
125
+ * command names may contain uppercase letters and spaces, so no lowercase/charset
126
+ * validation is applied here — only Discord's 1-32 length limit and a non-empty
127
+ * (non-whitespace) requirement are enforced.
128
+ * @param name Display name; 1-32 characters, mixed case and spaces allowed.
129
+ * @throws {RangeError} If the name is empty/whitespace-only or exceeds 32 characters.
130
+ */
131
+ setName(name: string): this;
132
+ /** Sets default member permissions required to see this command. */
133
+ setDefaultMemberPermissions(permissions: bigint | number | string | null): this;
134
+ /** Sets whether the command is available in direct messages. */
135
+ setDMPermission(enabled: boolean): this;
136
+ /** Sets command integration types. */
137
+ setIntegrationTypes(...types: number[]): this;
138
+ /** Serializes the command payload for the Discord API. */
139
+ toJSON(): Record<string, unknown>;
140
+ }
141
+ /** Builds a User context menu command (appears when right-clicking a user, type 2).
142
+ * @example
143
+ * new UserCommandBuilder().setName("View Profile").toJSON()
144
+ */
145
+ export declare class UserCommandBuilder extends ContextMenuCommandBuilder {
146
+ constructor();
147
+ }
148
+ /** Builds a Message context menu command (appears when right-clicking a message, type 3).
149
+ * @example
150
+ * new MessageCommandBuilder().setName("Translate Message").toJSON()
151
+ */
152
+ export declare class MessageCommandBuilder extends ContextMenuCommandBuilder {
153
+ constructor();
154
+ }
155
+ export {};
@@ -1,3 +1,5 @@
1
+ import { ButtonStyle } from "@lunibee/types";
2
+ export { ButtonStyle };
1
3
  /** Component type constants exposed by Lunibee. */
2
4
  export declare const ComponentType: {
3
5
  readonly ActionRow: 1;
@@ -17,13 +19,6 @@ export declare const ComponentType: {
17
19
  readonly ContentInventoryEntry: 16;
18
20
  readonly Container: 17;
19
21
  };
20
- export declare const ButtonStyle: {
21
- readonly Primary: 1;
22
- readonly Secondary: 2;
23
- readonly Success: 3;
24
- readonly Danger: 4;
25
- readonly Link: 5;
26
- };
27
22
  export declare const TextInputStyle: {
28
23
  readonly Short: 1;
29
24
  readonly Paragraph: 2;
@@ -35,7 +30,7 @@ export interface APIComponentEmoji {
35
30
  }
36
31
  export interface APIButtonComponent {
37
32
  type: typeof ComponentType.Button;
38
- style: 1 | 2 | 3 | 4 | 5;
33
+ style: 1 | 2 | 3 | 4 | 5 | 6;
39
34
  custom_id?: string;
40
35
  label?: string;
41
36
  emoji?: APIComponentEmoji;
@@ -67,6 +62,7 @@ export interface APIEntitySelectComponent {
67
62
  max_values?: number;
68
63
  required?: boolean;
69
64
  disabled?: boolean;
65
+ default_values?: APISelectDefaultValue[];
70
66
  }
71
67
  export interface APITextInputComponent {
72
68
  type: typeof ComponentType.TextInput;
@@ -108,6 +104,11 @@ export interface APIMediaGalleryComponent {
108
104
  };
109
105
  }[];
110
106
  }
107
+ /** Default values accepted by an auto-populated entity select. */
108
+ export interface APISelectDefaultValue {
109
+ id: string;
110
+ type: "user" | "role" | "channel";
111
+ }
111
112
  export interface APIFileComponent {
112
113
  type: typeof ComponentType.File;
113
114
  file: {
@@ -126,6 +127,8 @@ export interface APIThumbnailComponent {
126
127
  proxy_url?: string;
127
128
  width?: number;
128
129
  height?: number;
130
+ description?: string;
131
+ spoiler?: boolean;
129
132
  }
130
133
  export interface APIContentInventoryEntryComponent {
131
134
  type: typeof ComponentType.ContentInventoryEntry;
@@ -135,6 +138,7 @@ export interface APIContainerComponent {
135
138
  type: typeof ComponentType.Container;
136
139
  components: APIComponent[];
137
140
  accent_color?: number;
141
+ spoiler?: boolean;
138
142
  }
139
143
  export type APIComponent = APIActionRowComponent | APIButtonComponent | APIStringSelectComponent | APIEntitySelectComponent | APITextInputComponent | APISectionComponent | APITextDisplayComponent | APIThumbnailComponent | APIMediaGalleryComponent | APIFileComponent | APISeparatorComponent | APIContentInventoryEntryComponent | APIContainerComponent;
140
144
  export declare class ActionRowBuilder<T extends {
@@ -177,10 +181,7 @@ export declare class EntitySelectBuilder {
177
181
  setMaxValues(value: number): this;
178
182
  setRequired(value?: boolean): this;
179
183
  setDisabled(value?: boolean): this;
180
- setDefaultValues(...values: {
181
- id: string;
182
- type: "user" | "role" | "channel";
183
- }[]): this;
184
+ setDefaultValues(...values: APISelectDefaultValue[]): this;
184
185
  toJSON(): APIEntitySelectComponent;
185
186
  }
186
187
  export declare class ModalBuilder {
@@ -210,6 +211,8 @@ export declare class ContainerBuilder {
210
211
  toJSON(): APIComponent;
211
212
  }[]): this;
212
213
  setAccentColor(color: number): this;
214
+ /** Marks the whole container as a spoiler (blurred until clicked). */
215
+ setSpoiler(spoiler?: boolean): this;
213
216
  toJSON(): APIContainerComponent;
214
217
  }
215
218
  export declare class SectionBuilder {
@@ -250,6 +253,10 @@ export declare class SeparatorBuilder {
250
253
  export declare class ThumbnailBuilder {
251
254
  #private;
252
255
  setUrl(url: string): this;
256
+ /** Sets the thumbnail's alt-text description. */
257
+ setDescription(description: string): this;
258
+ /** Marks the thumbnail as a spoiler (blurred until clicked). */
259
+ setSpoiler(spoiler?: boolean): this;
253
260
  toJSON(): APIThumbnailComponent;
254
261
  }
255
262
  export declare class ContentInventoryEntryBuilder {
@@ -48,7 +48,9 @@ export declare class EmbedBuilder {
48
48
  /** Sets the image URL. @param value Image URL or payload. @returns This builder. @throws {TypeError} If URL is invalid. */ setImage(value: {
49
49
  url: string;
50
50
  } | string): this;
51
- /** Adds embed fields. @param fields Field payloads. @returns This builder. @throws {RangeError} If the 25-field limit is exceeded. */ addFields(...fields: EmbedField[]): this;
51
+ /** Adds embed fields. Accepts both the spread form `addFields(a, b)` and the
52
+ * single-array form `addFields([a, b])` for discord.js `RestOrArray` parity.
53
+ * @param fields Field payloads, spread or as a single array. @returns This builder. @throws {RangeError} If the 25-field limit is exceeded. */ addFields(...fields: EmbedField[] | [EmbedField[]]): this;
52
54
  setFields(fields: EmbedField[]): this;
53
55
  /** Replaces fields starting at an index. @param index Start index. @param deleteCount Number of fields to remove. @param fields Replacement fields. @returns This builder. @throws {RangeError} If arguments are invalid or the 25-field limit is exceeded. */ spliceFields(index: number, deleteCount: number, ...fields: EmbedField[]): this;
54
56
  /** Removes all embed fields. @returns This builder. */ clearFields(): this;
@@ -1,5 +1,5 @@
1
1
  export { EmbedBuilder } from "./embed.js";
2
2
  export type { EmbedField } from "./embed.js";
3
3
  export { ButtonBuilder, ButtonStyle, ComponentType, ActionRowBuilder, StringSelectBuilder, EntitySelectBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ContainerBuilder, SectionBuilder, TextDisplayBuilder, MediaGalleryBuilder, FileComponentBuilder, SeparatorBuilder, ThumbnailBuilder, ContentInventoryEntryBuilder, } from "./components.js";
4
- export { SlashCommandBuilder, StringOptionBuilder, IntegerOptionBuilder, NumberOptionBuilder, BooleanOptionBuilder, UserOptionBuilder, ChannelOptionBuilder, RoleOptionBuilder, MentionableOptionBuilder, AttachmentOptionBuilder, SubcommandBuilder, SubcommandGroupBuilder, ApplicationCommandOptionType, } from "./commands.js";
4
+ export { SlashCommandBuilder, StringOptionBuilder, IntegerOptionBuilder, NumberOptionBuilder, BooleanOptionBuilder, UserOptionBuilder, ChannelOptionBuilder, RoleOptionBuilder, MentionableOptionBuilder, AttachmentOptionBuilder, SubcommandBuilder, SubcommandGroupBuilder, ApplicationCommandOptionType, UserCommandBuilder, MessageCommandBuilder, } from "./commands.js";
5
5
  export { AttachmentBuilder, type AttachmentData } from "./attachment.js";
@@ -53,16 +53,20 @@ class EmbedBuilder {
53
53
  return this;
54
54
  }
55
55
  addFields(...fields) {
56
- if (!fields.length)
56
+ const resolved = fields.length === 1 && Array.isArray(fields[0]) ? fields[0] : fields;
57
+ if (!resolved.length)
57
58
  throw new TypeError("At least one embed field is required.");
58
59
  const current = this.#data.fields ?? [];
59
- if (current.length + fields.length > 25)
60
+ if (current.length + resolved.length > 25)
60
61
  throw new RangeError("An embed cannot contain more than 25 fields.");
61
- for (const field of fields) {
62
+ for (const field of resolved) {
62
63
  validate(field.name, 256, "Embed field name");
63
64
  validate(field.value, 1024, "Embed field value");
64
65
  }
65
- this.#data.fields = [...current, ...fields.map((field) => ({ ...field }))];
66
+ this.#data.fields = [
67
+ ...current,
68
+ ...resolved.map((field) => ({ ...field }))
69
+ ];
66
70
  return this;
67
71
  }
68
72
  setFields(fields) {
@@ -110,6 +114,67 @@ function url(value, field) {
110
114
  throw new TypeError(`${field} must be a valid URL.`, { cause: error });
111
115
  }
112
116
  }
117
+ // packages/types/src/index.ts
118
+ var GatewayIntentBits = {
119
+ Guilds: 1 << 0,
120
+ GuildMembers: 1 << 1,
121
+ GuildModeration: 1 << 2,
122
+ GuildExpressions: 1 << 3,
123
+ GuildIntegrations: 1 << 4,
124
+ GuildWebhooks: 1 << 5,
125
+ GuildInvites: 1 << 6,
126
+ GuildVoiceStates: 1 << 7,
127
+ GuildPresences: 1 << 8,
128
+ GuildMessages: 1 << 9,
129
+ GuildMessageReactions: 1 << 10,
130
+ GuildMessageTyping: 1 << 11,
131
+ DirectMessages: 1 << 12,
132
+ DirectMessageReactions: 1 << 13,
133
+ DirectMessageTyping: 1 << 14,
134
+ MessageContent: 1 << 15,
135
+ GuildScheduledEvents: 1 << 16,
136
+ AutoModerationConfiguration: 1 << 20,
137
+ AutoModerationExecution: 1 << 21,
138
+ GuildMessagePolls: 1 << 24,
139
+ DirectMessagePolls: 1 << 25
140
+ };
141
+ var IntentBits = {
142
+ guild: 1 << 0,
143
+ guilds: 1 << 0,
144
+ guildMembers: 1 << 1,
145
+ guildModeration: 1 << 2,
146
+ guildBans: 1 << 2,
147
+ guildExpressions: 1 << 3,
148
+ guildEmojis: 1 << 3,
149
+ guildEmojisAndStickers: 1 << 3,
150
+ guildIntegrations: 1 << 4,
151
+ guildWebhooks: 1 << 5,
152
+ guildInvites: 1 << 6,
153
+ guildVoiceStates: 1 << 7,
154
+ guildPresences: 1 << 8,
155
+ guildMessages: 1 << 9,
156
+ guildMessage: 1 << 9,
157
+ guildMessageReactions: 1 << 10,
158
+ guildMessageTyping: 1 << 11,
159
+ directMessages: 1 << 12,
160
+ directMessageReactions: 1 << 13,
161
+ directMessageTyping: 1 << 14,
162
+ messageContent: 1 << 15,
163
+ guildScheduledEvents: 1 << 16,
164
+ autoModerationConfiguration: 1 << 20,
165
+ autoModerationExecution: 1 << 21,
166
+ guildMessagePolls: 1 << 24,
167
+ directMessagePolls: 1 << 25
168
+ };
169
+ var ButtonStyle = {
170
+ Primary: 1,
171
+ Secondary: 2,
172
+ Success: 3,
173
+ Danger: 4,
174
+ Link: 5,
175
+ Premium: 6
176
+ };
177
+
113
178
  // packages/builders/src/components.ts
114
179
  var ComponentType = {
115
180
  ActionRow: 1,
@@ -129,13 +194,6 @@ var ComponentType = {
129
194
  ContentInventoryEntry: 16,
130
195
  Container: 17
131
196
  };
132
- var ButtonStyle = {
133
- Primary: 1,
134
- Secondary: 2,
135
- Success: 3,
136
- Danger: 4,
137
- Link: 5
138
- };
139
197
  var TextInputStyle = { Short: 1, Paragraph: 2 };
140
198
 
141
199
  class ActionRowBuilder {
@@ -244,7 +302,9 @@ class ButtonBuilder {
244
302
  try {
245
303
  url2 = new URL(value);
246
304
  } catch (error) {
247
- throw new TypeError("Button URL must be a valid URL.", { cause: error });
305
+ throw new TypeError("Button URL must be a valid URL.", {
306
+ cause: error
307
+ });
248
308
  }
249
309
  this.#data.style = ButtonStyle.Link;
250
310
  delete this.#data.custom_id;
@@ -300,7 +360,7 @@ class EntitySelectBuilder {
300
360
  return this;
301
361
  }
302
362
  setDefaultValues(...values) {
303
- this.#data.default_values = values;
363
+ this.#data.default_values = values.map((value) => ({ ...value }));
304
364
  return this;
305
365
  }
306
366
  toJSON() {
@@ -391,6 +451,7 @@ class TextInputBuilder {
391
451
  class ContainerBuilder {
392
452
  #components = [];
393
453
  #accentColor;
454
+ #spoiler;
394
455
  addComponents(...components) {
395
456
  if (!components.length)
396
457
  throw new TypeError("At least one component is required.");
@@ -404,12 +465,20 @@ class ContainerBuilder {
404
465
  this.#accentColor = color;
405
466
  return this;
406
467
  }
468
+ setSpoiler(spoiler = true) {
469
+ this.#spoiler = spoiler;
470
+ return this;
471
+ }
407
472
  toJSON() {
408
- return {
473
+ const data = {
409
474
  type: ComponentType.Container,
410
- components: this.#components.map((c) => c.toJSON()),
411
- accent_color: this.#accentColor
475
+ components: this.#components.map((c) => c.toJSON())
412
476
  };
477
+ if (this.#accentColor !== undefined)
478
+ data.accent_color = this.#accentColor;
479
+ if (this.#spoiler !== undefined)
480
+ data.spoiler = this.#spoiler;
481
+ return data;
413
482
  }
414
483
  }
415
484
 
@@ -520,16 +589,32 @@ class SeparatorBuilder {
520
589
 
521
590
  class ThumbnailBuilder {
522
591
  #url = "";
592
+ #description;
593
+ #spoiler;
523
594
  setUrl(url2) {
524
595
  validateText(url2, 2048, "Thumbnail URL");
525
596
  this.#url = url2;
526
597
  return this;
527
598
  }
599
+ setDescription(description) {
600
+ validateText(description, 1024, "Thumbnail description");
601
+ this.#description = description;
602
+ return this;
603
+ }
604
+ setSpoiler(spoiler = true) {
605
+ this.#spoiler = spoiler;
606
+ return this;
607
+ }
528
608
  toJSON() {
529
- return {
609
+ const data = {
530
610
  type: ComponentType.Thumbnail,
531
611
  url: this.#url
532
612
  };
613
+ if (this.#description !== undefined)
614
+ data.description = this.#description;
615
+ if (this.#spoiler !== undefined)
616
+ data.spoiler = this.#spoiler;
617
+ return data;
533
618
  }
534
619
  }
535
620
 
@@ -918,6 +1003,46 @@ function validateNumberRange(value, minimum, maximum, field, integerOnly = true)
918
1003
  if (!Number.isFinite(value) || integerOnly && !Number.isInteger(value) || value < minimum || value > maximum)
919
1004
  throw new RangeError(`${field} must be ${integerOnly ? "an integer" : "a number"} between ${minimum} and ${maximum}.`);
920
1005
  }
1006
+
1007
+ class ContextMenuCommandBuilder {
1008
+ data;
1009
+ constructor(type) {
1010
+ this.data = { type };
1011
+ }
1012
+ setName(name) {
1013
+ if (typeof name !== "string" || name.trim().length < 1 || name.length > 32)
1014
+ throw new RangeError("Command name must contain 1-32 characters.");
1015
+ this.data.name = name;
1016
+ return this;
1017
+ }
1018
+ setDefaultMemberPermissions(permissions) {
1019
+ this.data.default_member_permissions = permissions === null ? null : BigInt(permissions).toString();
1020
+ return this;
1021
+ }
1022
+ setDMPermission(enabled) {
1023
+ this.data.dm_permission = enabled;
1024
+ return this;
1025
+ }
1026
+ setIntegrationTypes(...types) {
1027
+ this.data.integration_types = [...types];
1028
+ return this;
1029
+ }
1030
+ toJSON() {
1031
+ return structuredClone(this.data);
1032
+ }
1033
+ }
1034
+
1035
+ class UserCommandBuilder extends ContextMenuCommandBuilder {
1036
+ constructor() {
1037
+ super(2);
1038
+ }
1039
+ }
1040
+
1041
+ class MessageCommandBuilder extends ContextMenuCommandBuilder {
1042
+ constructor() {
1043
+ super(3);
1044
+ }
1045
+ }
921
1046
  // packages/builders/src/attachment.ts
922
1047
  import { readFile } from "fs/promises";
923
1048
  import { basename } from "path";
@@ -963,7 +1088,7 @@ class AttachmentBuilder {
963
1088
  if (typeof Buffer !== "undefined" && Buffer.isBuffer(this.file)) {
964
1089
  return new Uint8Array(this.file);
965
1090
  }
966
- return new Uint8Array;
1091
+ throw new TypeError("Attachment file must be a supported binary value or file path.");
967
1092
  }
968
1093
  }
969
1094
  export {
@@ -984,6 +1109,7 @@ export {
984
1109
  IntegerOptionBuilder,
985
1110
  MediaGalleryBuilder,
986
1111
  MentionableOptionBuilder,
1112
+ MessageCommandBuilder,
987
1113
  ModalBuilder,
988
1114
  NumberOptionBuilder,
989
1115
  RoleOptionBuilder,
@@ -998,7 +1124,8 @@ export {
998
1124
  TextInputBuilder,
999
1125
  TextInputStyle,
1000
1126
  ThumbnailBuilder,
1127
+ UserCommandBuilder,
1001
1128
  UserOptionBuilder
1002
1129
  };
1003
1130
 
1004
- //# debugId=14619C67BE7B82B464756E2164756E21
1131
+ //# debugId=1FE9A1C7B4113D0264756E2164756E21