gralonium 0.3.0 → 0.4.1

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 (44) hide show
  1. package/lib/classes/Client.d.ts +9 -3
  2. package/lib/classes/Client.js +2 -2
  3. package/lib/classes/Context.d.ts +42 -1
  4. package/lib/classes/Context.js +276 -13
  5. package/lib/classes/Cooldowns.d.ts +2 -0
  6. package/lib/classes/Cooldowns.js +28 -0
  7. package/lib/classes/HelpCommand.d.ts +55 -13
  8. package/lib/classes/HelpCommand.js +319 -1
  9. package/lib/classes/Loader.d.ts +10 -1
  10. package/lib/classes/Loader.js +143 -58
  11. package/lib/classes/Plugins.js +3 -2
  12. package/lib/classes/Utils.d.ts +1 -1
  13. package/lib/classes/Utils.js +103 -24
  14. package/lib/classes/builders/CommandBuilder.d.ts +24 -0
  15. package/lib/classes/builders/CommandBuilder.js +66 -2
  16. package/lib/classes/builders/ComponentsV2Builder.d.ts +288 -113
  17. package/lib/classes/builders/ComponentsV2Builder.js +1071 -180
  18. package/lib/classes/builders/GroupBuilder.d.ts +20 -0
  19. package/lib/classes/builders/GroupBuilder.js +37 -1
  20. package/lib/classes/builders/InteractionBuilder.d.ts +86 -25
  21. package/lib/classes/builders/InteractionBuilder.js +212 -1
  22. package/lib/classes/builders/ParamsBuilder.d.ts +118 -76
  23. package/lib/classes/builders/ParamsBuilder.js +167 -1
  24. package/lib/classes/builders/components/StyleMapper.d.ts +14 -2
  25. package/lib/classes/builders/components/StyleMapper.js +35 -9
  26. package/lib/classes/builders/components/helpers.d.ts +68 -4
  27. package/lib/classes/builders/components/helpers.js +366 -7
  28. package/lib/classes/builders/components/templates.d.ts +151 -9
  29. package/lib/classes/builders/components/templates.js +376 -17
  30. package/lib/classes/builders/components/text.d.ts +24 -0
  31. package/lib/classes/builders/components/text.js +91 -0
  32. package/lib/classes/experiments/Confirmator.d.ts +44 -26
  33. package/lib/classes/experiments/Confirmator.js +37 -21
  34. package/lib/classes/experiments/Paginator.d.ts +48 -29
  35. package/lib/classes/experiments/Paginator.js +48 -19
  36. package/lib/classes/views/V2Paginator.d.ts +91 -0
  37. package/lib/classes/views/V2Paginator.js +268 -0
  38. package/lib/classes/views/V2View.d.ts +113 -0
  39. package/lib/classes/views/V2View.js +438 -0
  40. package/lib/experiments.d.ts +2 -0
  41. package/lib/experiments.js +9 -1
  42. package/lib/main.d.ts +3 -0
  43. package/lib/main.js +3 -0
  44. package/package.json +3 -1
@@ -1,125 +1,300 @@
1
1
  import {
2
+ ActionRowBuilder,
3
+ AttachmentBuilder,
4
+ BaseMessageOptions,
2
5
  ButtonBuilder,
3
6
  ButtonStyle,
7
+ ChannelType,
4
8
  ContainerBuilder,
5
- MessageFlags,
9
+ FileBuilder,
10
+ MediaGalleryBuilder,
11
+ MediaGalleryItemBuilder,
12
+ Message,
13
+ MessageMentionOptions,
14
+ SectionBuilder,
15
+ SeparatorBuilder,
16
+ SeparatorSpacingSize,
17
+ StringSelectMenuOptionBuilder,
18
+ TextDisplayBuilder,
19
+ ThumbnailBuilder,
6
20
  } from "discord.js";
