novaapp-sdk 1.0.10 → 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.d.mts +601 -36
- package/dist/index.d.ts +601 -36
- package/dist/index.js +660 -3
- package/dist/index.mjs +649 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -80,25 +80,35 @@ interface EmbedField {
|
|
|
80
80
|
interface Embed {
|
|
81
81
|
title?: string;
|
|
82
82
|
description?: string;
|
|
83
|
+
/** Makes the title a clickable link. */
|
|
83
84
|
url?: string;
|
|
84
|
-
|
|
85
|
+
/** Hex colour string — e.g. `'#5865F2'`. */
|
|
86
|
+
color?: string;
|
|
85
87
|
thumbnail?: string;
|
|
86
88
|
image?: string;
|
|
87
89
|
footer?: string;
|
|
88
90
|
fields?: EmbedField[];
|
|
89
91
|
timestamp?: string;
|
|
92
|
+
author?: {
|
|
93
|
+
name: string;
|
|
94
|
+
iconUrl?: string;
|
|
95
|
+
};
|
|
90
96
|
}
|
|
91
97
|
interface MessageComponent {
|
|
92
98
|
type: 'button' | 'select';
|
|
93
|
-
customId
|
|
99
|
+
customId?: string;
|
|
94
100
|
label?: string;
|
|
95
|
-
style?: 'primary' | 'secondary' | 'success' | 'danger';
|
|
101
|
+
style?: 'primary' | 'secondary' | 'success' | 'danger' | 'link';
|
|
102
|
+
emoji?: string;
|
|
103
|
+
url?: string;
|
|
96
104
|
placeholder?: string;
|
|
97
105
|
options?: Array<{
|
|
98
106
|
label: string;
|
|
99
107
|
value: string;
|
|
100
108
|
description?: string;
|
|
101
109
|
}>;
|
|
110
|
+
minValues?: number;
|
|
111
|
+
maxValues?: number;
|
|
102
112
|
disabled?: boolean;
|
|
103
113
|
}
|
|
104
114
|
interface Message {
|
|
@@ -306,41 +316,10 @@ interface NovaClientOptions {
|
|
|
306
316
|
token: string;
|
|
307
317
|
/**
|
|
308
318
|
* Base URL of the Nova server.
|
|
309
|
-
* @default "https://
|
|
319
|
+
* @default "https://novachatapp.com"
|
|
310
320
|
*/
|
|
311
321
|
baseUrl?: string;
|
|
312
322
|
}
|
|
313
|
-
interface NovaClientEvents {
|
|
314
|
-
/** Fired when the bot successfully connects and is identified. */
|
|
315
|
-
ready: (bot: BotApplication) => void;
|
|
316
|
-
/** Fired for every bot:event from the gateway. */
|
|
317
|
-
event: (event: BotEvent) => void;
|
|
318
|
-
/** Fired when an interaction is created (slash command, button, etc.). */
|
|
319
|
-
interactionCreate: (interaction: Interaction) => void;
|
|
320
|
-
/** Fired when the gateway connection is lost. */
|
|
321
|
-
disconnect: (reason: string) => void;
|
|
322
|
-
/** Fired on gateway/API errors. */
|
|
323
|
-
error: (err: {
|
|
324
|
-
code: number;
|
|
325
|
-
message: string;
|
|
326
|
-
}) => void;
|
|
327
|
-
/** A message was sent in a channel the bot is in. */
|
|
328
|
-
messageCreate: (data: BotEvent['data']) => void;
|
|
329
|
-
/** A message was edited. */
|
|
330
|
-
messageUpdate: (data: BotEvent['data']) => void;
|
|
331
|
-
/** A message was deleted. */
|
|
332
|
-
messageDelete: (data: BotEvent['data']) => void;
|
|
333
|
-
/** A reaction was added to a message. */
|
|
334
|
-
reactionAdd: (data: BotEvent['data']) => void;
|
|
335
|
-
/** A reaction was removed from a message. */
|
|
336
|
-
reactionRemove: (data: BotEvent['data']) => void;
|
|
337
|
-
/** A user joined a server the bot is in. */
|
|
338
|
-
memberAdd: (data: BotEvent['data']) => void;
|
|
339
|
-
/** A user left a server the bot is in. */
|
|
340
|
-
memberRemove: (data: BotEvent['data']) => void;
|
|
341
|
-
/** A user started typing. */
|
|
342
|
-
typingStart: (data: BotEvent['data']) => void;
|
|
343
|
-
}
|
|
344
323
|
|
|
345
324
|
declare class MessagesAPI {
|
|
346
325
|
private readonly http;
|
|
@@ -619,6 +598,321 @@ declare class PermissionsAPI {
|
|
|
619
598
|
get(options: PermissionsQueryOptions): Promise<PermissionsResult>;
|
|
620
599
|
}
|
|
621
600
|
|
|
601
|
+
type TextInputStyle = 'short' | 'paragraph';
|
|
602
|
+
/**
|
|
603
|
+
* Fluent builder for a single text-input field inside a modal.
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* new TextInputBuilder()
|
|
607
|
+
* .setCustomId('reason')
|
|
608
|
+
* .setLabel('Reason')
|
|
609
|
+
* .setStyle('paragraph')
|
|
610
|
+
* .setPlaceholder('Describe the issue in detail…')
|
|
611
|
+
* .setRequired(true)
|
|
612
|
+
* .setMaxLength(1000)
|
|
613
|
+
*/
|
|
614
|
+
declare class TextInputBuilder {
|
|
615
|
+
private _data;
|
|
616
|
+
/** Unique ID for this field — the key in `interaction.modalData` on submit. */
|
|
617
|
+
setCustomId(customId: string): this;
|
|
618
|
+
/** Label shown above the input inside the modal. */
|
|
619
|
+
setLabel(label: string): this;
|
|
620
|
+
/**
|
|
621
|
+
* Input style:
|
|
622
|
+
* - `'short'` — single-line text input
|
|
623
|
+
* - `'paragraph'` — multi-line textarea
|
|
624
|
+
*/
|
|
625
|
+
setStyle(style: TextInputStyle): this;
|
|
626
|
+
/** Greyed-out hint text shown when the field is empty. */
|
|
627
|
+
setPlaceholder(placeholder: string): this;
|
|
628
|
+
/** Whether the user must fill in this field before submitting. */
|
|
629
|
+
setRequired(required?: boolean): this;
|
|
630
|
+
/** Minimum number of characters required. */
|
|
631
|
+
setMinLength(min: number): this;
|
|
632
|
+
/** Maximum number of characters allowed. */
|
|
633
|
+
setMaxLength(max: number): this;
|
|
634
|
+
/** Pre-filled default value. */
|
|
635
|
+
setValue(value: string): this;
|
|
636
|
+
toJSON(): BotModalField;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
type FieldLike = TextInputBuilder | BotModalField;
|
|
640
|
+
/**
|
|
641
|
+
* Fluent builder for bot modal dialogs.
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* const modal = new ModalBuilder()
|
|
645
|
+
* .setTitle('Submit a report')
|
|
646
|
+
* .setCustomId('report_modal')
|
|
647
|
+
* .addField(
|
|
648
|
+
* new TextInputBuilder()
|
|
649
|
+
* .setCustomId('reason')
|
|
650
|
+
* .setLabel('Reason')
|
|
651
|
+
* .setStyle('paragraph')
|
|
652
|
+
* .setRequired(true)
|
|
653
|
+
* .setMaxLength(1000)
|
|
654
|
+
* )
|
|
655
|
+
* .addField(
|
|
656
|
+
* new TextInputBuilder()
|
|
657
|
+
* .setCustomId('proof')
|
|
658
|
+
* .setLabel('Evidence (optional URL)')
|
|
659
|
+
* .setStyle('short')
|
|
660
|
+
* )
|
|
661
|
+
*
|
|
662
|
+
* const submitted = await interaction.openModal(modal)
|
|
663
|
+
* if (submitted) {
|
|
664
|
+
* const reason = submitted.modalData.reason
|
|
665
|
+
* }
|
|
666
|
+
*/
|
|
667
|
+
declare class ModalBuilder {
|
|
668
|
+
private _title;
|
|
669
|
+
private _customId;
|
|
670
|
+
private readonly _fields;
|
|
671
|
+
/** Title shown at the top of the modal dialog. */
|
|
672
|
+
setTitle(title: string): this;
|
|
673
|
+
/** Custom ID passed back with the `MODAL_SUBMIT` interaction. */
|
|
674
|
+
setCustomId(customId: string): this;
|
|
675
|
+
/** Add a single text-input field. */
|
|
676
|
+
addField(field: FieldLike): this;
|
|
677
|
+
/** Add multiple fields at once. */
|
|
678
|
+
addFields(...fields: FieldLike[]): this;
|
|
679
|
+
toJSON(): BotModalDefinition;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Typed accessor for slash- and prefix-command options.
|
|
684
|
+
* Available via `interaction.options`.
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* client.command('ban', async (interaction) => {
|
|
688
|
+
* const userId = interaction.options.getString('user', true)
|
|
689
|
+
* const reason = interaction.options.getString('reason') ?? 'No reason given'
|
|
690
|
+
* })
|
|
691
|
+
*/
|
|
692
|
+
declare class InteractionOptions {
|
|
693
|
+
private readonly _map;
|
|
694
|
+
constructor(data: unknown);
|
|
695
|
+
/** Whether this option was supplied by the user. */
|
|
696
|
+
has(name: string): boolean;
|
|
697
|
+
/** @overload Required — never returns `null`. */
|
|
698
|
+
getString(name: string, required: true): string;
|
|
699
|
+
/** @overload Optional — returns `null` when not supplied. */
|
|
700
|
+
getString(name: string, required?: false): string | null;
|
|
701
|
+
/** @overload Required — never returns `null`. */
|
|
702
|
+
getInteger(name: string, required: true): number;
|
|
703
|
+
/** @overload Optional — returns `null` when not supplied. */
|
|
704
|
+
getInteger(name: string, required?: false): number | null;
|
|
705
|
+
/** @overload Required — never returns `null`. */
|
|
706
|
+
getNumber(name: string, required: true): number;
|
|
707
|
+
/** @overload Optional — returns `null` when not supplied. */
|
|
708
|
+
getNumber(name: string, required?: false): number | null;
|
|
709
|
+
/** Returns `true` or `false`, or `null` if not supplied. */
|
|
710
|
+
getBoolean(name: string): boolean | null;
|
|
711
|
+
/**
|
|
712
|
+
* Returns the mentioned **user ID** string (type `USER` option).
|
|
713
|
+
* @overload Required.
|
|
714
|
+
*/
|
|
715
|
+
getUser(name: string, required: true): string;
|
|
716
|
+
getUser(name: string, required?: false): string | null;
|
|
717
|
+
/**
|
|
718
|
+
* Returns the mentioned **channel ID** string (type `CHANNEL` option).
|
|
719
|
+
* @overload Required.
|
|
720
|
+
*/
|
|
721
|
+
getChannel(name: string, required: true): string;
|
|
722
|
+
getChannel(name: string, required?: false): string | null;
|
|
723
|
+
/**
|
|
724
|
+
* Returns the mentioned **role ID** string (type `ROLE` option).
|
|
725
|
+
* @overload Required.
|
|
726
|
+
*/
|
|
727
|
+
getRole(name: string, required: true): string;
|
|
728
|
+
getRole(name: string, required?: false): string | null;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Rich wrapper around a raw bot interaction.
|
|
732
|
+
* Returned by `interactionCreate`, `client.command()`, `client.button()`, `client.selectMenu()`.
|
|
733
|
+
*
|
|
734
|
+
* @example
|
|
735
|
+
* client.on('interactionCreate', async (interaction) => {
|
|
736
|
+
* if (interaction.isSlashCommand() && interaction.commandName === 'ping') {
|
|
737
|
+
* await interaction.reply('Pong! 🏓')
|
|
738
|
+
* }
|
|
739
|
+
* })
|
|
740
|
+
*
|
|
741
|
+
* // Or use built-in routing:
|
|
742
|
+
* client.command('ping', async (interaction) => {
|
|
743
|
+
* await interaction.reply('Pong! 🏓')
|
|
744
|
+
* })
|
|
745
|
+
*/
|
|
746
|
+
declare class NovaInteraction {
|
|
747
|
+
private readonly _raw;
|
|
748
|
+
private readonly _api;
|
|
749
|
+
/** Unique interaction ID. */
|
|
750
|
+
readonly id: string;
|
|
751
|
+
/** Interaction type. Use type guards (`.isSlashCommand()` etc.) for narrowing. */
|
|
752
|
+
readonly type: InteractionType;
|
|
753
|
+
/** Command name — set for `SLASH_COMMAND` and `PREFIX_COMMAND` interactions. */
|
|
754
|
+
readonly commandName: string | null;
|
|
755
|
+
/** Component custom ID — set for `BUTTON_CLICK`, `SELECT_MENU`, and `MODAL_SUBMIT` interactions. */
|
|
756
|
+
readonly customId: string | null;
|
|
757
|
+
/** ID of the user who triggered this interaction. */
|
|
758
|
+
readonly userId: string;
|
|
759
|
+
/** ID of the channel where this interaction occurred. */
|
|
760
|
+
readonly channelId: string;
|
|
761
|
+
/** ID of the server where this interaction occurred (`null` in DMs). */
|
|
762
|
+
readonly serverId: string | null;
|
|
763
|
+
/** ID of the message that contained the button/select component (if any). */
|
|
764
|
+
readonly triggerMsgId: string | null;
|
|
765
|
+
/** Selected option values for `SELECT_MENU` interactions. */
|
|
766
|
+
readonly values: string[];
|
|
767
|
+
/**
|
|
768
|
+
* Field values submitted in a `MODAL_SUBMIT` interaction.
|
|
769
|
+
* Keys are the `customId`s of the `TextInputBuilder` fields.
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* const reason = interaction.modalData.reason
|
|
773
|
+
*/
|
|
774
|
+
readonly modalData: Record<string, string>;
|
|
775
|
+
/** ISO timestamp of when the interaction was created. */
|
|
776
|
+
readonly createdAt: string;
|
|
777
|
+
/**
|
|
778
|
+
* Typed accessor for slash/prefix command options.
|
|
779
|
+
*
|
|
780
|
+
* @example
|
|
781
|
+
* const userId = interaction.options.getUser('user', true)
|
|
782
|
+
* const reason = interaction.options.getString('reason') ?? 'No reason given'
|
|
783
|
+
*/
|
|
784
|
+
readonly options: InteractionOptions;
|
|
785
|
+
constructor(_raw: Interaction, _api: InteractionsAPI);
|
|
786
|
+
/** `true` when triggered by a `/slash` command. */
|
|
787
|
+
isSlashCommand(): boolean;
|
|
788
|
+
/** `true` when triggered by a `!prefix` command. */
|
|
789
|
+
isPrefixCommand(): boolean;
|
|
790
|
+
/** `true` for both slash and prefix commands. */
|
|
791
|
+
isCommand(): boolean;
|
|
792
|
+
/** `true` when a button component was clicked. */
|
|
793
|
+
isButton(): boolean;
|
|
794
|
+
/** `true` when a select-menu option was chosen. */
|
|
795
|
+
isSelectMenu(): boolean;
|
|
796
|
+
/** `true` when the user submitted a modal form. */
|
|
797
|
+
isModalSubmit(): boolean;
|
|
798
|
+
/** `true` during autocomplete suggestion requests. */
|
|
799
|
+
isAutocomplete(): boolean;
|
|
800
|
+
/** `true` when triggered via a context-menu command. */
|
|
801
|
+
isContextMenu(): boolean;
|
|
802
|
+
/**
|
|
803
|
+
* Respond with a message.
|
|
804
|
+
* Accepts a plain string or a full options object.
|
|
805
|
+
*
|
|
806
|
+
* @example
|
|
807
|
+
* await interaction.reply('Pong! 🏓')
|
|
808
|
+
* await interaction.reply({ content: 'Done!', ephemeral: true })
|
|
809
|
+
* await interaction.reply({ embed: new EmbedBuilder().setTitle('Stats').toJSON() })
|
|
810
|
+
*/
|
|
811
|
+
reply(options: RespondInteractionOptions | string): Promise<Message | {
|
|
812
|
+
ok: true;
|
|
813
|
+
ephemeral: true;
|
|
814
|
+
}>;
|
|
815
|
+
/**
|
|
816
|
+
* Respond with a message **only visible to the user** who triggered the interaction.
|
|
817
|
+
*
|
|
818
|
+
* @example
|
|
819
|
+
* await interaction.replyEphemeral('Only you can see this!')
|
|
820
|
+
*/
|
|
821
|
+
replyEphemeral(options: string | Omit<RespondInteractionOptions, 'ephemeral'>): Promise<{
|
|
822
|
+
ok: true;
|
|
823
|
+
ephemeral: true;
|
|
824
|
+
}>;
|
|
825
|
+
/**
|
|
826
|
+
* Acknowledge the interaction without sending a response yet.
|
|
827
|
+
* Shows a loading indicator to the user.
|
|
828
|
+
* Follow up with `interaction.editReply()` when you're done.
|
|
829
|
+
*
|
|
830
|
+
* @example
|
|
831
|
+
* await interaction.defer()
|
|
832
|
+
* const data = await fetchSomeSlow()
|
|
833
|
+
* await interaction.editReply({ content: `Result: ${data}` })
|
|
834
|
+
*/
|
|
835
|
+
defer(): Promise<{
|
|
836
|
+
ok: true;
|
|
837
|
+
}>;
|
|
838
|
+
/**
|
|
839
|
+
* Edit the previous reply (e.g. after `defer()`).
|
|
840
|
+
*
|
|
841
|
+
* @example
|
|
842
|
+
* await interaction.defer()
|
|
843
|
+
* await interaction.editReply(`Done — processed ${count} items.`)
|
|
844
|
+
*/
|
|
845
|
+
editReply(options: RespondInteractionOptions | string): Promise<Message | {
|
|
846
|
+
ok: true;
|
|
847
|
+
ephemeral: true;
|
|
848
|
+
}>;
|
|
849
|
+
/**
|
|
850
|
+
* Open a **modal dialog** and return the user's submission as a new `NovaInteraction`.
|
|
851
|
+
* Returns `null` if the user closes the modal or the timeout expires (default: 5 min).
|
|
852
|
+
*
|
|
853
|
+
* **This is the recommended way to open modals.**
|
|
854
|
+
*
|
|
855
|
+
* @example
|
|
856
|
+
* const submitted = await interaction.openModal(
|
|
857
|
+
* new ModalBuilder()
|
|
858
|
+
* .setTitle('Submit a report')
|
|
859
|
+
* .setCustomId('report_modal')
|
|
860
|
+
* .addField(
|
|
861
|
+
* new TextInputBuilder()
|
|
862
|
+
* .setCustomId('reason')
|
|
863
|
+
* .setLabel('Reason')
|
|
864
|
+
* .setStyle('paragraph')
|
|
865
|
+
* .setRequired(true)
|
|
866
|
+
* )
|
|
867
|
+
* )
|
|
868
|
+
*
|
|
869
|
+
* if (!submitted) return // user dismissed or timed out
|
|
870
|
+
*
|
|
871
|
+
* const reason = submitted.modalData.reason
|
|
872
|
+
* await submitted.replyEphemeral(`Report received: ${reason}`)
|
|
873
|
+
*/
|
|
874
|
+
openModal(modal: ModalBuilder | BotModalDefinition, options?: {
|
|
875
|
+
timeout?: number;
|
|
876
|
+
}): Promise<NovaInteraction | null>;
|
|
877
|
+
/** Returns the raw interaction data from the gateway. */
|
|
878
|
+
toJSON(): Interaction;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
interface NovaClientEvents {
|
|
882
|
+
/** Fired when the bot connects and is identified by the gateway. */
|
|
883
|
+
ready: (bot: BotApplication) => void;
|
|
884
|
+
/** Fired for every raw `bot:event` from the gateway. */
|
|
885
|
+
event: (event: BotEvent) => void;
|
|
886
|
+
/**
|
|
887
|
+
* Fired when an interaction is received (slash command, button click, etc.).
|
|
888
|
+
* Use `client.command()`, `client.button()`, or `client.selectMenu()` for
|
|
889
|
+
* convenient routing instead of handling everything here.
|
|
890
|
+
*/
|
|
891
|
+
interactionCreate: (interaction: NovaInteraction) => void;
|
|
892
|
+
/** Fired when the WebSocket connection drops. */
|
|
893
|
+
disconnect: (reason: string) => void;
|
|
894
|
+
/** Fired on gateway / API errors. */
|
|
895
|
+
error: (err: Error | {
|
|
896
|
+
code: number;
|
|
897
|
+
message: string;
|
|
898
|
+
}) => void;
|
|
899
|
+
/** A new message was sent in a channel the bot can see. */
|
|
900
|
+
messageCreate: (data: BotEvent['data']) => void;
|
|
901
|
+
/** A message was edited. */
|
|
902
|
+
messageUpdate: (data: BotEvent['data']) => void;
|
|
903
|
+
/** A message was deleted. */
|
|
904
|
+
messageDelete: (data: BotEvent['data']) => void;
|
|
905
|
+
/** A reaction was added. */
|
|
906
|
+
reactionAdd: (data: BotEvent['data']) => void;
|
|
907
|
+
/** A reaction was removed. */
|
|
908
|
+
reactionRemove: (data: BotEvent['data']) => void;
|
|
909
|
+
/** A member joined a server the bot is in. */
|
|
910
|
+
memberAdd: (data: BotEvent['data']) => void;
|
|
911
|
+
/** A member left a server the bot is in. */
|
|
912
|
+
memberRemove: (data: BotEvent['data']) => void;
|
|
913
|
+
/** A user started typing. */
|
|
914
|
+
typingStart: (data: BotEvent['data']) => void;
|
|
915
|
+
}
|
|
622
916
|
/**
|
|
623
917
|
* The main Nova bot client.
|
|
624
918
|
*
|
|
@@ -657,7 +951,39 @@ declare class NovaClient extends EventEmitter {
|
|
|
657
951
|
private socket;
|
|
658
952
|
private readonly http;
|
|
659
953
|
private readonly options;
|
|
954
|
+
private readonly _commandHandlers;
|
|
955
|
+
private readonly _buttonHandlers;
|
|
956
|
+
private readonly _selectHandlers;
|
|
660
957
|
constructor(options: NovaClientOptions);
|
|
958
|
+
/**
|
|
959
|
+
* Register a handler for a slash or prefix command by name.
|
|
960
|
+
* Automatically routes `interactionCreate` events whose `commandName` matches.
|
|
961
|
+
*
|
|
962
|
+
* @example
|
|
963
|
+
* client.command('ping', async (interaction) => {
|
|
964
|
+
* await interaction.reply('Pong! 🏓')
|
|
965
|
+
* })
|
|
966
|
+
*/
|
|
967
|
+
command(name: string, handler: (interaction: NovaInteraction) => unknown): this;
|
|
968
|
+
/**
|
|
969
|
+
* Register a handler for a button by its `customId`.
|
|
970
|
+
*
|
|
971
|
+
* @example
|
|
972
|
+
* client.button('confirm_delete', async (interaction) => {
|
|
973
|
+
* await interaction.replyEphemeral('Deleted.')
|
|
974
|
+
* })
|
|
975
|
+
*/
|
|
976
|
+
button(customId: string, handler: (interaction: NovaInteraction) => unknown): this;
|
|
977
|
+
/**
|
|
978
|
+
* Register a handler for a select menu by its `customId`.
|
|
979
|
+
*
|
|
980
|
+
* @example
|
|
981
|
+
* client.selectMenu('colour_pick', async (interaction) => {
|
|
982
|
+
* const chosen = interaction.values[0]
|
|
983
|
+
* await interaction.reply(`You picked: ${chosen}`)
|
|
984
|
+
* })
|
|
985
|
+
*/
|
|
986
|
+
selectMenu(customId: string, handler: (interaction: NovaInteraction) => unknown): this;
|
|
661
987
|
/**
|
|
662
988
|
* Connect to the Nova WebSocket gateway.
|
|
663
989
|
* Resolves when the `ready` event is received.
|
|
@@ -696,4 +1022,243 @@ declare class NovaClient extends EventEmitter {
|
|
|
696
1022
|
emit(event: string | symbol, ...args: unknown[]): boolean;
|
|
697
1023
|
}
|
|
698
1024
|
|
|
699
|
-
|
|
1025
|
+
/**
|
|
1026
|
+
* Fluent builder for bot message embeds.
|
|
1027
|
+
*
|
|
1028
|
+
* @example
|
|
1029
|
+
* const embed = new EmbedBuilder()
|
|
1030
|
+
* .setTitle('Server Stats')
|
|
1031
|
+
* .setDescription('Here are the latest numbers.')
|
|
1032
|
+
* .setColor('#5865F2')
|
|
1033
|
+
* .addField('Members', '1 234', true)
|
|
1034
|
+
* .addField('Messages today', '567', true)
|
|
1035
|
+
* .setFooter('Nova Bot')
|
|
1036
|
+
* .setTimestamp()
|
|
1037
|
+
*
|
|
1038
|
+
* await client.messages.send(channelId, { embed })
|
|
1039
|
+
*/
|
|
1040
|
+
declare class EmbedBuilder {
|
|
1041
|
+
private readonly _data;
|
|
1042
|
+
/** Set the embed title (shown in bold at the top). */
|
|
1043
|
+
setTitle(title: string): this;
|
|
1044
|
+
/** Set the main description text (supports markdown). */
|
|
1045
|
+
setDescription(description: string): this;
|
|
1046
|
+
/**
|
|
1047
|
+
* Set the accent colour.
|
|
1048
|
+
* @param color Hex string — e.g. `'#5865F2'` or `'5865F2'`
|
|
1049
|
+
*/
|
|
1050
|
+
setColor(color: string): this;
|
|
1051
|
+
/** Make the title a clickable hyperlink. */
|
|
1052
|
+
setUrl(url: string): this;
|
|
1053
|
+
/** Small image shown in the top-right corner. */
|
|
1054
|
+
setThumbnail(url: string): this;
|
|
1055
|
+
/** Large image shown below the fields. */
|
|
1056
|
+
setImage(url: string): this;
|
|
1057
|
+
/** Footer text shown at the very bottom of the embed. */
|
|
1058
|
+
setFooter(text: string): this;
|
|
1059
|
+
/**
|
|
1060
|
+
* Add a timestamp to the footer line.
|
|
1061
|
+
* @param date Defaults to `new Date()`.
|
|
1062
|
+
*/
|
|
1063
|
+
setTimestamp(date?: Date | number): this;
|
|
1064
|
+
/** Author name + optional icon shown above the title. */
|
|
1065
|
+
setAuthor(author: {
|
|
1066
|
+
name: string;
|
|
1067
|
+
iconUrl?: string;
|
|
1068
|
+
}): this;
|
|
1069
|
+
/**
|
|
1070
|
+
* Add a single field.
|
|
1071
|
+
* @param inline Pass `true` to render this field side-by-side with adjacent inline fields.
|
|
1072
|
+
*/
|
|
1073
|
+
addField(name: string, value: string, inline?: boolean): this;
|
|
1074
|
+
/** Add multiple fields at once. */
|
|
1075
|
+
addFields(...fields: EmbedField[]): this;
|
|
1076
|
+
/** Replace all fields. */
|
|
1077
|
+
setFields(fields: EmbedField[]): this;
|
|
1078
|
+
/** Serialise to a plain `Embed` object you can pass to any API call. */
|
|
1079
|
+
toJSON(): Embed;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
type ButtonStyle = 'primary' | 'secondary' | 'success' | 'danger' | 'link';
|
|
1083
|
+
/**
|
|
1084
|
+
* Fluent builder for button components.
|
|
1085
|
+
*
|
|
1086
|
+
* @example
|
|
1087
|
+
* const row = new ActionRowBuilder()
|
|
1088
|
+
* .addButton(
|
|
1089
|
+
* new ButtonBuilder()
|
|
1090
|
+
* .setCustomId('confirm')
|
|
1091
|
+
* .setLabel('Confirm')
|
|
1092
|
+
* .setStyle('success')
|
|
1093
|
+
* )
|
|
1094
|
+
* .addButton(
|
|
1095
|
+
* new ButtonBuilder()
|
|
1096
|
+
* .setCustomId('cancel')
|
|
1097
|
+
* .setLabel('Cancel')
|
|
1098
|
+
* .setStyle('danger')
|
|
1099
|
+
* )
|
|
1100
|
+
*
|
|
1101
|
+
* await client.messages.send(channelId, { content: 'Are you sure?', components: row.toJSON() })
|
|
1102
|
+
*/
|
|
1103
|
+
declare class ButtonBuilder {
|
|
1104
|
+
private _customId;
|
|
1105
|
+
private _label;
|
|
1106
|
+
private _style;
|
|
1107
|
+
private _disabled;
|
|
1108
|
+
private _emoji?;
|
|
1109
|
+
private _url?;
|
|
1110
|
+
/** Custom ID returned in the `BUTTON_CLICK` interaction. Not required for `link` style buttons. */
|
|
1111
|
+
setCustomId(customId: string): this;
|
|
1112
|
+
/** Text displayed on the button. */
|
|
1113
|
+
setLabel(label: string): this;
|
|
1114
|
+
/**
|
|
1115
|
+
* Visual style:
|
|
1116
|
+
* - `primary` — blurple / brand colour
|
|
1117
|
+
* - `secondary` — grey
|
|
1118
|
+
* - `success` — green
|
|
1119
|
+
* - `danger` — red
|
|
1120
|
+
* - `link` — grey, navigates to a URL instead of creating an interaction
|
|
1121
|
+
*/
|
|
1122
|
+
setStyle(style: ButtonStyle): this;
|
|
1123
|
+
/** Emoji shown to the left of the label (unicode or custom e.g. `'👋'`). */
|
|
1124
|
+
setEmoji(emoji: string): this;
|
|
1125
|
+
/**
|
|
1126
|
+
* URL for `link` style buttons.
|
|
1127
|
+
* Sets the style to `'link'` automatically.
|
|
1128
|
+
*/
|
|
1129
|
+
setUrl(url: string): this;
|
|
1130
|
+
/** Prevent users from clicking the button. */
|
|
1131
|
+
setDisabled(disabled?: boolean): this;
|
|
1132
|
+
toJSON(): MessageComponent;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
interface SelectMenuOption {
|
|
1136
|
+
/** Visible label shown to the user. */
|
|
1137
|
+
label: string;
|
|
1138
|
+
/** Value returned in the interaction's `values` array. */
|
|
1139
|
+
value: string;
|
|
1140
|
+
/** Optional description shown below the label. */
|
|
1141
|
+
description?: string;
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Fluent builder for select-menu (dropdown) components.
|
|
1145
|
+
*
|
|
1146
|
+
* @example
|
|
1147
|
+
* const menu = new SelectMenuBuilder()
|
|
1148
|
+
* .setCustomId('colour_pick')
|
|
1149
|
+
* .setPlaceholder('Pick a colour…')
|
|
1150
|
+
* .addOption({ label: 'Red', value: 'red' })
|
|
1151
|
+
* .addOption({ label: 'Green', value: 'green' })
|
|
1152
|
+
* .addOption({ label: 'Blue', value: 'blue' })
|
|
1153
|
+
*
|
|
1154
|
+
* await client.messages.send(channelId, { content: 'Choose:', components: [menu.toJSON()] })
|
|
1155
|
+
*/
|
|
1156
|
+
declare class SelectMenuBuilder {
|
|
1157
|
+
private _customId;
|
|
1158
|
+
private _placeholder?;
|
|
1159
|
+
private _disabled;
|
|
1160
|
+
private readonly _options;
|
|
1161
|
+
/** Custom ID returned in the `SELECT_MENU` interaction. */
|
|
1162
|
+
setCustomId(customId: string): this;
|
|
1163
|
+
/** Greyed-out hint shown when nothing is selected. */
|
|
1164
|
+
setPlaceholder(placeholder: string): this;
|
|
1165
|
+
/** Prevent users from interacting with the menu. */
|
|
1166
|
+
setDisabled(disabled?: boolean): this;
|
|
1167
|
+
/** Add a single option. */
|
|
1168
|
+
addOption(option: SelectMenuOption): this;
|
|
1169
|
+
/** Add multiple options at once. */
|
|
1170
|
+
addOptions(...options: SelectMenuOption[]): this;
|
|
1171
|
+
/** Replace all options. */
|
|
1172
|
+
setOptions(options: SelectMenuOption[]): this;
|
|
1173
|
+
toJSON(): MessageComponent;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
type ComponentBuilder = ButtonBuilder | SelectMenuBuilder | {
|
|
1177
|
+
toJSON(): MessageComponent;
|
|
1178
|
+
};
|
|
1179
|
+
/**
|
|
1180
|
+
* Groups buttons (and/or a select menu) into a single row of components.
|
|
1181
|
+
*
|
|
1182
|
+
* @example
|
|
1183
|
+
* const row = new ActionRowBuilder()
|
|
1184
|
+
* .addComponent(new ButtonBuilder().setCustomId('yes').setLabel('Yes').setStyle('success'))
|
|
1185
|
+
* .addComponent(new ButtonBuilder().setCustomId('no').setLabel('No').setStyle('danger'))
|
|
1186
|
+
*
|
|
1187
|
+
* await interaction.reply({ content: 'Confirm?', components: row.toJSON() })
|
|
1188
|
+
*/
|
|
1189
|
+
declare class ActionRowBuilder {
|
|
1190
|
+
private readonly _components;
|
|
1191
|
+
/** Add a single component (button or select menu). */
|
|
1192
|
+
addComponent(component: ComponentBuilder): this;
|
|
1193
|
+
/** Add multiple components at once. */
|
|
1194
|
+
addComponents(...components: ComponentBuilder[]): this;
|
|
1195
|
+
/**
|
|
1196
|
+
* Serialise to a flat `MessageComponent[]` array — the format accepted by all API calls.
|
|
1197
|
+
*/
|
|
1198
|
+
toJSON(): MessageComponent[];
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* Fluent builder for a single slash command option (parameter).
|
|
1203
|
+
* Obtain one via the callback in `SlashCommandBuilder.addStringOption()` etc.
|
|
1204
|
+
*/
|
|
1205
|
+
declare class SlashCommandOptionBuilder {
|
|
1206
|
+
private _data;
|
|
1207
|
+
constructor(type: SlashCommandOption['type']);
|
|
1208
|
+
/** Internal option name (lowercase, no spaces). Shown after `/command ` in the client UI. */
|
|
1209
|
+
setName(name: string): this;
|
|
1210
|
+
/** Short human-readable description shown in the command picker. */
|
|
1211
|
+
setDescription(description: string): this;
|
|
1212
|
+
/** Whether users must supply this option before sending the command. */
|
|
1213
|
+
setRequired(required?: boolean): this;
|
|
1214
|
+
/**
|
|
1215
|
+
* Restrict the option to specific values.
|
|
1216
|
+
* The picker will show these as autocomplete suggestions.
|
|
1217
|
+
*/
|
|
1218
|
+
addChoice(name: string, value: string | number): this;
|
|
1219
|
+
/** Set all allowed choices at once. */
|
|
1220
|
+
setChoices(choices: Array<{
|
|
1221
|
+
name: string;
|
|
1222
|
+
value: string | number;
|
|
1223
|
+
}>): this;
|
|
1224
|
+
toJSON(): SlashCommandOption;
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Fluent builder for slash commands.
|
|
1228
|
+
*
|
|
1229
|
+
* @example
|
|
1230
|
+
* await client.commands.setSlash([
|
|
1231
|
+
* new SlashCommandBuilder()
|
|
1232
|
+
* .setName('ban')
|
|
1233
|
+
* .setDescription('Ban a member from this server')
|
|
1234
|
+
* .addUserOption((opt) =>
|
|
1235
|
+
* opt.setName('user').setDescription('Who to ban').setRequired(true)
|
|
1236
|
+
* )
|
|
1237
|
+
* .addStringOption((opt) =>
|
|
1238
|
+
* opt.setName('reason').setDescription('Reason for the ban')
|
|
1239
|
+
* )
|
|
1240
|
+
* .toJSON(),
|
|
1241
|
+
* ])
|
|
1242
|
+
*/
|
|
1243
|
+
declare class SlashCommandBuilder {
|
|
1244
|
+
private _data;
|
|
1245
|
+
/** Command name — lowercase, no spaces (e.g. `'ban'`, `'server-info'`). */
|
|
1246
|
+
setName(name: string): this;
|
|
1247
|
+
/** Short description shown in the command picker UI. */
|
|
1248
|
+
setDescription(description: string): this;
|
|
1249
|
+
/** Add a text (string) option. */
|
|
1250
|
+
addStringOption(fn: (opt: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
1251
|
+
/** Add an integer (whole number) option. */
|
|
1252
|
+
addIntegerOption(fn: (opt: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
1253
|
+
/** Add a boolean (true/false) option. */
|
|
1254
|
+
addBooleanOption(fn: (opt: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
1255
|
+
/** Add a user-mention option (returns a user ID string). */
|
|
1256
|
+
addUserOption(fn: (opt: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
1257
|
+
/** Add a channel-mention option (returns a channel ID string). */
|
|
1258
|
+
addChannelOption(fn: (opt: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
1259
|
+
/** Add a role-mention option (returns a role ID string). */
|
|
1260
|
+
addRoleOption(fn: (opt: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
1261
|
+
toJSON(): SlashCommandDefinition;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
export { ActionRowBuilder, type Attachment, type BotApplication, type BotEvent, type BotEventType, type BotModalDefinition, type BotModalField, type BotPermissionRecord, type BotUser, ButtonBuilder, type ButtonStyle, CommandsAPI, type ContextCommandDefinition, type EditMessageOptions, type Embed, EmbedBuilder, type EmbedField, type FetchMembersOptions, type FetchMessagesOptions, HttpClient, type Interaction, InteractionOptions, type InteractionType, InteractionsAPI, type Member, MembersAPI, type Message, type MessageComponent, MessagesAPI, ModalBuilder, NovaClient, type NovaClientEvents, type NovaClientOptions, NovaInteraction, type NovaServer, PermissionsAPI, type PermissionsQueryOptions, type PermissionsResult, type PollInteractionsOptions, type PrefixCommandDefinition, type Reaction, type RegisteredContextCommand, type RegisteredPrefixCommand, type RegisteredSlashCommand, type RespondInteractionOptions, SelectMenuBuilder, type SelectMenuOption, type SendMessageOptions, ServersAPI, SlashCommandBuilder, type SlashCommandDefinition, type SlashCommandOption, SlashCommandOptionBuilder, TextInputBuilder, type TextInputStyle };
|