@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/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- // src/bot/Bot.ts
1
+ // src/core/Bot.ts
2
2
  import { Events, version } from "discord.js";
3
3
 
4
- // src/utils/times/UnitTime.ts
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/network/InternetChecker.ts
244
+ // src/utils/InternetChecker.ts
245
245
  var InternetChecker = class {
246
246
  /**
247
247
  * Check internet connection towards 1.1.1.1 (Cloudflare DNS)
@@ -288,7 +288,7 @@ InternetChecker.TARGET = "https://1.1.1.1";
288
288
  // Cloudflare DNS HTTPS
289
289
  InternetChecker.RETRY_TIME = Time.second.SEC_30;
290
290
 
291
- // src/bot/BotLog.ts
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
- var EmbedColor = /* @__PURE__ */ ((EmbedColor3) => {
423
- EmbedColor3["transparent"] = "transparent";
424
- EmbedColor3[EmbedColor3["error"] = 8912917] = "error";
425
- EmbedColor3[EmbedColor3["success"] = 65280] = "success";
426
- EmbedColor3[EmbedColor3["black"] = 0] = "black";
427
- EmbedColor3[EmbedColor3["white"] = 16777215] = "white";
428
- EmbedColor3[EmbedColor3["red"] = 16711680] = "red";
429
- EmbedColor3[EmbedColor3["green"] = 65280] = "green";
430
- EmbedColor3[EmbedColor3["blue"] = 255] = "blue";
431
- EmbedColor3[EmbedColor3["yellow"] = 16776960] = "yellow";
432
- EmbedColor3[EmbedColor3["cyan"] = 65535] = "cyan";
433
- EmbedColor3[EmbedColor3["magenta"] = 16711935] = "magenta";
434
- EmbedColor3[EmbedColor3["gray"] = 8421504] = "gray";
435
- EmbedColor3[EmbedColor3["lightgray"] = 13882323] = "lightgray";
436
- EmbedColor3[EmbedColor3["darkgray"] = 11119017] = "darkgray";
437
- EmbedColor3[EmbedColor3["orange"] = 16753920] = "orange";
438
- EmbedColor3[EmbedColor3["purple"] = 8388736] = "purple";
439
- EmbedColor3[EmbedColor3["pink"] = 16761035] = "pink";
440
- EmbedColor3[EmbedColor3["brown"] = 10824234] = "brown";
441
- EmbedColor3[EmbedColor3["lime"] = 65280] = "lime";
442
- EmbedColor3[EmbedColor3["navy"] = 128] = "navy";
443
- EmbedColor3[EmbedColor3["teal"] = 32896] = "teal";
444
- EmbedColor3[EmbedColor3["olive"] = 8421376] = "olive";
445
- EmbedColor3[EmbedColor3["gold"] = 16766720] = "gold";
446
- EmbedColor3[EmbedColor3["silver"] = 12632256] = "silver";
447
- EmbedColor3[EmbedColor3["coral"] = 16744272] = "coral";
448
- EmbedColor3[EmbedColor3["salmon"] = 16416882] = "salmon";
449
- EmbedColor3[EmbedColor3["khaki"] = 15787660] = "khaki";
450
- EmbedColor3[EmbedColor3["plum"] = 14524637] = "plum";
451
- EmbedColor3[EmbedColor3["lavender"] = 15132410] = "lavender";
452
- EmbedColor3[EmbedColor3["beige"] = 16119260] = "beige";
453
- EmbedColor3[EmbedColor3["mint"] = 10026904] = "mint";
454
- EmbedColor3[EmbedColor3["peach"] = 16767673] = "peach";
455
- EmbedColor3[EmbedColor3["chocolate"] = 13789470] = "chocolate";
456
- EmbedColor3[EmbedColor3["crimson"] = 14423100] = "crimson";
457
- EmbedColor3[EmbedColor3["youtube"] = 16718362] = "youtube";
458
- EmbedColor3[EmbedColor3["default"] = 6064856] = "default";
459
- EmbedColor3[EmbedColor3["minecraft"] = 25600] = "minecraft";
460
- return EmbedColor3;
461
- })(EmbedColor || {});
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.defaultEmbedColor || 6064856 /* default */;
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] : void 0
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/bot/BotMessage.ts
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/bot/BotMessage.ts
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/utils/DiscordRegex.ts
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/bot/BotEnv.ts
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/bot/BotInteraction.ts
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/bot/Bot.ts
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,
@@ -2544,17 +2566,18 @@ import {
2544
2566
  MediaGalleryBuilder,
2545
2567
  MediaGalleryItemBuilder,
2546
2568
  AttachmentBuilder,
2547
- FileBuilder
2569
+ FileBuilder,
2570
+ ActionRowBuilder as ActionRowBuilder4
2548
2571
  } from "discord.js";