7
- import { ButtonStyleInput } from "./components/StyleMapper.js";
21
+ import type { DisableComponentsOptions, EmojiInput, ParsedEmoji } from "./components/helpers";
22
+ import type { ButtonStyleInput } from "./components/StyleMapper";
23
+ import type { V2CardOptions, V2ConfirmOptions, V2ImageViewOptions, V2ListOptions } from "./components/templates";
24
+ import { V2Text, type V2FieldRow } from "./components/text";
25
+
26
+ export type ButtonStyleResolvable =
27
+ | "primary"
28
+ | "secondary"
29
+ | "success"
30
+ | "danger"
31
+ | "link"
32
+ | "premium"
33
+ | ButtonStyle
34
+ | number;
35
+
36
+ export type ColorResolvable = string | number | [number, number, number] | null;
37
+
38
+ export type SeparatorSpacingResolvable = "small" | "large" | SeparatorSpacingSize;
39
+
40
+ export type V2SectionFieldRow = V2FieldRow;
41
+
42
+ export interface ComponentsV2BuilderOptions {
43
+ color?: ColorResolvable;
44
+ accentColor?: ColorResolvable;
45
+ spoiler?: boolean;
46
+ safeMentions?: boolean;
47
+ }
48
+
49
+ export interface V2TextOptions {
50
+ ignoreEmpty?: boolean;
51
+ maxLength?: number;
52
+ joinWith?: string;
53
+ }
54
+
55
+ export interface V2FieldsOptions extends V2TextOptions {
56
+ omitEmpty?: boolean;
57
+ omitIfEmpty?: boolean;
58
+ fallback?: string;
59
+ }
60
+
61
+ export interface V2SectionBlockOptions extends V2FieldsOptions {
62
+ separator?: boolean | "small" | "large";
63
+ }
64
+
65
+ export interface V2QuoteOptions {
66
+ ignoreEmpty?: boolean;
67
+ maxLength?: number;
68
+ fallback?: string;
69
+ }
70
+
71
+ export interface V2SmartTextOptions {
72
+ overflow?: "file" | "clip" | "split";
73
+ maxLength?: number;
74
+ limit?: number;
75
+ filename?: string;
76
+ fileDescription?: string;
77
+ spoiler?: boolean;
78
+ preview?: boolean;
79
+ previewLimit?: number;
80
+ overflowNotice?: string;
81
+ codeBlock?: string;
82
+ chunkSize?: number;
83
+ fallbackToFile?: boolean;
84
+ ignoreEmpty?: boolean;
85
+ }
86
+
87
+ export interface V2ButtonObjectOptions {
88
+ label?: string;
89
+ customId?: string;
90
+ id?: string;
91
+ style?: ButtonStyleResolvable;
92
+ url?: string;
93
+ emoji?: EmojiInput;
94
+ disabled?: boolean;
95
+ skuId?: string;
96
+ }
97
+
98
+ export type V2ButtonTuple = [
99
+ label: string,
100
+ customId?: string | null,
101
+ style?: ButtonStyleResolvable,
102
+ url?: string,
103
+ extra?: Partial<V2ButtonObjectOptions>
104
+ ];
105
+
106
+ export type V2ButtonInput = ButtonBuilder | V2ButtonObjectOptions | V2ButtonTuple;
107
+
108
+ export interface V2SectionOptions extends V2TextOptions {
109
+ thumbnail?: string | ThumbnailBuilder | { url?: string | null; description?: string; spoiler?: boolean } | null;
110
+ thumbnailDescription?: string;
111
+ thumbnailSpoiler?: boolean;
112
+ button?: ButtonBuilder | V2ButtonObjectOptions;
113
+ fallbackToText?: boolean;
114
+ }
115
+
116
+ export interface V2GalleryItemObject {
117
+ url: string;
118
+ description?: string;
119
+ spoiler?: boolean;
120
+ }
121
+
122
+ export type V2GalleryEntry = string | MediaGalleryItemBuilder | V2GalleryItemObject | null | undefined | false;
123
+ export type V2GalleryInput = MediaGalleryBuilder | V2GalleryEntry | V2GalleryEntry[];
124
+
125
+ export interface V2GalleryOptions {
126
+ description?: string;
127
+ spoiler?: boolean;
128
+ ignoreEmpty?: boolean;
129
+ ignoreInvalid?: boolean;
130
+ autoSplit?: boolean;
131
+ }
132
+
133
+ export interface V2AttachmentOptions {
134
+ name?: string;
135
+ description?: string;
136
+ }
137
+
138
+ export interface V2FileOptions extends V2AttachmentOptions {
139
+ spoiler?: boolean;
140
+ attachment?: Buffer | Uint8Array | string | AttachmentBuilder;
141
+ }
142
+
143
+ export interface V2FileInput {
144
+ source: Buffer | Uint8Array | string | AttachmentBuilder;
145
+ name?: string;
146
+ description?: string;
147
+ spoiler?: boolean;
148
+ }
149
+
150
+ export interface V2StringSelectOption {
151
+ label: string;
152
+ value?: string;
153
+ description?: string;
154
+ emoji?: EmojiInput;
155
+ default?: boolean;
156
+ }
157
+
158
+ export type V2SelectOptionTuple = [
159
+ label: string,
160
+ value?: string,
161
+ description?: string,
162
+ emoji?: EmojiInput,
163
+ isDefault?: boolean
164
+ ];
165
+
166
+ export interface V2SelectMenuConfig {
167
+ type?: "string" | "user" | "role" | "channel" | "mentionable";
168
+ customId?: string;
169
+ id?: string;
170
+ placeholder?: string;
171
+ minValues?: number;
172
+ maxValues?: number;
173
+ disabled?: boolean;
174
+ options?: Array<V2StringSelectOption | V2SelectOptionTuple | StringSelectMenuOptionBuilder>;
175
+ channelTypes?: ChannelType[];
176
+ defaultValues?: Array<string | { id: string; type: number }>;
177
+ defaultUsers?: string[];
178
+ defaultRoles?: string[];
179
+ defaultChannels?: string[];
180
+ }
181
+
182
+ export interface V2PayloadOptions {
183
+ ephemeral?: boolean;
184
+ suppressNotifications?: boolean;
185
+ flags?: number;
186
+ safeMentions?: boolean;
187
+ allowedMentions?: MessageMentionOptions;
188
+ files?: BaseMessageOptions["files"];
189
+ }
190
+
191
+ export interface V2BuiltPayload {
192
+ components: TopLevelV2Component[];
193
+ flags: number;
194
+ files?: Array<AttachmentBuilder | NonNullable<BaseMessageOptions["files"]>[number]>;
195
+ allowedMentions?: MessageMentionOptions;
196
+ }
197
+
198
+ export type TopLevelV2Component =
199
+ | ContainerBuilder
200
+ | SectionBuilder
201
+ | TextDisplayBuilder
202
+ | SeparatorBuilder
203
+ | MediaGalleryBuilder
204
+ | FileBuilder
205
+ | ActionRowBuilder<any>;
8
206
 
