@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.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/core/Bot.ts
|
|
2
2
|
import { Events, version } from "discord.js";
|
|
3
3
|
|
|
4
|
-
// src/utils/
|
|
4
|
+
// src/utils/UnitTime.ts
|
|
5
5
|
var UnitTime = class {
|
|
6
6
|
constructor(val) {
|
|
7
7
|
this.val = val;
|
|
@@ -241,7 +241,7 @@ var Log = class {
|
|
|
241
241
|
}
|
|
242
242
|
};
|
|
243
243
|
|
|
244
|
-
// src/utils/
|
|
244
|
+
// src/utils/InternetChecker.ts
|
|
245
245
|
var InternetChecker = class {
|
|
246
246
|
/**
|
|
247
247
|
* Check internet connection towards 1.1.1.1 (Cloudflare DNS)
|
|
@@ -284,11 +284,11 @@ var InternetChecker = class {
|
|
|
284
284
|
return false;
|
|
285
285
|
}
|
|
286
286
|
};
|
|
287
|
-
InternetChecker.TARGET = "https://
|
|
287
|
+
InternetChecker.TARGET = "https://one.one.one.one/";
|
|
288
288
|
// Cloudflare DNS HTTPS
|
|
289
289
|
InternetChecker.RETRY_TIME = Time.second.SEC_30;
|
|
290
290
|
|
|
291
|
-
// src/
|
|
291
|
+
// src/core/BotLog.ts
|
|
292
292
|
import { EmbedBuilder, ActionRowBuilder } from "discord.js";
|
|
293
293
|
var _BotLog = class _BotLog {
|
|
294
294
|
constructor() {
|
|
@@ -419,52 +419,56 @@ import {
|
|
|
419
419
|
EmbedBuilder as EmbedBuilder2,
|
|
420
420
|
MessageFlags
|
|
421
421
|
} from "discord.js";
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
422
|
+
|
|
423
|
+
// src/constants/SimpleColor.ts
|
|
424
|
+
var SimpleColor = /* @__PURE__ */ ((SimpleColor2) => {
|
|
425
|
+
SimpleColor2["transparent"] = "transparent";
|
|
426
|
+
SimpleColor2[SimpleColor2["error"] = 8912917] = "error";
|
|
427
|
+
SimpleColor2[SimpleColor2["success"] = 65280] = "success";
|
|
428
|
+
SimpleColor2[SimpleColor2["black"] = 0] = "black";
|
|
429
|
+
SimpleColor2[SimpleColor2["white"] = 16777215] = "white";
|
|
430
|
+
SimpleColor2[SimpleColor2["red"] = 16711680] = "red";
|
|
431
|
+
SimpleColor2[SimpleColor2["green"] = 65280] = "green";
|
|
432
|
+
SimpleColor2[SimpleColor2["blue"] = 255] = "blue";
|
|
433
|
+
SimpleColor2[SimpleColor2["yellow"] = 16776960] = "yellow";
|
|
434
|
+
SimpleColor2[SimpleColor2["cyan"] = 65535] = "cyan";
|
|
435
|
+
SimpleColor2[SimpleColor2["magenta"] = 16711935] = "magenta";
|
|
436
|
+
SimpleColor2[SimpleColor2["gray"] = 8421504] = "gray";
|
|
437
|
+
SimpleColor2[SimpleColor2["lightgray"] = 13882323] = "lightgray";
|
|
438
|
+
SimpleColor2[SimpleColor2["darkgray"] = 11119017] = "darkgray";
|
|
439
|
+
SimpleColor2[SimpleColor2["orange"] = 16753920] = "orange";
|
|
440
|
+
SimpleColor2[SimpleColor2["purple"] = 8388736] = "purple";
|
|
441
|
+
SimpleColor2[SimpleColor2["pink"] = 16761035] = "pink";
|
|
442
|
+
SimpleColor2[SimpleColor2["brown"] = 10824234] = "brown";
|
|
443
|
+
SimpleColor2[SimpleColor2["lime"] = 65280] = "lime";
|
|
444
|
+
SimpleColor2[SimpleColor2["navy"] = 128] = "navy";
|
|
445
|
+
SimpleColor2[SimpleColor2["teal"] = 32896] = "teal";
|
|
446
|
+
SimpleColor2[SimpleColor2["olive"] = 8421376] = "olive";
|
|
447
|
+
SimpleColor2[SimpleColor2["gold"] = 16766720] = "gold";
|
|
448
|
+
SimpleColor2[SimpleColor2["silver"] = 12632256] = "silver";
|
|
449
|
+
SimpleColor2[SimpleColor2["coral"] = 16744272] = "coral";
|
|
450
|
+
SimpleColor2[SimpleColor2["salmon"] = 16416882] = "salmon";
|
|
451
|
+
SimpleColor2[SimpleColor2["khaki"] = 15787660] = "khaki";
|
|
452
|
+
SimpleColor2[SimpleColor2["plum"] = 14524637] = "plum";
|
|
453
|
+
SimpleColor2[SimpleColor2["lavender"] = 15132410] = "lavender";
|
|
454
|
+
SimpleColor2[SimpleColor2["beige"] = 16119260] = "beige";
|
|
455
|
+
SimpleColor2[SimpleColor2["mint"] = 10026904] = "mint";
|
|
456
|
+
SimpleColor2[SimpleColor2["peach"] = 16767673] = "peach";
|
|
457
|
+
SimpleColor2[SimpleColor2["chocolate"] = 13789470] = "chocolate";
|
|
458
|
+
SimpleColor2[SimpleColor2["crimson"] = 14423100] = "crimson";
|
|
459
|
+
SimpleColor2[SimpleColor2["youtube"] = 16718362] = "youtube";
|
|
460
|
+
SimpleColor2[SimpleColor2["default"] = 6064856] = "default";
|
|
461
|
+
SimpleColor2[SimpleColor2["minecraft"] = 25600] = "minecraft";
|
|
462
|
+
return SimpleColor2;
|
|
463
|
+
})(SimpleColor || {});
|
|
464
|
+
|
|
465
|
+
// src/manager/messages/EmbedManager.ts
|
|
462
466
|
var EmbedManager = class {
|
|
463
467
|
static get BOT_ICON() {
|
|
464
468
|
return Bot.client?.user?.displayAvatarURL({ forceStatic: false, size: 128 }) || "";
|
|
465
469
|
}
|
|
466
470
|
static get DEFAULT_COLOR() {
|
|
467
|
-
return Bot.config.
|
|
471
|
+
return Bot.config.defaultSimpleColor || 6064856 /* default */;
|
|
468
472
|
}
|
|
469
473
|
/**
|
|
470
474
|
* Creates base embed - SAME SIMPLE API !
|
|
@@ -540,7 +544,15 @@ var EmbedManager = class {
|
|
|
540
544
|
static toInteraction(embed, ephemeral = false) {
|
|
541
545
|
return {
|
|
542
546
|
embeds: [embed],
|
|
543
|
-
flags: ephemeral ? [MessageFlags.Ephemeral] :
|
|
547
|
+
flags: ephemeral ? [MessageFlags.Ephemeral] : []
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Transform embed into objet for interaction.editReply()
|
|
552
|
+
*/
|
|
553
|
+
static toInteractionEdit(embed) {
|
|
554
|
+
return {
|
|
555
|
+
embeds: [embed]
|
|
544
556
|
};
|
|
545
557
|
}
|
|
546
558
|
/**
|
|
@@ -553,7 +565,7 @@ var EmbedManager = class {
|
|
|
553
565
|
}
|
|
554
566
|
};
|
|
555
567
|
|
|
556
|
-
// src/
|
|
568
|
+
// src/core/BotMessage.ts
|
|
557
569
|
import {
|
|
558
570
|
User,
|
|
559
571
|
GuildMember
|
|
@@ -563,11 +575,12 @@ import {
|
|
|
563
575
|
import {
|
|
564
576
|
ActionRowBuilder as ActionRowBuilder2,
|
|
565
577
|
EmbedBuilder as EmbedBuilder3,
|
|
566
|
-
MessageFlags as MessageFlags2
|
|
578
|
+
MessageFlags as MessageFlags2,
|
|
579
|
+
ContainerBuilder
|
|
567
580
|
} from "discord.js";
|
|
568
581
|
var SendableComponentBuilder = class {
|
|
569
582
|
static isSendableComponent(thing) {
|
|
570
|
-
return thing instanceof EmbedBuilder3 || thing instanceof ActionRowBuilder2;
|
|
583
|
+
return thing instanceof EmbedBuilder3 || thing instanceof ContainerBuilder || thing instanceof ActionRowBuilder2;
|
|
571
584
|
}
|
|
572
585
|
static build(base, content, components) {
|
|
573
586
|
if (content) {
|
|
@@ -579,6 +592,10 @@ var SendableComponentBuilder = class {
|
|
|
579
592
|
base.embeds = base.embeds || [];
|
|
580
593
|
base.embeds.push(comp);
|
|
581
594
|
}
|
|
595
|
+
if (comp instanceof ContainerBuilder) {
|
|
596
|
+
base.components = base.components || [];
|
|
597
|
+
base.components.push(comp);
|
|
598
|
+
}
|
|
582
599
|
if (comp instanceof ActionRowBuilder2) {
|
|
583
600
|
base.components = base.components || [];
|
|
584
601
|
base.components.push(comp);
|
|
@@ -609,7 +626,7 @@ var SendableComponentBuilder = class {
|
|
|
609
626
|
}
|
|
610
627
|
};
|
|
611
628
|
|
|
612
|
-
// src/
|
|
629
|
+
// src/core/BotMessage.ts
|
|
613
630
|
var BotMessage = class {
|
|
614
631
|
static async send(channel, content, component) {
|
|
615
632
|
try {
|
|
@@ -700,7 +717,7 @@ var BotMessage = class {
|
|
|
700
717
|
}
|
|
701
718
|
};
|
|
702
719
|
|
|
703
|
-
// src/
|
|
720
|
+
// src/constants/DiscordRegex.ts
|
|
704
721
|
var _DiscordRegex = class _DiscordRegex {
|
|
705
722
|
/**
|
|
706
723
|
* Validate Discord ID Discord (18)
|
|
@@ -815,7 +832,7 @@ _DiscordRegex.INVITE = /^discord(?:app\.com\/invite|gg)\/[a-zA-Z0-9]+$/;
|
|
|
815
832
|
_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;
|
|
816
833
|
var DiscordRegex = _DiscordRegex;
|
|
817
834
|
|
|
818
|
-
// src/
|
|
835
|
+
// src/core/BotEnv.ts
|
|
819
836
|
var BotEnv = {
|
|
820
837
|
get token() {
|
|
821
838
|
const token = process.env.DISCORD_BOT_TOKEN;
|
|
@@ -835,7 +852,7 @@ var BotEnv = {
|
|
|
835
852
|
}
|
|
836
853
|
};
|
|
837
854
|
|
|
838
|
-
// src/
|
|
855
|
+
// src/core/BotInteraction.ts
|
|
839
856
|
var BotInteraction = class {
|
|
840
857
|
/**
|
|
841
858
|
* InteractionReplyOptions && InteractionUpdateOptions
|
|
@@ -911,7 +928,7 @@ var BotInteraction = class {
|
|
|
911
928
|
}
|
|
912
929
|
};
|
|
913
930
|
|
|
914
|
-
// src/
|
|
931
|
+
// src/core/Bot.ts
|
|
915
932
|
var _Bot = class _Bot {
|
|
916
933
|
get config() {
|
|
917
934
|
return _Bot._config;
|
|
@@ -2522,6 +2539,11 @@ var SelectMenuManager = class _SelectMenuManager {
|
|
|
2522
2539
|
flags: ephemeral ? [MessageFlags3.Ephemeral] : []
|
|
2523
2540
|
};
|
|
2524
2541
|
}
|
|
2542
|
+
static toInteractionEdit(menus) {
|
|
2543
|
+
return {
|
|
2544
|
+
components: this._createRowsToReturn(menus)
|
|
2545
|
+
};
|
|
2546
|
+
}
|
|
2525
2547
|
static _createRowsToReturn(menus) {
|
|
2526
2548
|
if (Array.isArray(menus)) {
|
|
2527
2549
|
return menus.map(
|
|
@@ -2534,7 +2556,7 @@ var SelectMenuManager = class _SelectMenuManager {
|
|
|
2534
2556
|
|
|
2535
2557
|
// src/manager/messages/ComponentManager.ts
|
|
2536
2558
|
import {
|
|
2537
|
-
ContainerBuilder,
|
|
2559
|
+
ContainerBuilder as ContainerBuilder2,
|
|
2538
2560
|
TextDisplayBuilder,
|
|
2539
2561
|
SeparatorBuilder,
|
|
2540
2562
|
SeparatorSpacingSize,
|
|
@@ -2549,13 +2571,13 @@ import {
|
|
|
2549
2571
|
} from "discord.js";
|
|
2550
2572
|
var ComponentManager = class {
|
|
2551
2573
|
static get DEFAULT_COLOR() {
|
|
2552
|
-
return Bot.config?.
|
|
2574
|
+
return Bot.config?.defaultSimpleColor || 6064856 /* default */;
|
|
2553
2575
|
}
|
|
2554
2576
|
/**
|
|
2555
2577
|
* Creates base ComponentV2
|
|
2556
2578
|
*/
|
|
2557
2579
|
static create(option) {
|
|
2558
|
-
const container = new
|
|
2580
|
+
const container = new ContainerBuilder2();
|
|
2559
2581
|
const colorC = option?.color ?? this.DEFAULT_COLOR;
|
|
2560
2582
|
if (colorC !== "transparent" /* transparent */) {
|
|
2561
2583
|
container.setAccentColor(colorC);
|
|
@@ -2644,33 +2666,16 @@ var ComponentManager = class {
|
|
|
2644
2666
|
}
|
|
2645
2667
|
return container;
|
|
2646
2668
|
}
|
|
2647
|
-
/*static field(container: ContainerBuilder, field: ComponentManagerField): ContainerBuilder {
|
|
2648
|
-
const section = new SectionBuilder()
|
|
2649
|
-
.addTextDisplayComponents(
|
|
2650
|
-
new TextDisplayBuilder().setContent(`**${field.name}**`),
|
|
2651
|
-
new TextDisplayBuilder().setContent(field.value)
|
|
2652
|
-
);
|
|
2653
|
-
|
|
2654
|
-
if (field.thumbnailUrl) {
|
|
2655
|
-
section.setThumbnailAccessory(
|
|
2656
|
-
new ThumbnailBuilder().setURL(field.thumbnailUrl)
|
|
2657
|
-
);
|
|
2658
|
-
}
|
|
2659
|
-
|
|
2660
|
-
if (field.button && field.button.length > 0) {
|
|
2661
|
-
section.setButtonAccessory(field.button[0]!);
|
|
2662
|
-
}
|
|
2663
|
-
|
|
2664
|
-
container.addSectionComponents(section);
|
|
2665
|
-
container.addSeparatorComponents(this.separator());
|
|
2666
|
-
return container;
|
|
2667
|
-
}*/
|
|
2668
2669
|
/**
|
|
2669
2670
|
* Multiple fields
|
|
2670
2671
|
*/
|
|
2671
2672
|
static fields(container, fields) {
|
|
2672
|
-
fields.forEach((
|
|
2673
|
-
|
|
2673
|
+
fields.forEach((field, index) => {
|
|
2674
|
+
const finalField = { ...field };
|
|
2675
|
+
if (index === fields.length - 1 && finalField.separator === void 0) {
|
|
2676
|
+
finalField.separator = false;
|
|
2677
|
+
}
|
|
2678
|
+
this.field(container, finalField);
|
|
2674
2679
|
});
|
|
2675
2680
|
return container;
|
|
2676
2681
|
}
|
|
@@ -2736,6 +2741,37 @@ var ComponentManager = class {
|
|
|
2736
2741
|
flags: [MessageFlags4.IsComponentsV2]
|
|
2737
2742
|
};
|
|
2738
2743
|
}
|
|
2744
|
+
static toInteraction(container, file = null, footer = true) {
|
|
2745
|
+
if (footer) {
|
|
2746
|
+
this.footer(container);
|
|
2747
|
+
}
|
|
2748
|
+
const base = {
|
|
2749
|
+
components: [container],
|
|
2750
|
+
flags: [MessageFlags4.IsComponentsV2]
|
|
2751
|
+
};
|
|
2752
|
+
if (file) {
|
|
2753
|
+
return {
|
|
2754
|
+
...base,
|
|
2755
|
+
files: Array.isArray(file) ? file : [file]
|
|
2756
|
+
};
|
|
2757
|
+
}
|
|
2758
|
+
return base;
|
|
2759
|
+
}
|
|
2760
|
+
static toInteractionEdit(container, file = null, footer = true) {
|
|
2761
|
+
if (footer) {
|
|
2762
|
+
this.footer(container);
|
|
2763
|
+
}
|
|
2764
|
+
const base = {
|
|
2765
|
+
components: [container]
|
|
2766
|
+
};
|
|
2767
|
+
if (file) {
|
|
2768
|
+
return {
|
|
2769
|
+
...base,
|
|
2770
|
+
files: Array.isArray(file) ? file : [file]
|
|
2771
|
+
};
|
|
2772
|
+
}
|
|
2773
|
+
return base;
|
|
2774
|
+
}
|
|
2739
2775
|
};
|
|
2740
2776
|
|
|
2741
2777
|
// src/manager/interactions/ButtonManager.ts
|
|
@@ -2791,6 +2827,11 @@ var ButtonManager = class _ButtonManager {
|
|
|
2791
2827
|
flags: ephemeral ? [MessageFlags5.Ephemeral] : []
|
|
2792
2828
|
};
|
|
2793
2829
|
}
|
|
2830
|
+
static toInteractionEdit(button) {
|
|
2831
|
+
return {
|
|
2832
|
+
components: this.createRowsToReturn(button)
|
|
2833
|
+
};
|
|
2834
|
+
}
|
|
2794
2835
|
static createRowsToReturn(button) {
|
|
2795
2836
|
if (Array.isArray(button)) {
|
|
2796
2837
|
return button.map(
|
|
@@ -2842,7 +2883,7 @@ var SimpleMutex = class {
|
|
|
2842
2883
|
// package.json
|
|
2843
2884
|
var package_default = {
|
|
2844
2885
|
name: "@spatulox/simplediscordbot",
|
|
2845
|
-
version: "1.6.
|
|
2886
|
+
version: "1.6.2",
|
|
2846
2887
|
author: "Spatulox",
|
|
2847
2888
|
description: "Simple discord bot framework to set up a bot under 30 secondes",
|
|
2848
2889
|
exports: {
|
|
@@ -2864,7 +2905,7 @@ var package_default = {
|
|
|
2864
2905
|
},
|
|
2865
2906
|
license: "MIT",
|
|
2866
2907
|
dependencies: {
|
|
2867
|
-
"@spatulox/discord-interaction-manager": "^1.0
|
|
2908
|
+
"@spatulox/discord-interaction-manager": "^1.1.0",
|
|
2868
2909
|
"discord.js": "^14.25.1"
|
|
2869
2910
|
},
|
|
2870
2911
|
devDependencies: {
|
|
@@ -2903,7 +2944,6 @@ export {
|
|
|
2903
2944
|
ButtonManager,
|
|
2904
2945
|
ComponentManager,
|
|
2905
2946
|
DiscordRegex,
|
|
2906
|
-
EmbedColor,
|
|
2907
2947
|
EmbedManager,
|
|
2908
2948
|
FileManager,
|
|
2909
2949
|
GuildManager,
|
|
@@ -2912,6 +2952,7 @@ export {
|
|
|
2912
2952
|
ModalManager,
|
|
2913
2953
|
ReactionManager,
|
|
2914
2954
|
SelectMenuManager,
|
|
2955
|
+
SimpleColor,
|
|
2915
2956
|
SimpleDiscordBotInfo,
|
|
2916
2957
|
SimpleMutex,
|
|
2917
2958
|
Time,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spatulox/simplediscordbot",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"author": "Spatulox",
|
|
5
5
|
"description": "Simple discord bot framework to set up a bot under 30 secondes",
|
|
6
6
|
"exports": {
|
|
@@ -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.1.0",
|
|
26
26
|
"discord.js": "^14.25.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|