@spatulox/simplediscordbot 1.5.0 → 1.5.2
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 +138 -26
- package/dist/index.d.ts +138 -26
- package/dist/index.js +304 -58
- package/dist/index.mjs +321 -59
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -420,6 +420,7 @@ import {
|
|
|
420
420
|
MessageFlags
|
|
421
421
|
} from "discord.js";
|
|
422
422
|
var EmbedColor = /* @__PURE__ */ ((EmbedColor3) => {
|
|
423
|
+
EmbedColor3["transparent"] = "transparent";
|
|
423
424
|
EmbedColor3[EmbedColor3["error"] = 8912917] = "error";
|
|
424
425
|
EmbedColor3[EmbedColor3["success"] = 65280] = "success";
|
|
425
426
|
EmbedColor3[EmbedColor3["black"] = 0] = "black";
|
|
@@ -460,7 +461,6 @@ var EmbedColor = /* @__PURE__ */ ((EmbedColor3) => {
|
|
|
460
461
|
})(EmbedColor || {});
|
|
461
462
|
var EmbedManager = class {
|
|
462
463
|
static get BOT_ICON() {
|
|
463
|
-
if (Bot.config.botIconUrl) return Bot.config.botIconUrl;
|
|
464
464
|
return Bot.client?.user?.displayAvatarURL({ forceStatic: false, size: 128 }) || "";
|
|
465
465
|
}
|
|
466
466
|
static get DEFAULT_COLOR() {
|
|
@@ -470,7 +470,11 @@ var EmbedManager = class {
|
|
|
470
470
|
* Creates base embed - SAME SIMPLE API !
|
|
471
471
|
*/
|
|
472
472
|
static create(color = null) {
|
|
473
|
-
const embed = new EmbedBuilder2().
|
|
473
|
+
const embed = new EmbedBuilder2().setTimestamp(/* @__PURE__ */ new Date());
|
|
474
|
+
const colorC = color ?? this.DEFAULT_COLOR;
|
|
475
|
+
if (colorC !== "transparent" /* transparent */) {
|
|
476
|
+
embed.setColor(colorC);
|
|
477
|
+
}
|
|
474
478
|
if (Bot.config.botName) {
|
|
475
479
|
const footer = {
|
|
476
480
|
text: Bot.config.botName
|
|
@@ -501,7 +505,7 @@ var EmbedManager = class {
|
|
|
501
505
|
return this.create(25600 /* minecraft */).setTitle("Success").setDescription(description);
|
|
502
506
|
}
|
|
503
507
|
/**
|
|
504
|
-
* Creates a
|
|
508
|
+
* Creates a simple description embed
|
|
505
509
|
*/
|
|
506
510
|
static description(description) {
|
|
507
511
|
return this.create().setDescription(description).setFooter(null).setTimestamp(null);
|
|
@@ -530,24 +534,6 @@ var EmbedManager = class {
|
|
|
530
534
|
});
|
|
531
535
|
return embed;
|
|
532
536
|
}
|
|
533
|
-
/**
|
|
534
|
-
* Fluent API shortcuts
|
|
535
|
-
*/
|
|
536
|
-
static title(embed, title) {
|
|
537
|
-
return embed.setTitle(title);
|
|
538
|
-
}
|
|
539
|
-
static desc(embed, description) {
|
|
540
|
-
return embed.setDescription(description);
|
|
541
|
-
}
|
|
542
|
-
static thumb(embed, url) {
|
|
543
|
-
return embed.setThumbnail(url);
|
|
544
|
-
}
|
|
545
|
-
static image(embed, url) {
|
|
546
|
-
return embed.setImage(url);
|
|
547
|
-
}
|
|
548
|
-
static footer(embed, text) {
|
|
549
|
-
return embed.setFooter({ text, iconURL: this.BOT_ICON });
|
|
550
|
-
}
|
|
551
537
|
/**
|
|
552
538
|
* Transform embed into objet for interaction.reply()
|
|
553
539
|
*/
|
|
@@ -2297,7 +2283,7 @@ var ModalManager = class {
|
|
|
2297
2283
|
builder.setStyle(TextInputStyle.Short).setMaxLength(10);
|
|
2298
2284
|
break;
|
|
2299
2285
|
case 3 /* DATE */:
|
|
2300
|
-
builder.setStyle(TextInputStyle.Short).setMaxLength(10);
|
|
2286
|
+
builder.setStyle(TextInputStyle.Short).setMaxLength(10).setPlaceholder("YYYY-MM-DD / DD-MM-YYYY or YYYY/MM/DD / DD/MM/YYYY");
|
|
2301
2287
|
break;
|
|
2302
2288
|
case 4 /* PHONE */:
|
|
2303
2289
|
builder.setStyle(TextInputStyle.Short).setMaxLength(20);
|
|
@@ -2306,14 +2292,14 @@ var ModalManager = class {
|
|
|
2306
2292
|
return new LabelBuilder().setLabel(opt.label).setTextInputComponent(builder);
|
|
2307
2293
|
}
|
|
2308
2294
|
/**
|
|
2309
|
-
|
|
2310
|
-
|
|
2295
|
+
* Simple modal with ONE field - DIRECT ModalBuilder return !
|
|
2296
|
+
*/
|
|
2311
2297
|
static simple(customId, modalTitle, field) {
|
|
2312
2298
|
const modal = this.create(modalTitle ?? Bot.config?.botName ?? "Bot", customId);
|
|
2313
2299
|
const opt = {
|
|
2314
2300
|
...field,
|
|
2315
2301
|
customId: `${customId}_input`,
|
|
2316
|
-
placeholder: field.placeholder
|
|
2302
|
+
placeholder: "placeholder" in field && field.placeholder ? field.placeholder : `Enter ${field.label.toLowerCase()}`
|
|
2317
2303
|
};
|
|
2318
2304
|
modal.addLabelComponents(this._createField(opt));
|
|
2319
2305
|
return modal;
|
|
@@ -2345,7 +2331,7 @@ var ModalManager = class {
|
|
|
2345
2331
|
* Date modal preset
|
|
2346
2332
|
*/
|
|
2347
2333
|
static date(customId, modalTitle = "Select Date", inputLabel = "Date") {
|
|
2348
|
-
return this.simple(`${customId}_date`, modalTitle, { label: inputLabel, type: 3 /* DATE
|
|
2334
|
+
return this.simple(`${customId}_date`, modalTitle, { label: inputLabel, type: 3 /* DATE */ });
|
|
2349
2335
|
}
|
|
2350
2336
|
/**
|
|
2351
2337
|
* Number modal preset
|
|
@@ -2379,35 +2365,34 @@ var ModalManager = class {
|
|
|
2379
2365
|
const num = parseInt(value);
|
|
2380
2366
|
return isNaN(num) ? null : num;
|
|
2381
2367
|
}
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
}
|
|
2388
|
-
return clean.startsWith("0033") ? "+33" + clean.slice(4) : clean;
|
|
2389
|
-
}
|
|
2390
|
-
return null;
|
|
2391
|
-
}
|
|
2368
|
+
/**
|
|
2369
|
+
* yyyy-mm-dd / dd-mm-yyyy / dd/mm/yyyy / yyyy/mm/dd
|
|
2370
|
+
* American format is not supported lol
|
|
2371
|
+
* @param value
|
|
2372
|
+
*/
|
|
2392
2373
|
static parseDate(value) {
|
|
2393
|
-
if (/^\d{4}
|
|
2374
|
+
if (/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/.test(value)) {
|
|
2394
2375
|
const [year, month, day] = value.split("-").map(Number);
|
|
2395
2376
|
const date = new Date(year, month - 1, day);
|
|
2396
2377
|
return isNaN(date.getTime()) ? null : date;
|
|
2397
2378
|
}
|
|
2398
|
-
if (
|
|
2379
|
+
if (/^(0[1-9]|[12]\d|3[01])-(0[1-9]|1[0-2])-\d{4}$/.test(value)) {
|
|
2380
|
+
const [day, month, year] = value.split("-").map(Number);
|
|
2381
|
+
const date = new Date(year, month - 1, day);
|
|
2382
|
+
return isNaN(date.getTime()) ? null : date;
|
|
2383
|
+
}
|
|
2384
|
+
if (/^(0[1-9]|[12]\d|3[01])\/(0[1-9]|1[0-2])\/\d{4}$/.test(value)) {
|
|
2399
2385
|
const [day, month, year] = value.split("/").map(Number);
|
|
2400
2386
|
const date = new Date(year, month - 1, day);
|
|
2401
2387
|
return isNaN(date.getTime()) ? null : date;
|
|
2402
2388
|
}
|
|
2389
|
+
if (/^\d{4}\/(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])$/.test(value)) {
|
|
2390
|
+
const [year, month, day] = value.split("/").map(Number);
|
|
2391
|
+
const date = new Date(year, month - 1, day);
|
|
2392
|
+
return isNaN(date.getTime()) ? null : date;
|
|
2393
|
+
}
|
|
2403
2394
|
return null;
|
|
2404
2395
|
}
|
|
2405
|
-
/**
|
|
2406
|
-
* Transform modal to interaction.showModal() format
|
|
2407
|
-
*/
|
|
2408
|
-
static toInteraction(modal) {
|
|
2409
|
-
return modal;
|
|
2410
|
-
}
|
|
2411
2396
|
};
|
|
2412
2397
|
|
|
2413
2398
|
// src/manager/interactions/SelectMenuManager.ts
|
|
@@ -2418,9 +2403,10 @@ import {
|
|
|
2418
2403
|
UserSelectMenuBuilder,
|
|
2419
2404
|
RoleSelectMenuBuilder,
|
|
2420
2405
|
MentionableSelectMenuBuilder,
|
|
2421
|
-
ChannelSelectMenuBuilder
|
|
2406
|
+
ChannelSelectMenuBuilder,
|
|
2407
|
+
MessageFlags as MessageFlags3
|
|
2422
2408
|
} from "discord.js";
|
|
2423
|
-
var SelectMenuManager = class {
|
|
2409
|
+
var SelectMenuManager = class _SelectMenuManager {
|
|
2424
2410
|
/**
|
|
2425
2411
|
* Creates base StringSelectMenu - SIMPLE API !
|
|
2426
2412
|
*/
|
|
@@ -2443,15 +2429,13 @@ var SelectMenuManager = class {
|
|
|
2443
2429
|
* Pagination menu
|
|
2444
2430
|
*/
|
|
2445
2431
|
static paginated(customId, options, pageSize = 25) {
|
|
2446
|
-
const
|
|
2432
|
+
const rows = [];
|
|
2447
2433
|
for (let i = 0; i < options.length; i += pageSize) {
|
|
2448
2434
|
const pageOptions = options.slice(i, i + pageSize);
|
|
2449
|
-
const menu = new StringSelectMenuBuilder().setCustomId(`${customId}_page_${Math.floor(i / pageSize)}`).setPlaceholder(`Page ${Math.floor(i / pageSize) + 1}`).addOptions(pageOptions.map((opt) =>
|
|
2450
|
-
|
|
2451
|
-
}));
|
|
2452
|
-
row.addComponents(menu);
|
|
2435
|
+
const menu = new StringSelectMenuBuilder().setCustomId(`${customId}_page_${Math.floor(i / pageSize)}`).setPlaceholder(`Page ${Math.floor(i / pageSize) + 1}`).addOptions(pageOptions.map((opt) => this.option(opt)));
|
|
2436
|
+
rows.push(_SelectMenuManager.row(menu));
|
|
2453
2437
|
}
|
|
2454
|
-
return
|
|
2438
|
+
return rows.slice(0, 5);
|
|
2455
2439
|
}
|
|
2456
2440
|
/**
|
|
2457
2441
|
* User Select Menu (Components V2)
|
|
@@ -2515,6 +2499,283 @@ var SelectMenuManager = class {
|
|
|
2515
2499
|
(component) => this.row(component)
|
|
2516
2500
|
);
|
|
2517
2501
|
}
|
|
2502
|
+
static toMessage(menus) {
|
|
2503
|
+
return {
|
|
2504
|
+
components: this._createRowsToReturn(menus)
|
|
2505
|
+
};
|
|
2506
|
+
}
|
|
2507
|
+
static toInteraction(menus, ephemeral = false) {
|
|
2508
|
+
return {
|
|
2509
|
+
components: this._createRowsToReturn(menus),
|
|
2510
|
+
flags: ephemeral ? [MessageFlags3.Ephemeral] : []
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2513
|
+
static _createRowsToReturn(menus) {
|
|
2514
|
+
if (Array.isArray(menus)) {
|
|
2515
|
+
return menus.map(
|
|
2516
|
+
(menu) => menu instanceof ActionRowBuilder3 ? menu : _SelectMenuManager.row(menu)
|
|
2517
|
+
);
|
|
2518
|
+
}
|
|
2519
|
+
return menus instanceof ActionRowBuilder3 ? [menus] : [_SelectMenuManager.row(menus)];
|
|
2520
|
+
}
|
|
2521
|
+
};
|
|
2522
|
+
|
|
2523
|
+
// src/manager/messages/ComponentManager.ts
|
|
2524
|
+
import {
|
|
2525
|
+
ContainerBuilder,
|
|
2526
|
+
TextDisplayBuilder,
|
|
2527
|
+
SeparatorBuilder,
|
|
2528
|
+
SeparatorSpacingSize,
|
|
2529
|
+
MessageFlags as MessageFlags4,
|
|
2530
|
+
ThumbnailBuilder,
|
|
2531
|
+
SectionBuilder,
|
|
2532
|
+
MediaGalleryBuilder,
|
|
2533
|
+
MediaGalleryItemBuilder,
|
|
2534
|
+
AttachmentBuilder,
|
|
2535
|
+
FileBuilder
|
|
2536
|
+
} from "discord.js";
|
|
2537
|
+
var ComponentManager = class {
|
|
2538
|
+
static get DEFAULT_COLOR() {
|
|
2539
|
+
return Bot.config?.defaultEmbedColor || 6064856 /* default */;
|
|
2540
|
+
}
|
|
2541
|
+
/**
|
|
2542
|
+
* Creates base ComponentV2
|
|
2543
|
+
*/
|
|
2544
|
+
static create(option) {
|
|
2545
|
+
const container = new ContainerBuilder();
|
|
2546
|
+
const colorC = option?.color ?? this.DEFAULT_COLOR;
|
|
2547
|
+
if (colorC !== "transparent" /* transparent */) {
|
|
2548
|
+
container.setAccentColor(colorC);
|
|
2549
|
+
}
|
|
2550
|
+
if (option?.title || option?.thumbnailUrl) {
|
|
2551
|
+
if (option?.thumbnailUrl) {
|
|
2552
|
+
const headerSection = new SectionBuilder().addTextDisplayComponents(
|
|
2553
|
+
new TextDisplayBuilder().setContent(
|
|
2554
|
+
option?.title ? "## " + option.title : "\u200B"
|
|
2555
|
+
)
|
|
2556
|
+
).setThumbnailAccessory(
|
|
2557
|
+
new ThumbnailBuilder().setURL(option.thumbnailUrl)
|
|
2558
|
+
);
|
|
2559
|
+
container.addSectionComponents(headerSection);
|
|
2560
|
+
} else {
|
|
2561
|
+
container.addTextDisplayComponents(
|
|
2562
|
+
new TextDisplayBuilder().setContent("## " + option.title)
|
|
2563
|
+
);
|
|
2564
|
+
}
|
|
2565
|
+
container.addSeparatorComponents(this.separator());
|
|
2566
|
+
}
|
|
2567
|
+
return container;
|
|
2568
|
+
}
|
|
2569
|
+
/**
|
|
2570
|
+
* Creates simple ComponentV2 with just description
|
|
2571
|
+
*/
|
|
2572
|
+
static simple(description, color = null) {
|
|
2573
|
+
return this.create({ color }).addTextDisplayComponents(new TextDisplayBuilder().setContent(description)).addSeparatorComponents(this.separator());
|
|
2574
|
+
}
|
|
2575
|
+
/**
|
|
2576
|
+
* Creates success ComponentV2
|
|
2577
|
+
*/
|
|
2578
|
+
static success(description) {
|
|
2579
|
+
return this.create({ title: "Success", color: 65280 /* success */ }).addTextDisplayComponents(new TextDisplayBuilder().setContent(description)).addSeparatorComponents(this.separator());
|
|
2580
|
+
}
|
|
2581
|
+
/**
|
|
2582
|
+
* Creates debug ComponentV2
|
|
2583
|
+
*/
|
|
2584
|
+
static debug(description) {
|
|
2585
|
+
return this.create({ title: "Debug", color: 25600 /* minecraft */ }).addTextDisplayComponents(
|
|
2586
|
+
new TextDisplayBuilder().setContent(description)
|
|
2587
|
+
).addSeparatorComponents(this.separator());
|
|
2588
|
+
}
|
|
2589
|
+
/**
|
|
2590
|
+
* Creates error ComponentV2
|
|
2591
|
+
*/
|
|
2592
|
+
static error(description) {
|
|
2593
|
+
return this.create({ title: "Something went wrong", color: 8912917 /* error */ }).addTextDisplayComponents(
|
|
2594
|
+
new TextDisplayBuilder().setContent(description)
|
|
2595
|
+
).addSeparatorComponents(this.separator());
|
|
2596
|
+
}
|
|
2597
|
+
static separator(spacing = SeparatorSpacingSize.Small) {
|
|
2598
|
+
return new SeparatorBuilder().setDivider(true).setSpacing(spacing);
|
|
2599
|
+
}
|
|
2600
|
+
/**
|
|
2601
|
+
* Quick field adder
|
|
2602
|
+
*/
|
|
2603
|
+
static field(container, field) {
|
|
2604
|
+
if ("button" in field || "thumbnailUrl" in field) {
|
|
2605
|
+
const section = new SectionBuilder().addTextDisplayComponents(
|
|
2606
|
+
new TextDisplayBuilder().setContent(`**${field.name}**`),
|
|
2607
|
+
new TextDisplayBuilder().setContent(field.value)
|
|
2608
|
+
);
|
|
2609
|
+
if ("button" in field) {
|
|
2610
|
+
section.setButtonAccessory(field.button);
|
|
2611
|
+
} else if ("thumbnailUrl" in field) {
|
|
2612
|
+
section.setThumbnailAccessory(new ThumbnailBuilder().setURL(field.thumbnailUrl));
|
|
2613
|
+
}
|
|
2614
|
+
container.addSectionComponents(section);
|
|
2615
|
+
} else {
|
|
2616
|
+
container.addTextDisplayComponents(
|
|
2617
|
+
new TextDisplayBuilder().setContent(`**${field.name}**`),
|
|
2618
|
+
new TextDisplayBuilder().setContent(field.value)
|
|
2619
|
+
);
|
|
2620
|
+
}
|
|
2621
|
+
container.addSeparatorComponents(this.separator());
|
|
2622
|
+
return container;
|
|
2623
|
+
}
|
|
2624
|
+
/*static field(container: ContainerBuilder, field: ComponentManagerField): ContainerBuilder {
|
|
2625
|
+
const section = new SectionBuilder()
|
|
2626
|
+
.addTextDisplayComponents(
|
|
2627
|
+
new TextDisplayBuilder().setContent(`**${field.name}**`),
|
|
2628
|
+
new TextDisplayBuilder().setContent(field.value)
|
|
2629
|
+
);
|
|
2630
|
+
|
|
2631
|
+
if (field.thumbnailUrl) {
|
|
2632
|
+
section.setThumbnailAccessory(
|
|
2633
|
+
new ThumbnailBuilder().setURL(field.thumbnailUrl)
|
|
2634
|
+
);
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
if (field.button && field.button.length > 0) {
|
|
2638
|
+
section.setButtonAccessory(field.button[0]!);
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
container.addSectionComponents(section);
|
|
2642
|
+
container.addSeparatorComponents(this.separator());
|
|
2643
|
+
return container;
|
|
2644
|
+
}*/
|
|
2645
|
+
/**
|
|
2646
|
+
* Multiple fields
|
|
2647
|
+
*/
|
|
2648
|
+
static fields(container, fields) {
|
|
2649
|
+
fields.forEach((f) => {
|
|
2650
|
+
this.field(container, f);
|
|
2651
|
+
});
|
|
2652
|
+
return container;
|
|
2653
|
+
}
|
|
2654
|
+
/**
|
|
2655
|
+
* Add a media gallery (links)
|
|
2656
|
+
*/
|
|
2657
|
+
static mediaGallery(container, medias) {
|
|
2658
|
+
const gallery = new MediaGalleryBuilder();
|
|
2659
|
+
medias.forEach((med) => {
|
|
2660
|
+
gallery.addItems(new MediaGalleryItemBuilder().setURL(med.url).setSpoiler(med.spoiler ?? false));
|
|
2661
|
+
});
|
|
2662
|
+
container.addMediaGalleryComponents(gallery);
|
|
2663
|
+
return container;
|
|
2664
|
+
}
|
|
2665
|
+
static selectMenu(container, selectMenu) {
|
|
2666
|
+
const menus = Array.isArray(selectMenu) ? selectMenu : [selectMenu];
|
|
2667
|
+
menus.forEach((menu) => {
|
|
2668
|
+
const row = SelectMenuManager.row(menu);
|
|
2669
|
+
container.addActionRowComponents(row);
|
|
2670
|
+
});
|
|
2671
|
+
return container;
|
|
2672
|
+
}
|
|
2673
|
+
static file(container, file) {
|
|
2674
|
+
const files = [];
|
|
2675
|
+
const fileArray = Array.isArray(file) ? file : [file];
|
|
2676
|
+
fileArray.forEach((f) => {
|
|
2677
|
+
const attachment = new AttachmentBuilder(f.buffer, {
|
|
2678
|
+
name: f.name
|
|
2679
|
+
});
|
|
2680
|
+
files.push(attachment);
|
|
2681
|
+
container.addFileComponents(
|
|
2682
|
+
new FileBuilder().setURL(`attachment://${f.name}`).setSpoiler(f.spoiler ?? false)
|
|
2683
|
+
);
|
|
2684
|
+
container.addSeparatorComponents(this.separator());
|
|
2685
|
+
});
|
|
2686
|
+
return { container, files };
|
|
2687
|
+
}
|
|
2688
|
+
static footer(container) {
|
|
2689
|
+
container.addTextDisplayComponents(
|
|
2690
|
+
new TextDisplayBuilder().setContent(`-# **${Bot.config?.botName || "Bot"} \xB7 <t:${Math.floor(Date.now() / 1e3)}:d> <t:${Math.floor(Date.now() / 1e3)}:t>**`)
|
|
2691
|
+
);
|
|
2692
|
+
return container;
|
|
2693
|
+
}
|
|
2694
|
+
/**
|
|
2695
|
+
* Transform ComponentV2 into object for channel.send()
|
|
2696
|
+
* @param container The container to send
|
|
2697
|
+
* @param file Only if you have files to attach
|
|
2698
|
+
* @param footer Sometimes you don't want to have the Bot name neither the timestamp...
|
|
2699
|
+
*/
|
|
2700
|
+
static toMessage(container, file = null, footer = true) {
|
|
2701
|
+
if (footer) {
|
|
2702
|
+
this.footer(container);
|
|
2703
|
+
}
|
|
2704
|
+
if (file) {
|
|
2705
|
+
return {
|
|
2706
|
+
components: [container],
|
|
2707
|
+
files: Array.isArray(file) ? file : [file],
|
|
2708
|
+
flags: [MessageFlags4.IsComponentsV2]
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
return {
|
|
2712
|
+
components: [container],
|
|
2713
|
+
flags: [MessageFlags4.IsComponentsV2]
|
|
2714
|
+
};
|
|
2715
|
+
}
|
|
2716
|
+
};
|
|
2717
|
+
|
|
2718
|
+
// src/manager/interactions/ButtonManager.ts
|
|
2719
|
+
import {
|
|
2720
|
+
ButtonBuilder as ButtonBuilder2,
|
|
2721
|
+
ButtonStyle,
|
|
2722
|
+
ActionRowBuilder as ActionRowBuilder4,
|
|
2723
|
+
MessageFlags as MessageFlags5
|
|
2724
|
+
} from "discord.js";
|
|
2725
|
+
var ButtonManager = class _ButtonManager {
|
|
2726
|
+
static _create(options) {
|
|
2727
|
+
const btn = new ButtonBuilder2().setCustomId(options.customId).setLabel(options.label ?? "Button").setStyle(options.style).setDisabled(options.disabled ?? false);
|
|
2728
|
+
if (options.emoji) {
|
|
2729
|
+
btn.setEmoji(options.emoji);
|
|
2730
|
+
}
|
|
2731
|
+
return btn;
|
|
2732
|
+
}
|
|
2733
|
+
static primary(options) {
|
|
2734
|
+
return this._create({ ...options, style: ButtonStyle.Primary });
|
|
2735
|
+
}
|
|
2736
|
+
static success(options) {
|
|
2737
|
+
return this._create({ ...options, style: ButtonStyle.Success });
|
|
2738
|
+
}
|
|
2739
|
+
static secondary(options) {
|
|
2740
|
+
return this._create({ ...options, style: ButtonStyle.Secondary });
|
|
2741
|
+
}
|
|
2742
|
+
static danger(options) {
|
|
2743
|
+
return this._create({ ...options, style: ButtonStyle.Danger });
|
|
2744
|
+
}
|
|
2745
|
+
static link(options) {
|
|
2746
|
+
const btn = new ButtonBuilder2().setLabel(options.label).setStyle(ButtonStyle.Link).setURL(options.url);
|
|
2747
|
+
if (options.emoji) btn.setEmoji(options.emoji);
|
|
2748
|
+
return btn;
|
|
2749
|
+
}
|
|
2750
|
+
static confirm(customId) {
|
|
2751
|
+
return this.success({ customId, label: "Confirm" });
|
|
2752
|
+
}
|
|
2753
|
+
static cancel(customId) {
|
|
2754
|
+
return this.danger({ customId, label: "Cancel" });
|
|
2755
|
+
}
|
|
2756
|
+
static row(but) {
|
|
2757
|
+
const buttons = Array.isArray(but) ? but.slice(0, 5) : [but];
|
|
2758
|
+
return new ActionRowBuilder4().addComponents(buttons);
|
|
2759
|
+
}
|
|
2760
|
+
static toMessage(button) {
|
|
2761
|
+
return {
|
|
2762
|
+
components: this._createRowsToReturn(button)
|
|
2763
|
+
};
|
|
2764
|
+
}
|
|
2765
|
+
static toInteraction(button, ephemeral = false) {
|
|
2766
|
+
return {
|
|
2767
|
+
components: this._createRowsToReturn(button),
|
|
2768
|
+
flags: ephemeral ? [MessageFlags5.Ephemeral] : []
|
|
2769
|
+
};
|
|
2770
|
+
}
|
|
2771
|
+
static _createRowsToReturn(button) {
|
|
2772
|
+
if (Array.isArray(button)) {
|
|
2773
|
+
return button.map(
|
|
2774
|
+
(btn) => btn instanceof ActionRowBuilder4 ? btn : _ButtonManager.row(btn)
|
|
2775
|
+
);
|
|
2776
|
+
}
|
|
2777
|
+
return button instanceof ActionRowBuilder4 ? [button] : [_ButtonManager.row(button)];
|
|
2778
|
+
}
|
|
2518
2779
|
};
|
|
2519
2780
|
|
|
2520
2781
|
// src/utils/SimpleMutex.ts
|
|
@@ -2558,7 +2819,7 @@ var SimpleMutex = class {
|
|
|
2558
2819
|
// package.json
|
|
2559
2820
|
var package_default = {
|
|
2560
2821
|
name: "@spatulox/simplediscordbot",
|
|
2561
|
-
version: "1.
|
|
2822
|
+
version: "1.5.1",
|
|
2562
2823
|
author: "Spatulox",
|
|
2563
2824
|
description: "Simple discord bot framework to set up a bot under 30 secondes",
|
|
2564
2825
|
exports: {
|
|
@@ -2568,26 +2829,25 @@ var package_default = {
|
|
|
2568
2829
|
},
|
|
2569
2830
|
types: "./dist/index.d.ts",
|
|
2570
2831
|
scripts: {
|
|
2571
|
-
|
|
2832
|
+
"type-check": "tsc --noEmit",
|
|
2833
|
+
build: "npm run type-check && rm -rf ./dist/ && tsup",
|
|
2834
|
+
dev: "npm run type-check && tsx watch src/test/index.ts",
|
|
2572
2835
|
patch: "npm run build && npm version patch",
|
|
2573
2836
|
minor: "npm run build && npm version minor",
|
|
2574
2837
|
major: "npm run build && npm version major",
|
|
2575
2838
|
"pub:patch": "npm run patch && npm publish --access public",
|
|
2576
2839
|
"pub:minor": "npm run minor && npm publish --access public",
|
|
2577
|
-
"pub:major": "npm run major && npm publish --access public"
|
|
2578
|
-
"test-pack": "npm run patch && npm publish --access public",
|
|
2579
|
-
dev: "nodemon --exec tsx src/test/index.ts"
|
|
2840
|
+
"pub:major": "npm run major && npm publish --access public"
|
|
2580
2841
|
},
|
|
2581
2842
|
license: "MIT",
|
|
2582
2843
|
dependencies: {
|
|
2583
|
-
"@spatulox/discord-interaction-manager": "^1.0.
|
|
2844
|
+
"@spatulox/discord-interaction-manager": "^1.0.22",
|
|
2584
2845
|
"discord.js": "^14.25.1"
|
|
2585
2846
|
},
|
|
2586
2847
|
devDependencies: {
|
|
2587
2848
|
"@types/node": "^22.14.0",
|
|
2588
2849
|
"@types/node-schedule": "^2.1.7",
|
|
2589
2850
|
dotenv: "^17.2.4",
|
|
2590
|
-
nodemon: "^3.1.9",
|
|
2591
2851
|
tsup: "^8.5.1",
|
|
2592
2852
|
tsx: "^4.20.3",
|
|
2593
2853
|
typescript: "^5.9.3"
|
|
@@ -2617,6 +2877,8 @@ var SimpleDiscordBotInfo = {
|
|
|
2617
2877
|
export {
|
|
2618
2878
|
Bot,
|
|
2619
2879
|
BotEnv,
|
|
2880
|
+
ButtonManager,
|
|
2881
|
+
ComponentManager,
|
|
2620
2882
|
DiscordRegex,
|
|
2621
2883
|
EmbedColor,
|
|
2622
2884
|
EmbedManager,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spatulox/simplediscordbot",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"author": "Spatulox",
|
|
5
5
|
"description": "Simple discord bot framework to set up a bot under 30 secondes",
|
|
6
6
|
"exports": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"type-check": "tsc --noEmit",
|
|
14
|
-
"build": "npm run type-check && tsup",
|
|
14
|
+
"build": "npm run type-check && rm -rf ./dist/ && tsup",
|
|
15
15
|
"dev": "npm run type-check && tsx watch src/test/index.ts",
|
|
16
16
|
"patch": "npm run build && npm version patch",
|
|
17
17
|
"minor": "npm run build && npm version minor",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@spatulox/discord-interaction-manager": "^1.0.
|
|
25
|
+
"@spatulox/discord-interaction-manager": "^1.0.22",
|
|
26
26
|
"discord.js": "^14.25.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|