9
- /**
10
- * Fluent proxy returned by `ComponentsV2Builder#addSelectMenu()`.
11
- * Call `.end()` to return to the parent builder.
12
- */
13
207
  export declare class SelectMenuProxy {
14
- /**
15
- * Add an option to the select menu.
16
- *
17
- * @param label - Display label for the option
18
- * @param value - Value submitted when the option is selected
19
- * @param emoji - Unicode emoji (optional)
20
- * @param description - Short description shown below the label (optional)
21
- */
22
- addOption(label: string, value?: string, emoji?: string, description?: string): this;
23
-
24
- /** Return to the parent `ComponentsV2Builder`. */
208
+ addOption(option: V2StringSelectOption | StringSelectMenuOptionBuilder): this;
209
+ addOption(label: string, value: string, description?: string, emoji?: EmojiInput, isDefault?: boolean): this;
210
+ addOptions(options: Array<V2StringSelectOption | V2SelectOptionTuple | StringSelectMenuOptionBuilder | false | null | undefined>): this;
211
+ setPlaceholder(placeholder: string): this;
212
+ setMinValues(min: number): this;
213
+ setMaxValues(max: number): this;
214
+ setDisabled(disabled?: boolean): this;
25
215
  end(): ComponentsV2Builder;
26
216
  }
27
217
 
