gralonium 0.2.0 → 0.4.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.
Files changed (47) hide show
  1. package/lib/classes/Client.d.ts +9 -11
  2. package/lib/classes/Client.js +10 -13
  3. package/lib/classes/Context.d.ts +43 -4
  4. package/lib/classes/Context.js +251 -12
  5. package/lib/classes/Cooldowns.d.ts +3 -3
  6. package/lib/classes/Cooldowns.js +3 -8
  7. package/lib/classes/HelpCommand.d.ts +55 -13
  8. package/lib/classes/HelpCommand.js +319 -1
  9. package/lib/classes/Loader.d.ts +17 -11
  10. package/lib/classes/Loader.js +43 -42
  11. package/lib/classes/Utils.d.ts +4 -5
  12. package/lib/classes/Utils.js +32 -21
  13. package/lib/classes/builders/CommandBuilder.d.ts +10 -0
  14. package/lib/classes/builders/CommandBuilder.js +16 -0
  15. package/lib/classes/builders/ComponentsV2Builder.d.ts +285 -113
  16. package/lib/classes/builders/ComponentsV2Builder.js +1069 -182
  17. package/lib/classes/builders/GroupBuilder.d.ts +9 -0
  18. package/lib/classes/builders/GroupBuilder.js +16 -0
  19. package/lib/classes/builders/InteractionBuilder.d.ts +40 -25
  20. package/lib/classes/builders/InteractionBuilder.js +102 -1
  21. package/lib/classes/builders/components/StyleMapper.d.ts +1 -1
  22. package/lib/classes/builders/components/StyleMapper.js +2 -1
  23. package/lib/classes/builders/components/helpers.d.ts +68 -4
  24. package/lib/classes/builders/components/helpers.js +366 -7
  25. package/lib/classes/builders/components/templates.d.ts +151 -9
  26. package/lib/classes/builders/components/templates.js +376 -17
  27. package/lib/classes/builders/components/text.d.ts +24 -0
  28. package/lib/classes/builders/components/text.js +91 -0
  29. package/lib/classes/experiments/Confirmator.d.ts +45 -50
  30. package/lib/classes/experiments/Confirmator.js +37 -21
  31. package/lib/classes/experiments/Paginator.d.ts +49 -56
  32. package/lib/classes/experiments/Paginator.js +48 -19
  33. package/lib/classes/views/V2Paginator.d.ts +91 -0
  34. package/lib/classes/views/V2Paginator.js +268 -0
  35. package/lib/classes/views/V2View.d.ts +113 -0
  36. package/lib/classes/views/V2View.js +438 -0
  37. package/lib/experiments.d.ts +2 -0
  38. package/lib/experiments.js +9 -1
  39. package/lib/main.d.ts +3 -3
  40. package/lib/main.js +5 -5
  41. package/package.json +6 -15
  42. package/lib/events/interactionCreate.d.ts +0 -4
  43. package/lib/events/interactionCreate.js +0 -17
  44. package/lib/events/messageCreate.d.ts +0 -4
  45. package/lib/events/messageCreate.js +0 -17
  46. package/lib/events/messageUpdate.d.ts +0 -4
  47. package/lib/events/messageUpdate.js +0 -17
