@spatulox/simplediscordbot 1.6.0 → 1.6.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/README.md +3 -3
- package/dist/index.d.mts +106 -96
- package/dist/index.d.ts +106 -96
- package/dist/index.js +132 -90
- package/dist/index.mjs +141 -97
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,7 +35,6 @@ __export(index_exports, {
|
|
|
35
35
|
ButtonManager: () => ButtonManager,
|
|
36
36
|
ComponentManager: () => ComponentManager,
|
|
37
37
|
DiscordRegex: () => DiscordRegex,
|
|
38
|
-
EmbedColor: () => EmbedColor,
|
|
39
38
|
EmbedManager: () => EmbedManager,
|
|
40
39
|
FileManager: () => FileManager,
|
|
41
40
|
GuildManager: () => GuildManager,
|
|
@@ -44,6 +43,7 @@ __export(index_exports, {
|
|
|
44
43
|
ModalManager: () => ModalManager,
|
|
45
44
|
ReactionManager: () => ReactionManager,
|
|
46
45
|
SelectMenuManager: () => SelectMenuManager,
|
|
46
|
+
SimpleColor: () => SimpleColor,
|
|
47
47
|
SimpleDiscordBotInfo: () => SimpleDiscordBotInfo,
|
|
48
48
|
SimpleMutex: () => SimpleMutex,
|
|
49
49
|
Time: () => Time,
|
|
@@ -52,10 +52,10 @@ __export(index_exports, {
|
|
|
52
52
|
});
|
|
53
53
|
module.exports = __toCommonJS(index_exports);
|
|
54
54
|
|
|
55
|
-
// src/
|
|
55
|
+
// src/core/Bot.ts
|
|
56
56
|
var import_discord5 = require("discord.js");
|
|
57
57
|
|
|
58
|
-
// src/utils/
|
|
58
|
+
// src/utils/UnitTime.ts
|
|
59
59
|
var UnitTime = class {
|
|
60
60
|
constructor(val) {
|
|
61
61
|
this.val = val;
|
|
@@ -295,7 +295,7 @@ var Log = class {
|
|
|
295
295
|
}
|
|
296
296
|
};
|
|
297
297
|
|
|
298
|
-
// src/utils/
|
|
298
|
+
// src/utils/InternetChecker.ts
|
|
299
299
|
var InternetChecker = class {
|
|
300
300
|
/**
|
|
301
301
|
* Check internet connection towards 1.1.1.1 (Cloudflare DNS)
|
|
@@ -342,7 +342,7 @@ InternetChecker.TARGET = "https://1.1.1.1";
|
|
|
342
342
|
// Cloudflare DNS HTTPS
|
|
343
343
|
InternetChecker.RETRY_TIME = Time.second.SEC_30;
|
|
344
344
|
|
|
345
|
-
// src/
|
|
345
|
+
// src/core/BotLog.ts
|
|
346
346
|
var import_discord = require("discord.js");
|
|
347
347
|
var _BotLog = class _BotLog {
|
|
348
348
|
constructor() {
|
|
@@ -470,52 +470,56 @@ var BotLog = _BotLog;
|
|
|
470
470
|
|
|
471
471
|
// src/manager/messages/EmbedManager.ts
|
|
472
472
|
var import_discord2 = require("discord.js");
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
473
|
+
|
|
474
|
+
// src/constants/SimpleColor.ts
|
|
475
|
+
var SimpleColor = /* @__PURE__ */ ((SimpleColor2) => {
|
|
476
|
+
SimpleColor2["transparent"] = "transparent";
|
|
477
|
+
SimpleColor2[SimpleColor2["error"] = 8912917] = "error";
|
|
478
|
+
SimpleColor2[SimpleColor2["success"] = 65280] = "success";
|
|
479
|
+
SimpleColor2[SimpleColor2["black"] = 0] = "black";
|
|
480
|
+
SimpleColor2[SimpleColor2["white"] = 16777215] = "white";
|
|
481
|
+
SimpleColor2[SimpleColor2["red"] = 16711680] = "red";
|
|
482
|
+
SimpleColor2[SimpleColor2["green"] = 65280] = "green";
|
|
483
|
+
SimpleColor2[SimpleColor2["blue"] = 255] = "blue";
|
|
484
|
+
SimpleColor2[SimpleColor2["yellow"] = 16776960] = "yellow";
|
|
485
|
+
SimpleColor2[SimpleColor2["cyan"] = 65535] = "cyan";
|
|
486
|
+
SimpleColor2[SimpleColor2["magenta"] = 16711935] = "magenta";
|
|
487
|
+
SimpleColor2[SimpleColor2["gray"] = 8421504] = "gray";
|
|
488
|
+
SimpleColor2[SimpleColor2["lightgray"] = 13882323] = "lightgray";
|
|
489
|
+
SimpleColor2[SimpleColor2["darkgray"] = 11119017] = "darkgray";
|
|
490
|
+
SimpleColor2[SimpleColor2["orange"] = 16753920] = "orange";
|
|
491
|
+
SimpleColor2[SimpleColor2["purple"] = 8388736] = "purple";
|
|
492
|
+
SimpleColor2[SimpleColor2["pink"] = 16761035] = "pink";
|
|
493
|
+
SimpleColor2[SimpleColor2["brown"] = 10824234] = "brown";
|
|
494
|
+
SimpleColor2[SimpleColor2["lime"] = 65280] = "lime";
|
|
495
|
+
SimpleColor2[SimpleColor2["navy"] = 128] = "navy";
|
|
496
|
+
SimpleColor2[SimpleColor2["teal"] = 32896] = "teal";
|
|
497
|
+
SimpleColor2[SimpleColor2["olive"] = 8421376] = "olive";
|
|
498
|
+
SimpleColor2[SimpleColor2["gold"] = 16766720] = "gold";
|
|
499
|
+
SimpleColor2[SimpleColor2["silver"] = 12632256] = "silver";
|
|
500
|
+
SimpleColor2[SimpleColor2["coral"] = 16744272] = "coral";
|
|
501
|
+
SimpleColor2[SimpleColor2["salmon"] = 16416882] = "salmon";
|
|
502
|
+
SimpleColor2[SimpleColor2["khaki"] = 15787660] = "khaki";
|
|
503
|
+
SimpleColor2[SimpleColor2["plum"] = 14524637] = "plum";
|
|
504
|
+
SimpleColor2[SimpleColor2["lavender"] = 15132410] = "lavender";
|
|
505
|
+
SimpleColor2[SimpleColor2["beige"] = 16119260] = "beige";
|
|
506
|
+
SimpleColor2[SimpleColor2["mint"] = 10026904] = "mint";
|
|
507
|
+
SimpleColor2[SimpleColor2["peach"] = 16767673] = "peach";
|
|
508
|
+
SimpleColor2[SimpleColor2["chocolate"] = 13789470] = "chocolate";
|
|
509
|
+
SimpleColor2[SimpleColor2["crimson"] = 14423100] = "crimson";
|
|
510
|
+
SimpleColor2[SimpleColor2["youtube"] = 16718362] = "youtube";
|
|
511
|
+
SimpleColor2[SimpleColor2["default"] = 6064856] = "default";
|
|
512
|
+
SimpleColor2[SimpleColor2["minecraft"] = 25600] = "minecraft";
|
|
513
|
+
return SimpleColor2;
|
|
514
|
+
})(SimpleColor || {});
|
|
515
|
+
|
|
516
|
+
// src/manager/messages/EmbedManager.ts
|
|
513
517
|
var EmbedManager = class {
|
|
514
518
|
static get BOT_ICON() {
|
|
515
519
|
return Bot.client?.user?.displayAvatarURL({ forceStatic: false, size: 128 }) || "";
|
|
516
520
|
}
|
|
517
521
|
static get DEFAULT_COLOR() {
|
|
518
|
-
return Bot.config.
|
|
522
|
+
return Bot.config.defaultSimpleColor || 6064856 /* default */;
|
|
519
523
|
}
|
|
520
524
|
/**
|
|
521
525
|
* Creates base embed - SAME SIMPLE API !
|
|
@@ -591,7 +595,15 @@ var EmbedManager = class {
|
|
|
591
595
|
static toInteraction(embed, ephemeral = false) {
|
|
592
596
|
return {
|
|
593
597
|
embeds: [embed],
|
|
594
|
-
flags: ephemeral ? [import_discord2.MessageFlags.Ephemeral] :
|
|
598
|
+
flags: ephemeral ? [import_discord2.MessageFlags.Ephemeral] : []
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Transform embed into objet for interaction.editReply()
|
|
603
|
+
*/
|
|
604
|
+
static toInteractionEdit(embed) {
|
|
605
|
+
return {
|
|
606
|
+
embeds: [embed]
|
|
595
607
|
};
|
|
596
608
|
}
|
|
597
609
|
/**
|
|
@@ -604,14 +616,14 @@ var EmbedManager = class {
|
|
|
604
616
|
}
|
|
605
617
|
};
|
|
606
618
|
|
|
607
|
-
// src/
|
|
619
|
+
// src/core/BotMessage.ts
|
|
608
620
|
var import_discord4 = require("discord.js");
|
|
609
621
|
|
|
610
622
|
// src/manager/builder/SendableComponentBuilder.ts
|
|
611
623
|
var import_discord3 = require("discord.js");
|
|
612
624
|
var SendableComponentBuilder = class {
|
|
613
625
|
static isSendableComponent(thing) {
|
|
614
|
-
return thing instanceof import_discord3.EmbedBuilder || thing instanceof import_discord3.ActionRowBuilder;
|
|
626
|
+
return thing instanceof import_discord3.EmbedBuilder || thing instanceof import_discord3.ContainerBuilder || thing instanceof import_discord3.ActionRowBuilder;
|
|
615
627
|
}
|
|
616
628
|
static build(base, content, components) {
|
|
617
629
|
if (content) {
|
|
@@ -623,6 +635,10 @@ var SendableComponentBuilder = class {
|
|
|
623
635
|
base.embeds = base.embeds || [];
|
|
624
636
|
base.embeds.push(comp);
|
|
625
637
|
}
|
|
638
|
+
if (comp instanceof import_discord3.ContainerBuilder) {
|
|
639
|
+
base.components = base.components || [];
|
|
640
|
+
base.components.push(comp);
|
|
641
|
+
}
|
|
626
642
|
if (comp instanceof import_discord3.ActionRowBuilder) {
|
|
627
643
|
base.components = base.components || [];
|
|
628
644
|
base.components.push(comp);
|
|
@@ -653,7 +669,7 @@ var SendableComponentBuilder = class {
|
|
|
653
669
|
}
|
|
654
670
|
};
|
|
655
671
|
|
|
656
|
-
// src/
|
|
672
|
+
// src/core/BotMessage.ts
|
|
657
673
|
var BotMessage = class {
|
|
658
674
|
static async send(channel, content, component) {
|
|
659
675
|
try {
|
|
@@ -744,7 +760,7 @@ var BotMessage = class {
|
|
|
744
760
|
}
|
|
745
761
|
};
|
|
746
762
|
|
|
747
|
-
// src/
|
|
763
|
+
// src/constants/DiscordRegex.ts
|
|
748
764
|
var _DiscordRegex = class _DiscordRegex {
|
|
749
765
|
/**
|
|
750
766
|
* Validate Discord ID Discord (18)
|
|
@@ -859,7 +875,7 @@ _DiscordRegex.INVITE = /^discord(?:app\.com\/invite|gg)\/[a-zA-Z0-9]+$/;
|
|
|
859
875
|
_DiscordRegex.EMOJI = /^<a?:[a-zA-Z0-9_]{2,32}:[0-9]{18}>$|^[\u{1F300}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]+$/u;
|
|
860
876
|
var DiscordRegex = _DiscordRegex;
|
|
861
877
|
|
|
862
|
-
// src/
|
|
878
|
+
// src/core/BotEnv.ts
|
|
863
879
|
var BotEnv = {
|
|
864
880
|
get token() {
|
|
865
881
|
const token = process.env.DISCORD_BOT_TOKEN;
|
|
@@ -879,7 +895,7 @@ var BotEnv = {
|
|
|
879
895
|
}
|
|
880
896
|
};
|
|
881
897
|
|
|
882
|
-
// src/
|
|
898
|
+
// src/core/BotInteraction.ts
|
|
883
899
|
var BotInteraction = class {
|
|
884
900
|
/**
|
|
885
901
|
* InteractionReplyOptions && InteractionUpdateOptions
|
|
@@ -955,7 +971,7 @@ var BotInteraction = class {
|
|
|
955
971
|
}
|
|
956
972
|
};
|
|
957
973
|
|
|
958
|
-
// src/
|
|
974
|
+
// src/core/Bot.ts
|
|
959
975
|
var _Bot = class _Bot {
|
|
960
976
|
get config() {
|
|
961
977
|
return _Bot._config;
|
|
@@ -2546,6 +2562,11 @@ var SelectMenuManager = class _SelectMenuManager {
|
|
|
2546
2562
|
flags: ephemeral ? [import_discord16.MessageFlags.Ephemeral] : []
|
|
2547
2563
|
};
|
|
2548
2564
|
}
|
|
2565
|
+
static toInteractionEdit(menus) {
|
|
2566
|
+
return {
|
|
2567
|
+
components: this._createRowsToReturn(menus)
|
|
2568
|
+
};
|
|
2569
|
+
}
|
|
2549
2570
|
static _createRowsToReturn(menus) {
|
|
2550
2571
|
if (Array.isArray(menus)) {
|
|
2551
2572
|
return menus.map(
|
|
@@ -2560,7 +2581,7 @@ var SelectMenuManager = class _SelectMenuManager {
|
|
|
2560
2581
|
var import_discord17 = require("discord.js");
|
|
2561
2582
|
var ComponentManager = class {
|
|
2562
2583
|
static get DEFAULT_COLOR() {
|
|
2563
|
-
return Bot.config?.
|
|
2584
|
+
return Bot.config?.defaultSimpleColor || 6064856 /* default */;
|
|
2564
2585
|
}
|
|
2565
2586
|
/**
|
|
2566
2587
|
* Creates base ComponentV2
|
|
@@ -2629,57 +2650,42 @@ var ComponentManager = class {
|
|
|
2629
2650
|
/**
|
|
2630
2651
|
* Quick field adder
|
|
2631
2652
|
*/
|
|
2653
|
+
static fieldAddText(container, options) {
|
|
2654
|
+
options.name && container.addTextDisplayComponents(new import_discord17.TextDisplayBuilder().setContent(`__**${options.name}**__`));
|
|
2655
|
+
container.addTextDisplayComponents(new import_discord17.TextDisplayBuilder().setContent(options.value));
|
|
2656
|
+
}
|
|
2632
2657
|
static field(container, field) {
|
|
2633
|
-
if ("button" in field
|
|
2658
|
+
if ("button" in field && Array.isArray(field.button) && field.button.length > 0) {
|
|
2659
|
+
const actionRow = new import_discord17.ActionRowBuilder().addComponents(field.button);
|
|
2660
|
+
this.fieldAddText(container, { name: field.name, value: field.value });
|
|
2661
|
+
container.addActionRowComponents(actionRow);
|
|
2662
|
+
} else if ("button" in field && !Array.isArray(field.button) || "thumbnailUrl" in field) {
|
|
2634
2663
|
const section = new import_discord17.SectionBuilder();
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
}
|
|
2638
|
-
section.addTextDisplayComponents(new import_discord17.TextDisplayBuilder().setContent(field.value));
|
|
2639
|
-
if ("button" in field) {
|
|
2664
|
+
this.fieldAddText(section, { name: field.name, value: field.value });
|
|
2665
|
+
if ("button" in field && !Array.isArray(field.button)) {
|
|
2640
2666
|
section.setButtonAccessory(field.button);
|
|
2641
2667
|
} else if ("thumbnailUrl" in field) {
|
|
2642
2668
|
section.setThumbnailAccessory(new import_discord17.ThumbnailBuilder().setURL(field.thumbnailUrl));
|
|
2643
2669
|
}
|
|
2644
2670
|
container.addSectionComponents(section);
|
|
2645
2671
|
} else {
|
|
2646
|
-
|
|
2647
|
-
container.addTextDisplayComponents(new import_discord17.TextDisplayBuilder().setContent(`**${field.name}**`));
|
|
2648
|
-
}
|
|
2649
|
-
container.addTextDisplayComponents(new import_discord17.TextDisplayBuilder().setContent(field.value));
|
|
2672
|
+
this.fieldAddText(container, { name: field.name, value: field.value });
|
|
2650
2673
|
}
|
|
2651
2674
|
if (field.separator !== false) {
|
|
2652
2675
|
container.addSeparatorComponents(this.separator(field.separator));
|
|
2653
2676
|
}
|
|
2654
2677
|
return container;
|
|
2655
2678
|
}
|
|
2656
|
-
/*static field(container: ContainerBuilder, field: ComponentManagerField): ContainerBuilder {
|
|
2657
|
-
const section = new SectionBuilder()
|
|
2658
|
-
.addTextDisplayComponents(
|
|
2659
|
-
new TextDisplayBuilder().setContent(`**${field.name}**`),
|
|
2660
|
-
new TextDisplayBuilder().setContent(field.value)
|
|
2661
|
-
);
|
|
2662
|
-
|
|
2663
|
-
if (field.thumbnailUrl) {
|
|
2664
|
-
section.setThumbnailAccessory(
|
|
2665
|
-
new ThumbnailBuilder().setURL(field.thumbnailUrl)
|
|
2666
|
-
);
|
|
2667
|
-
}
|
|
2668
|
-
|
|
2669
|
-
if (field.button && field.button.length > 0) {
|
|
2670
|
-
section.setButtonAccessory(field.button[0]!);
|
|
2671
|
-
}
|
|
2672
|
-
|
|
2673
|
-
container.addSectionComponents(section);
|
|
2674
|
-
container.addSeparatorComponents(this.separator());
|
|
2675
|
-
return container;
|
|
2676
|
-
}*/
|
|
2677
2679
|
/**
|
|
2678
2680
|
* Multiple fields
|
|
2679
2681
|
*/
|
|
2680
2682
|
static fields(container, fields) {
|
|
2681
|
-
fields.forEach((
|
|
2682
|
-
|
|
2683
|
+
fields.forEach((field, index) => {
|
|
2684
|
+
const finalField = { ...field };
|
|
2685
|
+
if (index === fields.length - 1 && finalField.separator === void 0) {
|
|
2686
|
+
finalField.separator = false;
|
|
2687
|
+
}
|
|
2688
|
+
this.field(container, finalField);
|
|
2683
2689
|
});
|
|
2684
2690
|
return container;
|
|
2685
2691
|
}
|
|
@@ -2745,6 +2751,37 @@ var ComponentManager = class {
|
|
|
2745
2751
|
flags: [import_discord17.MessageFlags.IsComponentsV2]
|
|
2746
2752
|
};
|
|
2747
2753
|
}
|
|
2754
|
+
static toInteraction(container, file = null, footer = true) {
|
|
2755
|
+
if (footer) {
|
|
2756
|
+
this.footer(container);
|
|
2757
|
+
}
|
|
2758
|
+
const base = {
|
|
2759
|
+
components: [container],
|
|
2760
|
+
flags: [import_discord17.MessageFlags.IsComponentsV2]
|
|
2761
|
+
};
|
|
2762
|
+
if (file) {
|
|
2763
|
+
return {
|
|
2764
|
+
...base,
|
|
2765
|
+
files: Array.isArray(file) ? file : [file]
|
|
2766
|
+
};
|
|
2767
|
+
}
|
|
2768
|
+
return base;
|
|
2769
|
+
}
|
|
2770
|
+
static toInteractionEdit(container, file = null, footer = true) {
|
|
2771
|
+
if (footer) {
|
|
2772
|
+
this.footer(container);
|
|
2773
|
+
}
|
|
2774
|
+
const base = {
|
|
2775
|
+
components: [container]
|
|
2776
|
+
};
|
|
2777
|
+
if (file) {
|
|
2778
|
+
return {
|
|
2779
|
+
...base,
|
|
2780
|
+
files: Array.isArray(file) ? file : [file]
|
|
2781
|
+
};
|
|
2782
|
+
}
|
|
2783
|
+
return base;
|
|
2784
|
+
}
|
|
2748
2785
|
};
|
|
2749
2786
|
|
|
2750
2787
|
// src/manager/interactions/ButtonManager.ts
|
|
@@ -2795,6 +2832,11 @@ var ButtonManager = class _ButtonManager {
|
|
|
2795
2832
|
flags: ephemeral ? [import_discord18.MessageFlags.Ephemeral] : []
|
|
2796
2833
|
};
|
|
2797
2834
|
}
|
|
2835
|
+
static toInteractionEdit(button) {
|
|
2836
|
+
return {
|
|
2837
|
+
components: this.createRowsToReturn(button)
|
|
2838
|
+
};
|
|
2839
|
+
}
|
|
2798
2840
|
static createRowsToReturn(button) {
|
|
2799
2841
|
if (Array.isArray(button)) {
|
|
2800
2842
|
return button.map(
|
|
@@ -2846,7 +2888,7 @@ var SimpleMutex = class {
|
|
|
2846
2888
|
// package.json
|
|
2847
2889
|
var package_default = {
|
|
2848
2890
|
name: "@spatulox/simplediscordbot",
|
|
2849
|
-
version: "1.
|
|
2891
|
+
version: "1.6.1",
|
|
2850
2892
|
author: "Spatulox",
|
|
2851
2893
|
description: "Simple discord bot framework to set up a bot under 30 secondes",
|
|
2852
2894
|
exports: {
|
|
@@ -2908,7 +2950,6 @@ var SimpleDiscordBotInfo = {
|
|
|
2908
2950
|
ButtonManager,
|
|
2909
2951
|
ComponentManager,
|
|
2910
2952
|
DiscordRegex,
|
|
2911
|
-
EmbedColor,
|
|
2912
2953
|
EmbedManager,
|
|
2913
2954
|
FileManager,
|
|
2914
2955
|
GuildManager,
|
|
@@ -2917,6 +2958,7 @@ var SimpleDiscordBotInfo = {
|
|
|
2917
2958
|
ModalManager,
|
|
2918
2959
|
ReactionManager,
|
|
2919
2960
|
SelectMenuManager,
|
|
2961
|
+
SimpleColor,
|
|
2920
2962
|
SimpleDiscordBotInfo,
|
|
2921
2963
|
SimpleMutex,
|
|
2922
2964
|
Time,
|