28
- /**
29
- * ComponentsV2Builder — a fluent builder that abstracts the complexity of
30
- * Discord.js Components V2 (Containers, Separators, TextDisplays, Buttons,
31
- * and StringSelectMenus).
32
- *
33
- * @example
34
- * ```ts
35
- * const components = new ComponentsV2Builder()
36
- * .addText("## Welcome!")
37
- * .addSeparator("small")
38
- * .addButton("Click Me", "btn_1", "primary")
39
- * .addButton("Cancel", "btn_2", "secondary")
40
- * .build();
41
- *
42
- * interaction.reply({ components, flags: ComponentsV2Builder.flags });
43
- * ```
44
- */
45
218
  export declare class ComponentsV2Builder {
46
- /**
47
- * Add a text display (markdown supported) to the container.
48
- */
49
- addText(content: string): this;
50
-
51
- /**
52
- * Add a separator to the container.
53
- *
54
- * @param spacing - "small" | "large" (defaults to "small")
55
- * @param divider - Whether to render a visual divider line (defaults to true)
56
- */
57
- addSeparator(spacing?: "small" | "large", divider?: boolean): this;
58
-
59
- /**
60
- * Add a single button to the container.
61
- * Buttons are batched and placed into ActionRows automatically (max 5 per row).
62
- *
63
- * @param label - Button label text
64
- * @param customId - Custom ID (or URL for link buttons)
65
- * @param style - "primary" | "secondary" | "success" | "danger" | "link"
66
- * @param url - URL (only used when style is "link")
67
- */
68
- addButton(label: string, customId?: string, style?: ButtonStyleInput, url?: string): this;
69
-
70
- /**
71
- * Add multiple pre-built `ButtonBuilder` instances at once.
72
- * They are batched into ActionRows automatically (max 5 per row).
73
- */
74
- addButtons(...buttons: ButtonBuilder[]): this;
75
-
76
- /**
77
- * Add a `StringSelectMenu` to the container.
78
- * Returns a `SelectMenuProxy` for adding options fluently.
79
- * Call `.end()` on the proxy to return to this builder.
80
- *
81
- * @param customId - Custom ID for the select menu
82
- * @param placeholder - Placeholder text (optional)
83
- */
84
- addSelectMenu(customId?: string, placeholder?: string): SelectMenuProxy;
85
-
86
- /**
87
- * Mark the container as a spoiler (blurred until clicked).
88
- */
89
- setSpoiler(spoiler: boolean): this;
90
-
91
- /**
92
- * Build and return the components array ready for
93
- * `interaction.reply({ components: builder.build(), flags: ComponentsV2Builder.flags })`.
94
- */
95
- build(): ContainerBuilder[];
96
-
97
- /**
98
- * The `MessageFlags` bitmask required for Components V2 messages.
99
- *
100
- * ```ts
101
- * interaction.reply({ components: builder.build(), flags: ComponentsV2Builder.flags });
102
- * ```
103
- */
104
- static readonly flags: MessageFlags;
105
-
106
- /**
107
- * Create a Confirm / Cancel button container.
108
- */
109
- static createConfirm(confirmId?: string, cancelId?: string): ComponentsV2Builder;
110
-
111
- /**
112
- * Create a ticket category select menu container.
113
- */
114
- static createTicketMenu(customId?: string): ComponentsV2Builder;
115
-
116
- /**
117
- * Create a plan selector container (bot / game / web hosting example).
118
- */
119
- static createPlanSelector(customId?: string): ComponentsV2Builder;
120
-
121
- /**
122
- * Create a role selector menu container.
123
- */
124
- static createRoleMenu(customId?: string): ComponentsV2Builder;
219
+ static readonly flags: number;
220
+ static readonly MAX_TEXT_LENGTH: number;
221
+ static readonly SAFE_TEXT_LENGTH: number;
222
+ static readonly MAX_COMPONENTS: number;
223
+ static readonly MAX_TOP_LEVEL_COMPONENTS: number;
224
+ static readonly text: typeof V2Text;
225
+ static clipText(text: string, maxLen?: number, fallback?: string): string;
226
+ static resolveColor(color?: ColorResolvable, fallback?: ColorResolvable): number | null;
227
+ static setDefaultButtonStyle(style?: ButtonStyleInput | null): ButtonStyle;
228
+ static getDefaultButtonStyle(): ButtonStyle;
229
+ static parseEmoji(emoji?: EmojiInput): ParsedEmoji | null;
230
+ static isValidMediaUrl(url?: string | null): boolean;
231
+ static isValidLinkUrl(url?: string | null): boolean;
232
+ static disableComponents(components: any[], options?: DisableComponentsOptions): any[];
233
+ static disableMessageComponents(message: Message, options?: DisableComponentsOptions): Promise<Message | null>;
234
+ static countTextLength(components: any[]): number;
235
+ static countComponents(components: any[]): number;
236
+ static isBuilder(value: unknown): value is ComponentsV2Builder;
237
+
238
+ constructor(options?: ComponentsV2BuilderOptions);
239
+
240
+ setColor(color: ColorResolvable): this;
241
+ setAccentColor(color: ColorResolvable): this;
242
+ setSpoiler(spoiler?: boolean): this;
243
+ addContainer(options?: ComponentsV2BuilderOptions): this;
244
+ outside(): this;
245
+ inside(options?: ComponentsV2BuilderOptions & { new?: boolean; newContainer?: boolean }): this;
246
+
247
+ addText(content: string | TextDisplayBuilder | Array<string | TextDisplayBuilder | false | null | undefined>, options?: V2TextOptions): this;
248
+ addFields(rows: Array<V2FieldRow | false | null | undefined>, options?: V2FieldsOptions): this;
249
+ addSectionBlock(heading: string, rows: Array<V2FieldRow | false | null | undefined>, options?: V2SectionBlockOptions): this;
250
+ addQuote(text: string, options?: V2QuoteOptions): this;
251
+ addSmartText(text: string, options?: V2SmartTextOptions): this;
252
+
253
+ addSection(
254
+ texts: string | TextDisplayBuilder | Array<string | TextDisplayBuilder | false | null | undefined>,
255
+ accessoryOrOptions?: ThumbnailBuilder | ButtonBuilder | V2SectionOptions
256
+ ): this;
257
+
258
+ addGallery(itemsOrUrl: V2GalleryInput, options?: V2GalleryOptions): this;
259
+ addAttachment(source: Buffer | Uint8Array | string | AttachmentBuilder, options?: V2AttachmentOptions): this;
260
+ addFile(source: Buffer | Uint8Array | string | AttachmentBuilder | FileBuilder, options?: V2FileOptions): this;
261
+
262
+ addSeparator(spacing?: SeparatorSpacingResolvable | { spacing?: SeparatorSpacingResolvable; divider?: boolean }, divider?: boolean): this;
263
+ addSpacer(spacing?: SeparatorSpacingResolvable): this;
264
+
265
+ addButton(options: V2ButtonObjectOptions | ButtonBuilder): this;
266
+ addButton(label: string, customId?: string | null, style?: ButtonStyleResolvable, url?: string, extraOptions?: Partial<V2ButtonObjectOptions>): this;
267
+ addButtons(buttons: Array<V2ButtonInput | false | null | undefined>, options?: { autoWrap?: boolean }): this;
268
+ addButtonsRow(buttons: Array<V2ButtonInput | false | null | undefined>, options?: { autoWrap?: boolean }): this;
269
+
270
+ addSelectMenu(config: V2SelectMenuConfig): this;
271
+ addSelectMenu(customId: string, placeholder?: string): SelectMenuProxy;
272
+ addSelectRow(config: V2SelectMenuConfig): this;
273
+ addUserSelectMenu(configOrCustomId: string | Omit<V2SelectMenuConfig, "type">, options?: Omit<V2SelectMenuConfig, "type" | "customId">): this;
274
+ addRoleSelectMenu(configOrCustomId: string | Omit<V2SelectMenuConfig, "type">, options?: Omit<V2SelectMenuConfig, "type" | "customId">): this;
275
+ addChannelSelectMenu(configOrCustomId: string | Omit<V2SelectMenuConfig, "type">, options?: Omit<V2SelectMenuConfig, "type" | "customId">): this;
276
+ addMentionableSelectMenu(configOrCustomId: string | Omit<V2SelectMenuConfig, "type">, options?: Omit<V2SelectMenuConfig, "type" | "customId">): this;
277
+
278
+ addComponent(component: TopLevelV2Component): this;
279
+
280
+ readonly textLength: number;
281
+ readonly remainingChars: number;
282
+ readonly componentCount: number;
283
+ readonly remainingComponents: number;
284
+ readonly files: AttachmentBuilder[];
285
+
286
+ build(): TopLevelV2Component[];
287
+ toJSON(): Record<string, unknown>[];
288
+ toPayload(options?: V2PayloadOptions): V2BuiltPayload;
289
+
290
+ static card(options?: V2CardOptions): ComponentsV2Builder;
291
+ static imageView(options?: V2ImageViewOptions): ComponentsV2Builder;
292
+ static list<T = unknown>(options?: V2ListOptions<T>): ComponentsV2Builder;
293
+ static confirm(options: V2ConfirmOptions): ComponentsV2Builder;
294
+ static confirm(confirmId: string, cancelId: string, title?: string, message?: string): ComponentsV2Builder;
295
+ static createConfirm(options: V2ConfirmOptions): ComponentsV2Builder;
296
+ static createConfirm(confirmId: string, cancelId: string, title?: string, message?: string): ComponentsV2Builder;
297
+ static createTicketMenu(customId: string, title?: string, description?: string): { builder: ComponentsV2Builder; select: SelectMenuProxy };
298
+ static createPlanSelector(customId: string, title?: string, description?: string): { builder: ComponentsV2Builder; select: SelectMenuProxy };
299
+ static createRoleMenu(customId: string, title?: string, description?: string): { builder: ComponentsV2Builder; select: SelectMenuProxy };
125
300
  }