2549
2572
  var ComponentManager = class {
2550
2573
  static get DEFAULT_COLOR() {
2551
- return Bot.config?.defaultEmbedColor || 6064856 /* default */;
2574
+ return Bot.config?.defaultSimpleColor || 6064856 /* default */;
2552
2575
  }
2553
2576
  /**
2554
2577
  * Creates base ComponentV2
2555
2578
  */
2556
2579
  static create(option) {
2557
- const container = new ContainerBuilder();
2580
+ const container = new ContainerBuilder2();
2558
2581
  const colorC = option?.color ?? this.DEFAULT_COLOR;
2559
2582
  if (colorC !== "transparent" /* transparent */) {
2560
2583
  container.setAccentColor(colorC);
@@ -2617,57 +2640,42 @@ var ComponentManager = class {
2617
2640
  /**
2618
2641
  * Quick field adder
2619
2642
  */
2643
+ static fieldAddText(container, options) {
2644
+ options.name && container.addTextDisplayComponents(new TextDisplayBuilder().setContent(`__**${options.name}**__`));
2645
+ container.addTextDisplayComponents(new TextDisplayBuilder().setContent(options.value));
2646
+ }
2620
2647
  static field(container, field) {
2621
- if ("button" in field || "thumbnailUrl" in field) {
2648
+ if ("button" in field && Array.isArray(field.button) && field.button.length > 0) {
2649
+ const actionRow = new ActionRowBuilder4().addComponents(field.button);
2650
+ this.fieldAddText(container, { name: field.name, value: field.value });
2651
+ container.addActionRowComponents(actionRow);
2652
+ } else if ("button" in field && !Array.isArray(field.button) || "thumbnailUrl" in field) {
2622
2653
  const section = new SectionBuilder();
2623
- if (field.name) {
2624
- section.addTextDisplayComponents(new TextDisplayBuilder().setContent(`__**${field.name}**__`));
2625
- }
2626
- section.addTextDisplayComponents(new TextDisplayBuilder().setContent(field.value));
2627
- if ("button" in field) {
2654
+ this.fieldAddText(section, { name: field.name, value: field.value });
2655
+ if ("button" in field && !Array.isArray(field.button)) {
2628
2656
  section.setButtonAccessory(field.button);
2629
2657
  } else if ("thumbnailUrl" in field) {
2630
2658
  section.setThumbnailAccessory(new ThumbnailBuilder().setURL(field.thumbnailUrl));
2631
2659
  }
2632
2660
  container.addSectionComponents(section);
2633
2661
  } else {
2634
- if (field.name) {
2635
- container.addTextDisplayComponents(new TextDisplayBuilder().setContent(`**${field.name}**`));
2636
- }
2637
- container.addTextDisplayComponents(new TextDisplayBuilder().setContent(field.value));
2662
+ this.fieldAddText(container, { name: field.name, value: field.value });
2638
2663
  }
2639
2664
  if (field.separator !== false) {
2640
2665
  container.addSeparatorComponents(this.separator(field.separator));
2641
2666
  }
2642
2667
  return container;
2643
2668
  }
2644
- /*static field(container: ContainerBuilder, field: ComponentManagerField): ContainerBuilder {
2645
- const section = new SectionBuilder()
2646
- .addTextDisplayComponents(
2647
- new TextDisplayBuilder().setContent(`**${field.name}**`),
2648
- new TextDisplayBuilder().setContent(field.value)
2649
- );
2650
-
2651
- if (field.thumbnailUrl) {
2652
- section.setThumbnailAccessory(
2653
- new ThumbnailBuilder().setURL(field.thumbnailUrl)
2654
- );
2655
- }
2656
-
2657
- if (field.button && field.button.length > 0) {
2658
- section.setButtonAccessory(field.button[0]!);
2659
- }
2660
-
2661
- container.addSectionComponents(section);
2662
- container.addSeparatorComponents(this.separator());
2663
- return container;
2664
- }*/
2665
2669
  /**
2666
2670
  * Multiple fields
2667
2671
  */
2668
2672
  static fields(container, fields) {
2669
- fields.forEach((f) => {
2670
- this.field(container, f);
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);
2671
2679
  });
2672
2680
  return container;
2673
2681
  }
@@ -2733,13 +2741,44 @@ var ComponentManager = class {
2733
2741
  flags: [MessageFlags4.IsComponentsV2]
2734
2742
  };
2735
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
+ }
2736
2775
  };
2737
2776
 
2738
2777
  // src/manager/interactions/ButtonManager.ts
2739
2778
  import {
2740
2779
  ButtonBuilder as ButtonBuilder2,
2741
2780
  ButtonStyle,
2742
- ActionRowBuilder as ActionRowBuilder4,
2781
+ ActionRowBuilder as ActionRowBuilder5,
2743
2782
  MessageFlags as MessageFlags5
2744
2783
  } from "discord.js";
2745
2784
  var ButtonManager = class _ButtonManager {
@@ -2775,7 +2814,7 @@ var ButtonManager = class _ButtonManager {
2775
2814
  }
2776
2815
  static row(but) {
2777
2816
  const buttons = Array.isArray(but) ? but.slice(0, 5) : [but];
2778
- return new ActionRowBuilder4().addComponents(buttons);
2817
+ return new ActionRowBuilder5().addComponents(buttons);
2779
2818
  }
2780
2819
  static toMessage(button) {
2781
2820
  return {
@@ -2788,13 +2827,18 @@ var ButtonManager = class _ButtonManager {
2788
2827
  flags: ephemeral ? [MessageFlags5.Ephemeral] : []
2789
2828
  };
2790
2829
  }
2830
+ static toInteractionEdit(button) {
2831
+ return {
2832
+ components: this.createRowsToReturn(button)
2833
+ };
2834
+ }
2791
2835
  static createRowsToReturn(button) {
2792
2836
  if (Array.isArray(button)) {
2793
2837
  return button.map(
2794
- (btn) => btn instanceof ActionRowBuilder4 ? btn : _ButtonManager.row(btn)
2838
+ (btn) => btn instanceof ActionRowBuilder5 ? btn : _ButtonManager.row(btn)
2795
2839
  );
2796
2840
  }
2797
- return button instanceof ActionRowBuilder4 ? [button] : [_ButtonManager.row(button)];
2841
+ return button instanceof ActionRowBuilder5 ? [button] : [_ButtonManager.row(button)];
2798
2842
  }
2799
2843
  };
2800
2844
 
@@ -2839,7 +2883,7 @@ var SimpleMutex = class {
2839
2883
  // package.json
2840
2884
  var package_default = {
2841
2885
  name: "@spatulox/simplediscordbot",
2842
- version: "1.5.2",
2886
+ version: "1.6.1",
2843
2887
  author: "Spatulox",
2844
2888
  description: "Simple discord bot framework to set up a bot under 30 secondes",
2845
2889
  exports: {
@@ -2900,7 +2944,6 @@ export {
2900
2944
  ButtonManager,
2901
2945
  ComponentManager,
2902
2946
  DiscordRegex,
2903
- EmbedColor,
2904
2947
  EmbedManager,
2905
2948
  FileManager,
2906
2949
  GuildManager,
@@ -2909,6 +2952,7 @@ export {
2909
2952
  ModalManager,
2910
2953
  ReactionManager,
2911
2954
  SelectMenuManager,
2955
+ SimpleColor,
2912
2956
  SimpleDiscordBotInfo,
2913
2957
  SimpleMutex,
2914
2958
  Time,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spatulox/simplediscordbot",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "author": "Spatulox",
5
5
  "description": "Simple discord bot framework to set up a bot under 30 secondes",
6
6
  "exports": {