@@ -1,41 +1,400 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRoleMenu =
4
+ exports.createPlanSelector =
5
+ exports.createTicketMenu =
6
+ exports.createConfirm =
7
+ exports.createList =
8
+ exports.createImageView =
9
+ exports.createCard =
10
+ void 0;
11
+
12
+ const { V2Text } = require("./text.js");
13
+ const { generateCustomId } = require("./helpers.js");
14
+
15
+ function getBuilder() {
16
+ return require("../ComponentsV2Builder.js").ComponentsV2Builder;
17
+ }
18
+
19
+ function formatHeadingIfPlain(text, level = 3) {
20
+ const str = String(text ?? "").trim();
21
+ if (!str) return "";
22
+ if (/^(?:#{1,3}\s|\*\*)/.test(str)) return str;
23
+ return V2Text.heading(str, level);
24
+ }
25
+
26
+ function formatSubtextIfPlain(text) {
27
+ const str = String(text ?? "").trim();
28
+ if (!str) return "";
29
+ if (str.startsWith("-# ")) return str;
30
+ return V2Text.subtext(str);
31
+ }
32
+
2
33
  /**
3
- * templates.js — re-exports the static template factories from ComponentsV2Builder
4
- * as standalone named functions for convenient direct imports.
34
+ * Builds an agnostic V2 card with optional header section (thumbnail/button),
35
+ * description, fields, extra sections, media gallery, files, footer, and action buttons.
5
36
  */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createRoleMenu = exports.createPlanSelector = exports.createTicketMenu = exports.createConfirm = void 0;
37
+ function createCard(options = {}) {
38
+ const Builder = getBuilder();
39
+ const builder = new Builder({
40
+ color: options.color ?? options.accentColor,
41
+ spoiler: options.spoiler,
42
+ safeMentions: options.safeMentions,
43
+ });
44
+
45
+ const headerLines = [];
46
+ if (options.title) headerLines.push(formatHeadingIfPlain(options.title, options.headingLevel ?? 3));
47
+ if (options.subtitle) headerLines.push(String(options.subtitle).trim());
48
+
49
+ const hasHeaderThumbnail = options.thumbnail !== undefined && options.thumbnail !== null;
50
+ const hasHeaderButton = Boolean(options.headerButton);
51
+
52
+ if (headerLines.length > 0) {
53
+ if (hasHeaderThumbnail || hasHeaderButton) {
54
+ builder.addSection(headerLines, {
55
+ thumbnail: options.thumbnail,
56
+ thumbnailDescription: options.thumbnailDescription,
57
+ thumbnailSpoiler: options.thumbnailSpoiler,
58
+ button: options.headerButton,
59
+ fallbackToText: true,
60
+ });
61
+ } else {
62
+ builder.addText(headerLines.join("\n"));
63
+ }
64
+ }
65
+
66
+ if (options.description) {
67
+ if (headerLines.length > 0 && options.headerSeparator !== false) {
68
+ builder.addSeparator(options.separatorSpacing || "small");
69
+ }
70
+ if (options.overflow) {
71
+ builder.addSmartText(options.description, {
72
+ overflow: options.overflow,
73
+ filename: options.overflowFilename || "content.txt",
74
+ maxLength: options.maxDescriptionLength,
75
+ ignoreEmpty: true,
76
+ });
77
+ } else {
78
+ builder.addText(options.description, {
79
+ ignoreEmpty: true,
80
+ maxLength: options.maxDescriptionLength,
81
+ });
82
+ }
83
+ }
8
84
 
9
- const ComponentsV2Builder_js_1 = require("../ComponentsV2Builder.js");
85
+ if (Array.isArray(options.fields) && options.fields.length > 0) {
86
+ if ((headerLines.length > 0 || options.description) && options.fieldsSeparator !== false) {
87
+ builder.addSeparator(options.separatorSpacing || "small");
88
+ }
89
+ builder.addFields(options.fields, {
90
+ omitIfEmpty: options.omitEmptyFields !== false,
91
+ fallback: options.fieldFallback,
92
+ });
93
+ }
94
+
95
+ if (Array.isArray(options.sections)) {
96
+ for (const sec of options.sections) {
97
+ if (!sec) continue;
98
+ if (Array.isArray(sec.rows) || Array.isArray(sec.fields)) {
99
+ builder.addSectionBlock(sec.heading || sec.title || "", sec.rows || sec.fields, {
100
+ separator: sec.separator !== undefined ? sec.separator : true,
101
+ omitIfEmpty: sec.omitIfEmpty !== false,
102
+ fallback: sec.fallback,
103
+ });
104
+ } else if (sec.text) {
105
+ if (sec.separator !== false) builder.addSeparator(options.separatorSpacing || "small");
106
+ builder.addText(sec.text, { ignoreEmpty: true });
107
+ }
108
+ }
109
+ }
110
+
111
+ const gallery = options.gallery ?? options.image;
112
+ if (gallery) {
113
+ if (options.gallerySeparator !== false && (headerLines.length > 0 || options.description || options.fields?.length)) {
114
+ builder.addSpacer(options.separatorSpacing || "small");
115
+ }
116
+ builder.addGallery(gallery, { ignoreEmpty: true, ignoreInvalid: options.ignoreInvalidMedia !== false });
117
+ }
118
+
119
+ if (Array.isArray(options.files)) {
120
+ for (const file of options.files) {
121
+ if (!file) continue;
122
+ if (typeof file === "string" || Buffer.isBuffer(file)) {
123
+ builder.addFile(file);
124
+ } else if (file.source !== undefined) {
125
+ builder.addFile(file.source, {
126
+ name: file.name,
127
+ description: file.description,
128
+ spoiler: file.spoiler,
129
+ });
130
+ }
131
+ }
132
+ }
133
+
134
+ if (options.footer) {
135
+ if (options.footerSeparator !== false) {
136
+ builder.addSpacer("small");
137
+ }
138
+ builder.addText(formatSubtextIfPlain(options.footer), { ignoreEmpty: true });
139
+ }
140
+
141
+ if (Array.isArray(options.buttons) && options.buttons.length > 0) {
142
+ if (options.buttonSpacer !== false) {
143
+ builder.addSpacer("small");
144
+ }
145
+ builder.addButtonsRow(options.buttons, { autoWrap: true });
146
+ }
147
+
148
+ if (Array.isArray(options.outsideButtons) && options.outsideButtons.length > 0) {
149
+ builder.outside().addButtonsRow(options.outsideButtons, { autoWrap: true }).inside();
150
+ }
151
+
152
+ return builder;
153
+ }
154
+ exports.createCard = createCard;
10
155
 
11
156
  /**
12
- * Create a Confirm / Cancel button container.
157
+ * Builds an agnostic media/image showcase card with optional links and footer.
13
158
  */
14
- function createConfirm(confirmId, cancelId) {
15
- return ComponentsV2Builder_js_1.ComponentsV2Builder.createConfirm(confirmId, cancelId);
159
+ function createImageView(options = {}) {
160
+ const Builder = getBuilder();
161
+ const builder = new Builder({
162
+ color: options.color ?? options.accentColor,
163
+ spoiler: options.spoiler,
164
+ safeMentions: options.safeMentions,
165
+ });
166
+
167
+ const headerLines = [];
168
+ if (options.title) headerLines.push(formatHeadingIfPlain(options.title, options.headingLevel ?? 3));
169
+ if (options.subtitle) headerLines.push(String(options.subtitle).trim());
170
+ if (headerLines.length > 0) {
171
+ builder.addText(headerLines.join("\n"));
172
+ }
173
+
174
+ if (options.description) {
175
+ builder.addText(options.description, { ignoreEmpty: true });
176
+ }
177
+
178
+ const media = options.images ?? options.gallery ?? options.image ?? options.url;
179
+ if (media) {
180
+ if (headerLines.length > 0 || options.description) {
181
+ builder.addSpacer("small");
182
+ }
183
+ builder.addGallery(media, {
184
+ description: options.imageDescription,
185
+ spoiler: options.imageSpoiler,
186
+ ignoreEmpty: true,
187
+ ignoreInvalid: options.ignoreInvalidMedia !== false,
188
+ });
189
+ }
190
+
191
+ const buttons = [];
192
+ if (Array.isArray(options.links)) {
193
+ for (const link of options.links) {
194
+ if (!link?.url) continue;
195
+ buttons.push({
196
+ label: link.label || "Abrir enlace",
197
+ style: link.style || "link",
198
+ url: link.url,
199
+ emoji: link.emoji,
200
+ disabled: link.disabled,
201
+ });
202
+ }
203
+ }
204
+ if (Array.isArray(options.buttons)) {
205
+ buttons.push(...options.buttons);
206
+ }
207
+
208
+ if (buttons.length > 0) {
209
+ builder.addSpacer("small");
210
+ builder.addButtonsRow(buttons, { autoWrap: true });
211
+ }
212
+
213
+ if (options.footer) {
214
+ builder.addSpacer("small");
215
+ builder.addText(formatSubtextIfPlain(options.footer), { ignoreEmpty: true });
216
+ }
217
+
218
+ if (Array.isArray(options.outsideButtons) && options.outsideButtons.length > 0) {
219
+ builder.outside().addButtonsRow(options.outsideButtons, { autoWrap: true }).inside();
220
+ }
221
+
222
+ return builder;
223
+ }
224
+ exports.createImageView = createImageView;
225
+
226
+ /**
227
+ * Builds an agnostic structured list card with page metadata and optional buttons.
228
+ */
229
+ function createList(options = {}) {
230
+ const Builder = getBuilder();
231
+ const builder = new Builder({
232
+ color: options.color ?? options.accentColor,
233
+ spoiler: options.spoiler,
234
+ safeMentions: options.safeMentions,
235
+ });
236
+
237
+ if (options.title || options.subtitle) {
238
+ const header = [];
239
+ if (options.title) header.push(formatHeadingIfPlain(options.title, options.headingLevel ?? 3));
240
+ if (options.subtitle) header.push(String(options.subtitle).trim());
241
+ if (options.thumbnail) {
242
+ builder.addSection(header, { thumbnail: options.thumbnail, fallbackToText: true });
243
+ } else {
244
+ builder.addText(header.join("\n"));
245
+ }
246
+ builder.addSeparator("small");
247
+ }
248
+
249
+ const rawItems = Array.isArray(options.items) ? options.items : [];
250
+ if (rawItems.length === 0) {
251
+ builder.addText(options.emptyText || "-# Sin elementos para mostrar.", { ignoreEmpty: true });
252
+ } else {
253
+ const startIndex = Math.max(0, Number(options.startIndex) || 0);
254
+ const numbered = Boolean(options.numbered);
255
+ const renderItem =
256
+ typeof options.renderItem === "function"
257
+ ? options.renderItem
258
+ : (item, idx) => {
259
+ const text =
260
+ typeof item === "string"
261
+ ? item
262
+ : item && typeof item === "object"
263
+ ? item.line ?? `${item.label ? `**${item.label}:** ` : ""}${item.value ?? item.name ?? ""}`
264
+ : String(item ?? "");
265
+ if (!text) return "";
266
+ if (numbered) return `**${startIndex + idx + 1}.** ${text}`;
267
+ return text.startsWith(">") || text.startsWith("-") ? text : `• ${text}`;
268
+ };
269
+
270
+ const lines = rawItems.map((item, idx) => renderItem(item, idx)).filter(Boolean);
271
+ const body = lines.join(options.itemSeparator ?? "\n");
272
+ builder.addSmartText(body || options.emptyText || "-# Sin elementos para mostrar.", {
273
+ overflow: options.overflow || "clip",
274
+ filename: options.overflowFilename || "list.txt",
275
+ });
276
+ }
277
+
278
+ const footerParts = [];
279
+ if (options.page !== undefined && options.totalPages !== undefined) {
280
+ const pageNum = Math.max(1, Number(options.page) || 1);
281
+ const totalNum = Math.max(1, Number(options.totalPages) || 1);
282
+ const baseText =
283
+ typeof options.pageFormatter === "function"
284
+ ? options.pageFormatter(pageNum, totalNum, options.totalItems)
285
+ : `Página ${pageNum}/${totalNum}${options.totalItems !== undefined ? ` • ${options.totalItems} elementos` : ""}`;
286
+ if (baseText) footerParts.push(baseText);
287
+ }
288
+ if (options.footer) footerParts.push(String(options.footer).trim());
289
+
290
+ if (footerParts.length > 0) {
291
+ builder.addSpacer("small");
292
+ builder.addText(formatSubtextIfPlain(footerParts.join(" • ")));
293
+ }
294
+
295
+ if (Array.isArray(options.buttons) && options.buttons.length > 0) {
296
+ builder.addSpacer("small");
297
+ builder.addButtonsRow(options.buttons, { autoWrap: true });
298
+ }
299
+
300
+ if (Array.isArray(options.outsideButtons) && options.outsideButtons.length > 0) {
301
+ builder.outside().addButtonsRow(options.outsideButtons, { autoWrap: true }).inside();
302
+ }
303
+
304
+ return builder;
305
+ }
306
+ exports.createList = createList;
307
+
308
+ /**
309
+ * Confirmation prompt builder.
310
+ * Supports both legacy positional arguments `(confirmId, cancelId, title?, message?)`
311
+ * and an options object `{ title, message, description, confirmId, cancelId, ... }`.
312
+ */
313
+ function createConfirm(confirmIdOrOptions, cancelId, title = "Confirmation Required", message = "Are you sure you want to proceed? This action cannot be undone.") {
314
+ const Builder = getBuilder();
315
+
316
+ if (confirmIdOrOptions && typeof confirmIdOrOptions === "object") {
317
+ const opts = confirmIdOrOptions;
318
+ const builder = new Builder({
319
+ color: opts.color ?? opts.accentColor,
320
+ spoiler: opts.spoiler,
321
+ safeMentions: opts.safeMentions,
322
+ });
323
+
324
+ const heading = opts.title !== undefined ? formatHeadingIfPlain(opts.title, opts.headingLevel ?? 3) : "### Confirmation Required";
325
+ const body = opts.message ?? opts.description ?? "Are you sure you want to proceed?";
326
+
327
+ if (heading) builder.addText(heading);
328
+ if (body) builder.addText(body);
329
+ if (opts.warning) {
330
+ builder.addText(V2Text.quote(opts.warning));
331
+ }
332
+
333
+ builder.addSeparator("small");
334
+ builder.addButtonsRow([
335
+ {
336
+ label: opts.confirmLabel || "Confirm",
337
+ customId: opts.confirmId || generateCustomId("confirm"),
338
+ style: opts.confirmStyle || "success",
339
+ emoji: opts.confirmEmoji,
340
+ disabled: opts.disabled,
341
+ },
342
+ {
343
+ label: opts.cancelLabel || "Cancel",
344
+ customId: opts.cancelId || generateCustomId("cancel"),
345
+ style: opts.cancelStyle || "danger",
346
+ emoji: opts.cancelEmoji,
347
+ disabled: opts.disabled,
348
+ },
349
+ ]);
350
+
351
+ if (Array.isArray(opts.outsideButtons) && opts.outsideButtons.length > 0) {
352
+ builder.outside().addButtonsRow(opts.outsideButtons, { autoWrap: true }).inside();
353
+ }
354
+
355
+ return builder;
356
+ }
357
+
358
+ return new Builder()
359
+ .addText(`## ${title}`)
360
+ .addText(message)
361
+ .addSeparator("small")
362
+ .addButtons([
363
+ ["Confirm", confirmIdOrOptions, "success"],
364
+ ["Cancel", cancelId, "danger"],
365
+ ]);
16
366
  }
17
367
  exports.createConfirm = createConfirm;
18
368
 
19
369
  /**
20
- * Create a ticket category select menu container.
370
+ * Legacy helper: creates a ticket creation prompt with a select menu.
21
371
  */
22
- function createTicketMenu(customId) {
23
- return ComponentsV2Builder_js_1.ComponentsV2Builder.createTicketMenu(customId);
372
+ function createTicketMenu(customId, title = "Support Tickets", description = "Select the category that best matches your issue.") {
373
+ const Builder = getBuilder();
374
+ const builder = new Builder().addText(`# ${title}`).addText(description).addSeparator("small");
375
+ const select = builder.addSelectMenu(customId, "Select a ticket category");
376
+ return { builder, select };
24
377
  }
25
378
  exports.createTicketMenu = createTicketMenu;
26
379
 
27
380
  /**
28
- * Create a plan selector container.
381
+ * Legacy helper: creates a subscription plan selector menu.
29
382
  */
30
- function createPlanSelector(customId) {
31
- return ComponentsV2Builder_js_1.ComponentsV2Builder.createPlanSelector(customId);
383
+ function createPlanSelector(customId, title = "Select Your Plan", description = "Choose a subscription tier below.") {
384
+ const Builder = getBuilder();
385
+ const builder = new Builder().addText(`# ${title}`).addText(description).addSeparator("small");
386
+ const select = builder.addSelectMenu(customId, "Choose a plan");
387
+ return { builder, select };
32
388
  }
33
389
  exports.createPlanSelector = createPlanSelector;
34
390
 
35
391
  /**
36
- * Create a role selector menu container.
392
+ * Legacy helper: creates a role selection menu.
37
393
  */
38
- function createRoleMenu(customId) {
39
- return ComponentsV2Builder_js_1.ComponentsV2Builder.createRoleMenu(customId);
394
+ function createRoleMenu(customId, title = "Self-Assignable Roles", description = "Pick roles from the dropdown below.") {
395
+ const Builder = getBuilder();
396
+ const builder = new Builder().addText(`# ${title}`).addText(description).addSeparator("small");
397
+ const select = builder.addSelectMenu(customId, "Select roles");
398
+ return { builder, select };
40
399
  }
41
400
  exports.createRoleMenu = createRoleMenu;
@@ -0,0 +1,24 @@
1
+ export type V2FieldTuple = [label: string, value: unknown];
2
+ export interface V2FieldObject {
3
+ label?: string;
4
+ name?: string;
5
+ value: unknown;
6
+ }
7
+ export type V2FieldEntry = V2FieldTuple | V2FieldObject | false | null | undefined;
8
+
9
+ export interface V2FieldsOptions {
10
+ omitEmpty?: boolean;
11
+ omitIfEmpty?: boolean;
12
+ fallback?: string;
13
+ }
14
+
15
+ export declare class V2Text {
16
+ static clip(text: unknown, maxLen?: number, fallback?: string): string;
17
+ static code(value: unknown): string;
18
+ static subtext(text: unknown, maxLen?: number | null): string;
19
+ static heading(text: unknown, level?: 1 | 2 | 3, maxLen?: number | null): string;
20
+ static fields(rows: V2FieldEntry[], options?: V2FieldsOptions): string;
21
+ static sectionBlock(heading: string, rows: V2FieldEntry[], options?: V2FieldsOptions): string;
22
+ static quote(text: unknown, maxLen?: number | null, fallback?: string): string;
23
+ static join(blocks: Array<string | false | null | undefined>, separator?: string): string;
24
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V2Text = void 0;
4
+
5
+ const helpers_js_1 = require("./helpers.js");
6
+
7
+ function normalizeFieldRow(row, options) {
8
+ if (!row) return null;
9
+
10
+ let label;
11
+ let value;
12
+
13
+ if (Array.isArray(row)) {
14
+ [label, value] = row;
15
+ } else if (typeof row === "object") {
16
+ label = row.label ?? row.name;
17
+ value = row.value;
18
+ } else {
19
+ return null;
20
+ }
21
+
22
+ if (label === undefined || label === null || String(label).trim() === "") return null;
23
+
24
+ const omitEmpty = options?.omitEmpty !== false;
25
+ if (omitEmpty && (value === undefined || value === null || value === "")) {
26
+ return null;
27
+ }
28
+
29
+ const formattedValue = value === undefined || value === null || value === "" ? options?.fallback ?? "-" : String(value);
30
+ return `> **${String(label).trim()}:** ${formattedValue}`;
31
+ }
32
+
33
+ class V2Text {
34
+ static clip(text, maxLen = helpers_js_1.SAFE_V2_TEXT_LENGTH, fallback = "") {
35
+ return helpers_js_1.clipText(text, maxLen, fallback);
36
+ }
37
+
38
+ static code(value) {
39
+ return `\`${String(value ?? "")}\``;
40
+ }
41
+
42
+ static subtext(text, maxLen = null) {
43
+ const str = String(text ?? "").trim();
44
+ if (!str) return "";
45
+ const clipped = maxLen ? helpers_js_1.clipText(str, maxLen) : str;
46
+ return `-# ${clipped}`;
47
+ }
48
+
49
+ static heading(text, level = 3, maxLen = null) {
50
+ const str = String(text ?? "").trim();
51
+ if (!str) return "";
52
+ const hashes = "#".repeat(Math.min(3, Math.max(1, Number(level) || 3)));
53
+ const clipped = maxLen ? helpers_js_1.clipText(str, maxLen) : str;
54
+ return `${hashes} ${clipped}`;
55
+ }
56
+
57
+ static fields(rows, options = {}) {
58
+ if (!Array.isArray(rows)) return "";
59
+ const lines = rows.map((row) => normalizeFieldRow(row, options)).filter(Boolean);
60
+ return lines.join("\n");
61
+ }
62
+
63
+ static sectionBlock(heading, rows, options = {}) {
64
+ const body = V2Text.fields(rows, options);
65
+ if (!body && options?.omitIfEmpty !== false) return "";
66
+ const title = String(heading ?? "").trim();
67
+ if (!title) return body;
68
+ return body ? `**${title}**\n${body}` : `**${title}**`;
69
+ }
70
+
71
+ static quote(text, maxLen = null, fallback = "-") {
72
+ const raw = String(text ?? "").trimEnd();
73
+ if (!raw) return fallback ? `> ${fallback}` : "";
74
+
75
+ const quoted = raw
76
+ .split(/\r?\n/)
77
+ .map((line) => (line ? `> ${line}` : ">"))
78
+ .join("\n");
79
+
80
+ return maxLen ? helpers_js_1.clipText(quoted, maxLen, fallback ? `> ${fallback}` : "") : quoted;
81
+ }
82
+
83
+ static join(blocks, separator = "\n") {
84
+ return (Array.isArray(blocks) ? blocks : [blocks])
85
+ .map((item) => (typeof item === "string" ? item.trimEnd() : ""))
86
+ .filter(Boolean)
87
+ .join(separator);
88
+ }
89
+ }
90
+
91
+ exports.V2Text = V2Text;
@@ -1,58 +1,53 @@
1
- import { User, Message, CollectedInteraction } from "discord.js";
1
+ import { CollectedInteraction, InteractionCollector, Message, User } from "discord.js";
2
+ import type { ButtonStyleResolvable } from "../builders/ComponentsV2Builder.js";
3
+ import type { EmojiInput } from "../builders/components/helpers.js";
2
4
  import { AsyncFunction } from "../Loader.js";
3
- import { Erine } from "../Client.js";
5
+ import { Gralonium } from "../Client.js";
6
+
4
7
  export type ConfirmatorOptions = {
5
- author: User;
6
- filter?: ConfirmatorProcess;
7
- timeout?: number;
8
+ author: User;
9
+ filter?: ConfirmatorProcess;
10
+ timeout?: number;
11
+ continueId?: string;
12
+ cancelId?: string;
13
+ disableOnEnd?: boolean;
8
14
  };
15
+
9
16
  export type ConfirmatorProcess = AsyncFunction<CollectedInteraction, any>;
17
+
18
+ export type ConfirmatorButtonSchema = {
19
+ label?: string;
20
+ style?: ButtonStyleResolvable;
21
+ emoji?: EmojiInput;
22
+ customId?: string;
23
+ };
24
+
10
25
  export type ConfirmatorButtonsOptions = {
11
- continue?: {
12
- label?: string;
13
- };
14
- cancel?: {
15
- label?: string;
16
- };
26
+ continue?: ConfirmatorButtonSchema;
27
+ cancel?: ConfirmatorButtonSchema;
17
28
  };
29
+
18
30
  export declare class Confirmator {
19
- private _author;
20
- private _continue;
21
- private _cancel;
22
- private _filter;
23
- filter: ConfirmatorProcess;
24
- timeout: number;
25
- message?: Message;
26
- bot: Erine;
27
- constructor(bot: Erine, options: ConfirmatorOptions);
28
- /**
29
- *
30
- * @param predicate The function to call when someone clicks the continue button
31
- */
32
- setContinueProcess(predicate: ConfirmatorProcess): this;
33
- /**
34
- * @param predicate The function to call when someone clicks the cancel button.
35
- */
36
- setCancelProcess(predicate: ConfirmatorProcess): this;
37
- /**
38
- * @param predicate The function to call when the filter process returns false
39
- */
40
- setFilterErrorProcess(predicate: ConfirmatorProcess): this;
41
- /**
42
- * @param predicate The function to call and check if is true, if not it will throw an error (setted with .setFilterErrorProcess())
43
- */
44
- setFilterCheckProcess(predicate: ConfirmatorProcess): this;
45
- /**
46
- * You have to use this after you send the message with the buttons, this is required.
47
- * @param message The message that will be used in the process
48
- */
49
- setMessage(message: Message): this;
50
- /**
51
- * @param options Optional options to customize your buttons
52
- */
53
- static Buttons(options?: ConfirmatorButtonsOptions): import("discord.js").APIActionRowComponent<import("discord.js").APIStringSelectComponent | import("discord.js").APIChannelSelectComponent | import("discord.js").APIMentionableSelectComponent | import("discord.js").APIUserSelectComponent | import("discord.js").APIRoleSelectComponent | import("discord.js").APIButtonComponent | import("discord.js").APITextInputComponent>;
54
- /**
55
- * Start the confirmator, we recommend you to start it after using Confirmator.setMessage()
56
- */
57
- start(): void;
31
+ filter: ConfirmatorProcess;
32
+ timeout: number;
33
+ message?: Message;
34
+ bot: Gralonium;
35
+ constructor(bot: Gralonium, options: ConfirmatorOptions);
36
+ setContinueProcess(predicate: ConfirmatorProcess): this;
37
+ setCancelProcess(predicate: ConfirmatorProcess): this;
38
+ setFilterErrorProcess(predicate: ConfirmatorProcess): this;
39
+ setFilterCheckProcess(predicate: ConfirmatorProcess): this;
40
+ setMessage(message: Message): this;
41
+ static Buttons(
42
+ options?: ConfirmatorButtonsOptions
43
+ ): import("discord.js").APIActionRowComponent<
44
+ | import("discord.js").APIStringSelectComponent
45
+ | import("discord.js").APIChannelSelectComponent
46
+ | import("discord.js").APIMentionableSelectComponent
47
+ | import("discord.js").APIUserSelectComponent
48
+ | import("discord.js").APIRoleSelectComponent
49
+ | import("discord.js").APIButtonComponent
50
+ | import("discord.js").APITextInputComponent
51
+ >;
52
+ start(): InteractionCollector<any>;
58
53
  }