@spatulox/simplediscordbot 1.6.1 → 1.6.3
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/.env.example +1 -1
- package/LICENSE.md +21 -21
- package/README.md +3 -3
- package/dist/index.d.mts +104 -95
- package/dist/index.d.ts +104 -95
- package/dist/index.js +122 -82
- package/dist/index.mjs +125 -84
- package/package.json +2 -2
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)
|
|
@@ -338,11 +338,11 @@ var InternetChecker = class {
|
|
|
338
338
|
return false;
|
|
339
339
|
}
|
|
340
340
|
};
|
|
341
|
-
InternetChecker.TARGET = "https://
|
|
341
|
+
InternetChecker.TARGET = "https://one.one.one.one/";
|
|
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
|
|
@@ -2655,33 +2676,16 @@ var ComponentManager = class {
|
|
|
2655
2676
|
}
|
|
2656
2677
|
return container;
|
|
2657
2678
|
}
|
|
2658
|
-
/*static field(container: ContainerBuilder, field: ComponentManagerField): ContainerBuilder {
|
|
2659
|
-
const section = new SectionBuilder()
|
|
2660
|
-
.addTextDisplayComponents(
|
|
2661
|
-
new TextDisplayBuilder().setContent(`**${field.name}**`),
|
|
2662
|
-
new TextDisplayBuilder().setContent(field.value)
|
|
2663
|
-
);
|
|
2664
|
-
|
|
2665
|
-
if (field.thumbnailUrl) {
|
|
2666
|
-
section.setThumbnailAccessory(
|
|
2667
|
-
new ThumbnailBuilder().setURL(field.thumbnailUrl)
|
|
2668
|
-
);
|
|
2669
|
-
}
|
|
2670
|
-
|
|
2671
|
-
if (field.button && field.button.length > 0) {
|
|
2672
|
-
section.setButtonAccessory(field.button[0]!);
|
|
2673
|
-
}
|
|
2674
|
-
|
|
2675
|
-
container.addSectionComponents(section);
|
|
2676
|
-
container.addSeparatorComponents(this.separator());
|
|
2677
|
-
return container;
|
|
2678
|
-
}*/
|
|
2679
2679
|
/**
|
|
2680
2680
|
* Multiple fields
|
|
2681
2681
|
*/
|
|
2682
2682
|
static fields(container, fields) {
|
|
2683
|
-
fields.forEach((
|
|
2684
|
-
|
|
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);
|
|
2685
2689
|
});
|
|
2686
2690
|
return container;
|
|
2687
2691
|
}
|
|
@@ -2747,6 +2751,37 @@ var ComponentManager = class {
|
|
|
2747
2751
|
flags: [import_discord17.MessageFlags.IsComponentsV2]
|
|
2748
2752
|
};
|
|
2749
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
|
+
}
|
|
2750
2785
|
};
|
|
2751
2786
|
|
|
2752
2787
|
// src/manager/interactions/ButtonManager.ts
|
|
@@ -2797,6 +2832,11 @@ var ButtonManager = class _ButtonManager {
|
|
|
2797
2832
|
flags: ephemeral ? [import_discord18.MessageFlags.Ephemeral] : []
|
|
2798
2833
|
};
|
|
2799
2834
|
}
|
|
2835
|
+
static toInteractionEdit(button) {
|
|
2836
|
+
return {
|
|
2837
|
+
components: this.createRowsToReturn(button)
|
|
2838
|
+
};
|
|
2839
|
+
}
|
|
2800
2840
|
static createRowsToReturn(button) {
|
|
2801
2841
|
if (Array.isArray(button)) {
|
|
2802
2842
|
return button.map(
|
|
@@ -2848,7 +2888,7 @@ var SimpleMutex = class {
|
|
|
2848
2888
|
// package.json
|
|
2849
2889
|
var package_default = {
|
|
2850
2890
|
name: "@spatulox/simplediscordbot",
|
|
2851
|
-
version: "1.6.
|
|
2891
|
+
version: "1.6.2",
|
|
2852
2892
|
author: "Spatulox",
|
|
2853
2893
|
description: "Simple discord bot framework to set up a bot under 30 secondes",
|
|
2854
2894
|
exports: {
|
|
@@ -2870,7 +2910,7 @@ var package_default = {
|
|
|
2870
2910
|
},
|
|
2871
2911
|
license: "MIT",
|
|
2872
2912
|
dependencies: {
|
|
2873
|
-
"@spatulox/discord-interaction-manager": "^1.0
|
|
2913
|
+
"@spatulox/discord-interaction-manager": "^1.1.0",
|
|
2874
2914
|
"discord.js": "^14.25.1"
|
|
2875
2915
|
},
|
|
2876
2916
|
devDependencies: {
|
|
@@ -2910,7 +2950,6 @@ var SimpleDiscordBotInfo = {
|
|
|
2910
2950
|
ButtonManager,
|
|
2911
2951
|
ComponentManager,
|
|
2912
2952
|
DiscordRegex,
|
|
2913
|
-
EmbedColor,
|
|
2914
2953
|
EmbedManager,
|
|
2915
2954
|
FileManager,
|
|
2916
2955
|
GuildManager,
|
|
@@ -2919,6 +2958,7 @@ var SimpleDiscordBotInfo = {
|
|
|
2919
2958
|
ModalManager,
|
|
2920
2959
|
ReactionManager,
|
|
2921
2960
|
SelectMenuManager,
|
|
2961
|
+
SimpleColor,
|
|
2922
2962
|
SimpleDiscordBotInfo,
|
|
2923
2963
|
SimpleMutex,
|
|
2924
2964
|
Time,
|