novaapp-sdk 1.0.9 → 1.1.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.
package/dist/index.mjs CHANGED
@@ -240,8 +240,9 @@ var ServersAPI = class {
240
240
 
241
241
  // src/api/interactions.ts
242
242
  var InteractionsAPI = class {
243
- constructor(http) {
243
+ constructor(http, emitter) {
244
244
  this.http = http;
245
+ this.emitter = emitter;
245
246
  }
246
247
  /**
247
248
  * Acknowledge an interaction without sending a visible response.
@@ -290,6 +291,71 @@ var InteractionsAPI = class {
290
291
  const qs = params.toString();
291
292
  return this.http.get(`/interactions${qs ? `?${qs}` : ""}`);
292
293
  }
294
+ /**
295
+ * Open a modal for the user who triggered an interaction and await their submission.
296
+ *
297
+ * Internally this:
298
+ * 1. Calls `respond(interactionId, { modal })` to push the modal to the client UI.
299
+ * 2. Listens for the next `interactionCreate` event whose type is `MODAL_SUBMIT`
300
+ * and whose `customId` matches your modal's `customId`.
301
+ * 3. Resolves with the submitted `Interaction` (containing `modalData`), or `null`
302
+ * if the user closes the modal without submitting within the timeout.
303
+ *
304
+ * @param interactionId - ID of the triggering interaction.
305
+ * @param modal - Modal definition (title, customId, fields).
306
+ * @param options.timeout - Max milliseconds to wait (default: 300 000 = 5 min).
307
+ *
308
+ * @example
309
+ * client.on('interactionCreate', async (interaction) => {
310
+ * if (interaction.commandName === 'report') {
311
+ * const submitted = await client.interactions.awaitModal(interaction.id, {
312
+ * title: 'Submit a report',
313
+ * customId: 'report_modal',
314
+ * fields: [
315
+ * { customId: 'reason', label: 'Reason', type: 'paragraph', required: true, maxLength: 500 },
316
+ * ],
317
+ * })
318
+ *
319
+ * if (!submitted) {
320
+ * // User dismissed the modal or timed out — nothing to do
321
+ * return
322
+ * }
323
+ *
324
+ * const reason = submitted.modalData?.reason
325
+ * await client.interactions.respond(submitted.id, {
326
+ * content: `Report received: ${reason}`,
327
+ * ephemeral: true,
328
+ * })
329
+ * }
330
+ * })
331
+ */
332
+ awaitModal(interactionId, modal, options = {}) {
333
+ const ms = options.timeout ?? 3e5;
334
+ let listener = null;
335
+ let timer = null;
336
+ const waitPromise = new Promise((resolve) => {
337
+ timer = setTimeout(() => {
338
+ if (listener) this.emitter.off("interactionCreate", listener);
339
+ resolve(null);
340
+ }, ms);
341
+ listener = (interaction) => {
342
+ if (interaction.type === "MODAL_SUBMIT" && interaction.customId === modal.customId) {
343
+ if (timer) clearTimeout(timer);
344
+ if (listener) this.emitter.off("interactionCreate", listener);
345
+ resolve(interaction);
346
+ }
347
+ };
348
+ this.emitter.on("interactionCreate", listener);
349
+ });
350
+ return this.respond(interactionId, { modal }).then(
351
+ () => waitPromise,
352
+ (err) => {
353
+ if (timer) clearTimeout(timer);
354
+ if (listener) this.emitter.off("interactionCreate", listener);
355
+ return Promise.reject(err);
356
+ }
357
+ );
358
+ }
293
359
  };
294
360
 
295
361
  // src/api/permissions.ts
@@ -336,6 +402,185 @@ var PermissionsAPI = class {
336
402
  }
337
403
  };
338
404
 
405
+ // src/structures/NovaInteraction.ts
406
+ var InteractionOptions = class {
407
+ constructor(data) {
408
+ this._map = /* @__PURE__ */ new Map();
409
+ if (data && typeof data === "object") {
410
+ const d = data;
411
+ const opts = Array.isArray(d.options) ? d.options : [];
412
+ for (const o of opts) {
413
+ if (o?.name != null) this._map.set(String(o.name), o.value);
414
+ }
415
+ }
416
+ }
417
+ /** Whether this option was supplied by the user. */
418
+ has(name) {
419
+ return this._map.has(name);
420
+ }
421
+ getString(name, required = false) {
422
+ const v = this._map.get(name);
423
+ if (required && (v == null || v === "")) throw new Error(`Required option "${name}" is missing`);
424
+ return v != null ? String(v) : null;
425
+ }
426
+ getInteger(name, required = false) {
427
+ const v = this._map.get(name);
428
+ if (required && v == null) throw new Error(`Required option "${name}" is missing`);
429
+ return v != null ? Math.trunc(Number(v)) : null;
430
+ }
431
+ getNumber(name, required = false) {
432
+ const v = this._map.get(name);
433
+ if (required && v == null) throw new Error(`Required option "${name}" is missing`);
434
+ return v != null ? Number(v) : null;
435
+ }
436
+ /** Returns `true` or `false`, or `null` if not supplied. */
437
+ getBoolean(name) {
438
+ const v = this._map.get(name);
439
+ return v != null ? Boolean(v) : null;
440
+ }
441
+ getUser(name, required = false) {
442
+ return this.getString(name, required);
443
+ }
444
+ getChannel(name, required = false) {
445
+ return this.getString(name, required);
446
+ }
447
+ getRole(name, required = false) {
448
+ return this.getString(name, required);
449
+ }
450
+ };
451
+ var NovaInteraction = class _NovaInteraction {
452
+ constructor(_raw, _api) {
453
+ this._raw = _raw;
454
+ this._api = _api;
455
+ this.id = _raw.id;
456
+ this.type = _raw.type;
457
+ this.commandName = _raw.commandName ?? null;
458
+ this.customId = _raw.customId ?? null;
459
+ this.userId = _raw.userId;
460
+ this.channelId = _raw.channelId;
461
+ this.serverId = _raw.serverId ?? null;
462
+ this.triggerMsgId = _raw.triggerMsgId ?? null;
463
+ this.values = _raw.values ?? [];
464
+ this.modalData = _raw.modalData ?? {};
465
+ this.createdAt = _raw.createdAt;
466
+ this.options = new InteractionOptions(_raw.data);
467
+ }
468
+ // ── Type guards ─────────────────────────────────────────────────────────────
469
+ /** `true` when triggered by a `/slash` command. */
470
+ isSlashCommand() {
471
+ return this.type === "SLASH_COMMAND";
472
+ }
473
+ /** `true` when triggered by a `!prefix` command. */
474
+ isPrefixCommand() {
475
+ return this.type === "PREFIX_COMMAND";
476
+ }
477
+ /** `true` for both slash and prefix commands. */
478
+ isCommand() {
479
+ return this.isSlashCommand() || this.isPrefixCommand();
480
+ }
481
+ /** `true` when a button component was clicked. */
482
+ isButton() {
483
+ return this.type === "BUTTON_CLICK";
484
+ }
485
+ /** `true` when a select-menu option was chosen. */
486
+ isSelectMenu() {
487
+ return this.type === "SELECT_MENU";
488
+ }
489
+ /** `true` when the user submitted a modal form. */
490
+ isModalSubmit() {
491
+ return this.type === "MODAL_SUBMIT";
492
+ }
493
+ /** `true` during autocomplete suggestion requests. */
494
+ isAutocomplete() {
495
+ return this.type === "AUTOCOMPLETE";
496
+ }
497
+ /** `true` when triggered via a context-menu command. */
498
+ isContextMenu() {
499
+ return this.type === "CONTEXT_MENU";
500
+ }
501
+ // ── Actions ─────────────────────────────────────────────────────────────────
502
+ /**
503
+ * Respond with a message.
504
+ * Accepts a plain string or a full options object.
505
+ *
506
+ * @example
507
+ * await interaction.reply('Pong! 🏓')
508
+ * await interaction.reply({ content: 'Done!', ephemeral: true })
509
+ * await interaction.reply({ embed: new EmbedBuilder().setTitle('Stats').toJSON() })
510
+ */
511
+ reply(options) {
512
+ return this._api.respond(this.id, typeof options === "string" ? { content: options } : options);
513
+ }
514
+ /**
515
+ * Respond with a message **only visible to the user** who triggered the interaction.
516
+ *
517
+ * @example
518
+ * await interaction.replyEphemeral('Only you can see this!')
519
+ */
520
+ replyEphemeral(options) {
521
+ const resolved = typeof options === "string" ? { content: options } : options;
522
+ return this._api.respond(this.id, { ...resolved, ephemeral: true });
523
+ }
524
+ /**
525
+ * Acknowledge the interaction without sending a response yet.
526
+ * Shows a loading indicator to the user.
527
+ * Follow up with `interaction.editReply()` when you're done.
528
+ *
529
+ * @example
530
+ * await interaction.defer()
531
+ * const data = await fetchSomeSlow()
532
+ * await interaction.editReply({ content: `Result: ${data}` })
533
+ */
534
+ defer() {
535
+ return this._api.ack(this.id);
536
+ }
537
+ /**
538
+ * Edit the previous reply (e.g. after `defer()`).
539
+ *
540
+ * @example
541
+ * await interaction.defer()
542
+ * await interaction.editReply(`Done — processed ${count} items.`)
543
+ */
544
+ editReply(options) {
545
+ return this._api.respond(this.id, typeof options === "string" ? { content: options } : options);
546
+ }
547
+ /**
548
+ * Open a **modal dialog** and return the user's submission as a new `NovaInteraction`.
549
+ * Returns `null` if the user closes the modal or the timeout expires (default: 5 min).
550
+ *
551
+ * **This is the recommended way to open modals.**
552
+ *
553
+ * @example
554
+ * const submitted = await interaction.openModal(
555
+ * new ModalBuilder()
556
+ * .setTitle('Submit a report')
557
+ * .setCustomId('report_modal')
558
+ * .addField(
559
+ * new TextInputBuilder()
560
+ * .setCustomId('reason')
561
+ * .setLabel('Reason')
562
+ * .setStyle('paragraph')
563
+ * .setRequired(true)
564
+ * )
565
+ * )
566
+ *
567
+ * if (!submitted) return // user dismissed or timed out
568
+ *
569
+ * const reason = submitted.modalData.reason
570
+ * await submitted.replyEphemeral(`Report received: ${reason}`)
571
+ */
572
+ async openModal(modal, options = {}) {
573
+ const def = "toJSON" in modal && typeof modal.toJSON === "function" ? modal.toJSON() : modal;
574
+ const raw = await this._api.awaitModal(this.id, def, options);
575
+ if (!raw) return null;
576
+ return new _NovaInteraction(raw, this._api);
577
+ }
578
+ /** Returns the raw interaction data from the gateway. */
579
+ toJSON() {
580
+ return { ...this._raw };
581
+ }
582
+ };
583
+
339
584
  // src/client.ts
340
585
  var EVENT_MAP = {
341
586
  "message.created": "messageCreate",
@@ -353,6 +598,10 @@ var NovaClient = class extends EventEmitter {
353
598
  /** The authenticated bot application. Available after `ready` fires. */
354
599
  this.botUser = null;
355
600
  this.socket = null;
601
+ // ── Command / component routing ───────────────────────────────────────────────────
602
+ this._commandHandlers = /* @__PURE__ */ new Map();
603
+ this._buttonHandlers = /* @__PURE__ */ new Map();
604
+ this._selectHandlers = /* @__PURE__ */ new Map();
356
605
  if (!options.token) {
357
606
  throw new Error("[nova-bot-sdk] A bot token is required.");
358
607
  }
@@ -368,7 +617,7 @@ var NovaClient = class extends EventEmitter {
368
617
  this.commands = new CommandsAPI(this.http);
369
618
  this.members = new MembersAPI(this.http);
370
619
  this.servers = new ServersAPI(this.http);
371
- this.interactions = new InteractionsAPI(this.http);
620
+ this.interactions = new InteractionsAPI(this.http, this);
372
621
  this.permissions = new PermissionsAPI(this.http);
373
622
  this.on("error", () => {
374
623
  });
@@ -383,6 +632,44 @@ var NovaClient = class extends EventEmitter {
383
632
  process.exit(0);
384
633
  });
385
634
  }
635
+ /**
636
+ * Register a handler for a slash or prefix command by name.
637
+ * Automatically routes `interactionCreate` events whose `commandName` matches.
638
+ *
639
+ * @example
640
+ * client.command('ping', async (interaction) => {
641
+ * await interaction.reply('Pong! 🏓')
642
+ * })
643
+ */
644
+ command(name, handler) {
645
+ this._commandHandlers.set(name, handler);
646
+ return this;
647
+ }
648
+ /**
649
+ * Register a handler for a button by its `customId`.
650
+ *
651
+ * @example
652
+ * client.button('confirm_delete', async (interaction) => {
653
+ * await interaction.replyEphemeral('Deleted.')
654
+ * })
655
+ */
656
+ button(customId, handler) {
657
+ this._buttonHandlers.set(customId, handler);
658
+ return this;
659
+ }
660
+ /**
661
+ * Register a handler for a select menu by its `customId`.
662
+ *
663
+ * @example
664
+ * client.selectMenu('colour_pick', async (interaction) => {
665
+ * const chosen = interaction.values[0]
666
+ * await interaction.reply(`You picked: ${chosen}`)
667
+ * })
668
+ */
669
+ selectMenu(customId, handler) {
670
+ this._selectHandlers.set(customId, handler);
671
+ return this;
672
+ }
386
673
  /**
387
674
  * Connect to the Nova WebSocket gateway.
388
675
  * Resolves when the `ready` event is received.
@@ -420,8 +707,19 @@ var NovaClient = class extends EventEmitter {
420
707
  this.emit("ready", this.botUser);
421
708
  resolve();
422
709
  });
423
- this.socket.on("interaction:created", (interaction) => {
710
+ this.socket.on("interaction:created", (raw) => {
711
+ const interaction = new NovaInteraction(raw, this.interactions);
424
712
  this.emit("interactionCreate", interaction);
713
+ const run = (h) => {
714
+ if (h) Promise.resolve(h(interaction)).catch((e) => this.emit("error", e));
715
+ };
716
+ if (interaction.isCommand() && interaction.commandName) {
717
+ run(this._commandHandlers.get(interaction.commandName));
718
+ } else if (interaction.isButton() && interaction.customId) {
719
+ run(this._buttonHandlers.get(interaction.customId));
720
+ } else if (interaction.isSelectMenu() && interaction.customId) {
721
+ run(this._selectHandlers.get(interaction.customId));
722
+ }
425
723
  });
426
724
  this.socket.on("bot:event", (event) => {
427
725
  this.emit("event", event);
@@ -505,13 +803,428 @@ var NovaClient = class extends EventEmitter {
505
803
  return super.emit(event, ...args);
506
804
  }
507
805
  };
806
+
807
+ // src/builders/EmbedBuilder.ts
808
+ var EmbedBuilder = class {
809
+ constructor() {
810
+ this._data = {};
811
+ }
812
+ /** Set the embed title (shown in bold at the top). */
813
+ setTitle(title) {
814
+ this._data.title = title;
815
+ return this;
816
+ }
817
+ /** Set the main description text (supports markdown). */
818
+ setDescription(description) {
819
+ this._data.description = description;
820
+ return this;
821
+ }
822
+ /**
823
+ * Set the accent colour.
824
+ * @param color Hex string — e.g. `'#5865F2'` or `'5865F2'`
825
+ */
826
+ setColor(color) {
827
+ this._data.color = color.startsWith("#") ? color : `#${color}`;
828
+ return this;
829
+ }
830
+ /** Make the title a clickable hyperlink. */
831
+ setUrl(url) {
832
+ this._data.url = url;
833
+ return this;
834
+ }
835
+ /** Small image shown in the top-right corner. */
836
+ setThumbnail(url) {
837
+ this._data.thumbnail = url;
838
+ return this;
839
+ }
840
+ /** Large image shown below the fields. */
841
+ setImage(url) {
842
+ this._data.image = url;
843
+ return this;
844
+ }
845
+ /** Footer text shown at the very bottom of the embed. */
846
+ setFooter(text) {
847
+ this._data.footer = text;
848
+ return this;
849
+ }
850
+ /**
851
+ * Add a timestamp to the footer line.
852
+ * @param date Defaults to `new Date()`.
853
+ */
854
+ setTimestamp(date) {
855
+ const d = date instanceof Date ? date : date != null ? new Date(date) : /* @__PURE__ */ new Date();
856
+ this._data.timestamp = d.toISOString();
857
+ return this;
858
+ }
859
+ /** Author name + optional icon shown above the title. */
860
+ setAuthor(author) {
861
+ this._data.author = author;
862
+ return this;
863
+ }
864
+ /**
865
+ * Add a single field.
866
+ * @param inline Pass `true` to render this field side-by-side with adjacent inline fields.
867
+ */
868
+ addField(name, value, inline) {
869
+ if (!this._data.fields) this._data.fields = [];
870
+ this._data.fields.push({ name, value, inline });
871
+ return this;
872
+ }
873
+ /** Add multiple fields at once. */
874
+ addFields(...fields) {
875
+ if (!this._data.fields) this._data.fields = [];
876
+ this._data.fields.push(...fields);
877
+ return this;
878
+ }
879
+ /** Replace all fields. */
880
+ setFields(fields) {
881
+ this._data.fields = [...fields];
882
+ return this;
883
+ }
884
+ /** Serialise to a plain `Embed` object you can pass to any API call. */
885
+ toJSON() {
886
+ return {
887
+ ...this._data,
888
+ fields: this._data.fields ? [...this._data.fields] : void 0
889
+ };
890
+ }
891
+ };
892
+
893
+ // src/builders/ButtonBuilder.ts
894
+ var ButtonBuilder = class {
895
+ constructor() {
896
+ this._customId = "";
897
+ this._label = "";
898
+ this._style = "primary";
899
+ this._disabled = false;
900
+ }
901
+ /** Custom ID returned in the `BUTTON_CLICK` interaction. Not required for `link` style buttons. */
902
+ setCustomId(customId) {
903
+ this._customId = customId;
904
+ return this;
905
+ }
906
+ /** Text displayed on the button. */
907
+ setLabel(label) {
908
+ this._label = label;
909
+ return this;
910
+ }
911
+ /**
912
+ * Visual style:
913
+ * - `primary` — blurple / brand colour
914
+ * - `secondary` — grey
915
+ * - `success` — green
916
+ * - `danger` — red
917
+ * - `link` — grey, navigates to a URL instead of creating an interaction
918
+ */
919
+ setStyle(style) {
920
+ this._style = style;
921
+ return this;
922
+ }
923
+ /** Emoji shown to the left of the label (unicode or custom e.g. `'👋'`). */
924
+ setEmoji(emoji) {
925
+ this._emoji = emoji;
926
+ return this;
927
+ }
928
+ /**
929
+ * URL for `link` style buttons.
930
+ * Sets the style to `'link'` automatically.
931
+ */
932
+ setUrl(url) {
933
+ this._url = url;
934
+ this._style = "link";
935
+ return this;
936
+ }
937
+ /** Prevent users from clicking the button. */
938
+ setDisabled(disabled = true) {
939
+ this._disabled = disabled;
940
+ return this;
941
+ }
942
+ toJSON() {
943
+ return {
944
+ type: "button",
945
+ customId: this._customId,
946
+ label: this._label || void 0,
947
+ style: this._style,
948
+ emoji: this._emoji,
949
+ url: this._url,
950
+ disabled: this._disabled || void 0
951
+ };
952
+ }
953
+ };
954
+
955
+ // src/builders/SelectMenuBuilder.ts
956
+ var SelectMenuBuilder = class {
957
+ constructor() {
958
+ this._customId = "";
959
+ this._disabled = false;
960
+ this._options = [];
961
+ }
962
+ /** Custom ID returned in the `SELECT_MENU` interaction. */
963
+ setCustomId(customId) {
964
+ this._customId = customId;
965
+ return this;
966
+ }
967
+ /** Greyed-out hint shown when nothing is selected. */
968
+ setPlaceholder(placeholder) {
969
+ this._placeholder = placeholder;
970
+ return this;
971
+ }
972
+ /** Prevent users from interacting with the menu. */
973
+ setDisabled(disabled = true) {
974
+ this._disabled = disabled;
975
+ return this;
976
+ }
977
+ /** Add a single option. */
978
+ addOption(option) {
979
+ this._options.push(option);
980
+ return this;
981
+ }
982
+ /** Add multiple options at once. */
983
+ addOptions(...options) {
984
+ this._options.push(...options);
985
+ return this;
986
+ }
987
+ /** Replace all options. */
988
+ setOptions(options) {
989
+ this._options.splice(0, this._options.length, ...options);
990
+ return this;
991
+ }
992
+ toJSON() {
993
+ return {
994
+ type: "select",
995
+ customId: this._customId,
996
+ placeholder: this._placeholder,
997
+ disabled: this._disabled || void 0,
998
+ options: [...this._options]
999
+ };
1000
+ }
1001
+ };
1002
+
1003
+ // src/builders/ActionRowBuilder.ts
1004
+ var ActionRowBuilder = class {
1005
+ constructor() {
1006
+ this._components = [];
1007
+ }
1008
+ /** Add a single component (button or select menu). */
1009
+ addComponent(component) {
1010
+ this._components.push(component);
1011
+ return this;
1012
+ }
1013
+ /** Add multiple components at once. */
1014
+ addComponents(...components) {
1015
+ this._components.push(...components);
1016
+ return this;
1017
+ }
1018
+ /**
1019
+ * Serialise to a flat `MessageComponent[]` array — the format accepted by all API calls.
1020
+ */
1021
+ toJSON() {
1022
+ return this._components.map((c) => c.toJSON());
1023
+ }
1024
+ };
1025
+
1026
+ // src/builders/ModalBuilder.ts
1027
+ var ModalBuilder = class {
1028
+ constructor() {
1029
+ this._title = "";
1030
+ this._customId = "";
1031
+ this._fields = [];
1032
+ }
1033
+ /** Title shown at the top of the modal dialog. */
1034
+ setTitle(title) {
1035
+ this._title = title;
1036
+ return this;
1037
+ }
1038
+ /** Custom ID passed back with the `MODAL_SUBMIT` interaction. */
1039
+ setCustomId(customId) {
1040
+ this._customId = customId;
1041
+ return this;
1042
+ }
1043
+ /** Add a single text-input field. */
1044
+ addField(field) {
1045
+ this._fields.push("toJSON" in field ? field.toJSON() : field);
1046
+ return this;
1047
+ }
1048
+ /** Add multiple fields at once. */
1049
+ addFields(...fields) {
1050
+ for (const f of fields) this.addField(f);
1051
+ return this;
1052
+ }
1053
+ toJSON() {
1054
+ if (!this._title) throw new Error("ModalBuilder: title is required \u2014 call .setTitle()");
1055
+ if (!this._customId) throw new Error("ModalBuilder: customId is required \u2014 call .setCustomId()");
1056
+ if (this._fields.length === 0) throw new Error("ModalBuilder: at least one field is required \u2014 call .addField()");
1057
+ return { title: this._title, customId: this._customId, fields: [...this._fields] };
1058
+ }
1059
+ };
1060
+
1061
+ // src/builders/TextInputBuilder.ts
1062
+ var TextInputBuilder = class {
1063
+ constructor() {
1064
+ this._data = {
1065
+ customId: "",
1066
+ label: "",
1067
+ type: "short"
1068
+ };
1069
+ }
1070
+ /** Unique ID for this field — the key in `interaction.modalData` on submit. */
1071
+ setCustomId(customId) {
1072
+ this._data.customId = customId;
1073
+ return this;
1074
+ }
1075
+ /** Label shown above the input inside the modal. */
1076
+ setLabel(label) {
1077
+ this._data.label = label;
1078
+ return this;
1079
+ }
1080
+ /**
1081
+ * Input style:
1082
+ * - `'short'` — single-line text input
1083
+ * - `'paragraph'` — multi-line textarea
1084
+ */
1085
+ setStyle(style) {
1086
+ this._data.type = style;
1087
+ return this;
1088
+ }
1089
+ /** Greyed-out hint text shown when the field is empty. */
1090
+ setPlaceholder(placeholder) {
1091
+ this._data.placeholder = placeholder;
1092
+ return this;
1093
+ }
1094
+ /** Whether the user must fill in this field before submitting. */
1095
+ setRequired(required = true) {
1096
+ this._data.required = required;
1097
+ return this;
1098
+ }
1099
+ /** Minimum number of characters required. */
1100
+ setMinLength(min) {
1101
+ this._data.minLength = min;
1102
+ return this;
1103
+ }
1104
+ /** Maximum number of characters allowed. */
1105
+ setMaxLength(max) {
1106
+ this._data.maxLength = max;
1107
+ return this;
1108
+ }
1109
+ /** Pre-filled default value. */
1110
+ setValue(value) {
1111
+ this._data.value = value;
1112
+ return this;
1113
+ }
1114
+ toJSON() {
1115
+ return { ...this._data };
1116
+ }
1117
+ };
1118
+
1119
+ // src/builders/SlashCommandBuilder.ts
1120
+ var SlashCommandOptionBuilder = class {
1121
+ constructor(type) {
1122
+ this._data = { name: "", description: "", type };
1123
+ }
1124
+ /** Internal option name (lowercase, no spaces). Shown after `/command ` in the client UI. */
1125
+ setName(name) {
1126
+ this._data.name = name;
1127
+ return this;
1128
+ }
1129
+ /** Short human-readable description shown in the command picker. */
1130
+ setDescription(description) {
1131
+ this._data.description = description;
1132
+ return this;
1133
+ }
1134
+ /** Whether users must supply this option before sending the command. */
1135
+ setRequired(required = true) {
1136
+ this._data.required = required;
1137
+ return this;
1138
+ }
1139
+ /**
1140
+ * Restrict the option to specific values.
1141
+ * The picker will show these as autocomplete suggestions.
1142
+ */
1143
+ addChoice(name, value) {
1144
+ if (!this._data.choices) this._data.choices = [];
1145
+ this._data.choices.push({ name, value });
1146
+ return this;
1147
+ }
1148
+ /** Set all allowed choices at once. */
1149
+ setChoices(choices) {
1150
+ this._data.choices = [...choices];
1151
+ return this;
1152
+ }
1153
+ toJSON() {
1154
+ return { ...this._data };
1155
+ }
1156
+ };
1157
+ var SlashCommandBuilder = class {
1158
+ constructor() {
1159
+ this._data = {
1160
+ name: "",
1161
+ description: "",
1162
+ options: []
1163
+ };
1164
+ }
1165
+ /** Command name — lowercase, no spaces (e.g. `'ban'`, `'server-info'`). */
1166
+ setName(name) {
1167
+ this._data.name = name;
1168
+ return this;
1169
+ }
1170
+ /** Short description shown in the command picker UI. */
1171
+ setDescription(description) {
1172
+ this._data.description = description;
1173
+ return this;
1174
+ }
1175
+ /** Add a text (string) option. */
1176
+ addStringOption(fn) {
1177
+ this._data.options.push(fn(new SlashCommandOptionBuilder("STRING")).toJSON());
1178
+ return this;
1179
+ }
1180
+ /** Add an integer (whole number) option. */
1181
+ addIntegerOption(fn) {
1182
+ this._data.options.push(fn(new SlashCommandOptionBuilder("INTEGER")).toJSON());
1183
+ return this;
1184
+ }
1185
+ /** Add a boolean (true/false) option. */
1186
+ addBooleanOption(fn) {
1187
+ this._data.options.push(fn(new SlashCommandOptionBuilder("BOOLEAN")).toJSON());
1188
+ return this;
1189
+ }
1190
+ /** Add a user-mention option (returns a user ID string). */
1191
+ addUserOption(fn) {
1192
+ this._data.options.push(fn(new SlashCommandOptionBuilder("USER")).toJSON());
1193
+ return this;
1194
+ }
1195
+ /** Add a channel-mention option (returns a channel ID string). */
1196
+ addChannelOption(fn) {
1197
+ this._data.options.push(fn(new SlashCommandOptionBuilder("CHANNEL")).toJSON());
1198
+ return this;
1199
+ }
1200
+ /** Add a role-mention option (returns a role ID string). */
1201
+ addRoleOption(fn) {
1202
+ this._data.options.push(fn(new SlashCommandOptionBuilder("ROLE")).toJSON());
1203
+ return this;
1204
+ }
1205
+ toJSON() {
1206
+ if (!this._data.name) throw new Error("SlashCommandBuilder: name is required \u2014 call .setName()");
1207
+ if (!this._data.description) throw new Error("SlashCommandBuilder: description is required \u2014 call .setDescription()");
1208
+ return { ...this._data, options: [...this._data.options ?? []] };
1209
+ }
1210
+ };
508
1211
  export {
1212
+ ActionRowBuilder,
1213
+ ButtonBuilder,
509
1214
  CommandsAPI,
1215
+ EmbedBuilder,
510
1216
  HttpClient,
1217
+ InteractionOptions,
511
1218
  InteractionsAPI,
512
1219
  MembersAPI,
513
1220
  MessagesAPI,
1221
+ ModalBuilder,
514
1222
  NovaClient,
1223
+ NovaInteraction,
515
1224
  PermissionsAPI,
516
- ServersAPI
1225
+ SelectMenuBuilder,
1226
+ ServersAPI,
1227
+ SlashCommandBuilder,
1228
+ SlashCommandOptionBuilder,
1229
+ TextInputBuilder
517
1230
  };