@spatulox/simplediscordbot 1.5.2 → 1.6.1
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 +13 -6
- package/dist/index.d.ts +13 -6
- package/dist/index.js +48 -24
- package/dist/index.mjs +53 -29
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmbedBuilder, ActionRowBuilder, MessageActionRowComponentBuilder, Message, InteractionDeferReplyOptions, InteractionReplyOptions, InteractionEditReplyOptions, MessageCreateOptions, TextChannel, DMChannel, ThreadChannel, User, GuildMember, BaseInteraction, InteractionResponse, Client, ActivityType, WebhookMessageCreateOptions, EmojiResolvable, Guild, BanOptions, Snowflake, GuildBasedChannel, GuildChannelCreateOptions, ForumChannel, NewsChannel, StageChannel, StartThreadOptions, VoiceChannel, Invite, Channel, Collection, GuildBan, ModalBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, MentionableSelectMenuBuilder, ChannelSelectMenuBuilder, ChannelType, ContainerBuilder, ButtonBuilder, AttachmentBuilder } from 'discord.js';
|
|
1
|
+
import { EmbedBuilder, ActionRowBuilder, MessageActionRowComponentBuilder, Message, InteractionDeferReplyOptions, InteractionReplyOptions, InteractionEditReplyOptions, MessageCreateOptions, TextChannel, DMChannel, ThreadChannel, User, GuildMember, BaseInteraction, InteractionResponse, Client, ActivityType, WebhookMessageCreateOptions, EmojiResolvable, Guild, BanOptions, Snowflake, GuildBasedChannel, GuildChannelCreateOptions, ForumChannel, NewsChannel, StageChannel, StartThreadOptions, VoiceChannel, Invite, Channel, Collection, GuildBan, ModalBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, MentionableSelectMenuBuilder, ChannelSelectMenuBuilder, ChannelType, SeparatorSpacingSize, ContainerBuilder, ButtonBuilder, AttachmentBuilder, ButtonStyle } from 'discord.js';
|
|
2
2
|
|
|
3
3
|
type SendableComponent = EmbedBuilder | ActionRowBuilder<MessageActionRowComponentBuilder>;
|
|
4
4
|
|
|
@@ -555,6 +555,7 @@ declare enum ModalFieldType {
|
|
|
555
555
|
}
|
|
556
556
|
interface BaseModalField {
|
|
557
557
|
label: string;
|
|
558
|
+
value?: string;
|
|
558
559
|
required?: boolean;
|
|
559
560
|
}
|
|
560
561
|
interface TextModalField extends BaseModalField {
|
|
@@ -669,20 +670,23 @@ declare class SelectMenuManager {
|
|
|
669
670
|
}
|
|
670
671
|
|
|
671
672
|
interface BasicComponentManagerField {
|
|
672
|
-
name
|
|
673
|
+
name?: string;
|
|
673
674
|
value: string;
|
|
675
|
+
separator?: SeparatorSpacingSize | false;
|
|
674
676
|
}
|
|
675
677
|
interface ComponentManagerFieldThumbnail extends BasicComponentManagerField {
|
|
676
678
|
thumbnailUrl: string;
|
|
677
679
|
}
|
|
678
680
|
interface ComponentManagerFieldAccessory extends BasicComponentManagerField {
|
|
679
|
-
button: ButtonBuilder;
|
|
681
|
+
button: ButtonBuilder | ButtonBuilder[];
|
|
680
682
|
}
|
|
681
683
|
type ComponentManagerField = ComponentManagerFieldAccessory | ComponentManagerFieldThumbnail | BasicComponentManagerField;
|
|
682
684
|
interface ComponentManagerCreate {
|
|
683
685
|
title?: string | null;
|
|
686
|
+
description?: string | null;
|
|
684
687
|
color?: EmbedColor | null;
|
|
685
688
|
thumbnailUrl?: string;
|
|
689
|
+
separator?: SeparatorSpacingSize | false;
|
|
686
690
|
}
|
|
687
691
|
interface ComponentManagerFileInput {
|
|
688
692
|
buffer: Buffer;
|
|
@@ -715,6 +719,7 @@ declare class ComponentManager {
|
|
|
715
719
|
/**
|
|
716
720
|
* Quick field adder
|
|
717
721
|
*/
|
|
722
|
+
private static fieldAddText;
|
|
718
723
|
static field(container: ContainerBuilder, field: ComponentManagerField): ContainerBuilder;
|
|
719
724
|
/**
|
|
720
725
|
* Multiple fields
|
|
@@ -761,7 +766,9 @@ interface ButtonOptions {
|
|
|
761
766
|
disabled?: boolean;
|
|
762
767
|
}
|
|
763
768
|
declare class ButtonManager {
|
|
764
|
-
|
|
769
|
+
static create(options: ButtonOptions & {
|
|
770
|
+
style: ButtonStyle;
|
|
771
|
+
}): ButtonBuilder;
|
|
765
772
|
static primary(options: ButtonOptions): ButtonBuilder;
|
|
766
773
|
static success(options: ButtonOptions): ButtonBuilder;
|
|
767
774
|
static secondary(options: ButtonOptions): ButtonBuilder;
|
|
@@ -776,7 +783,7 @@ declare class ButtonManager {
|
|
|
776
783
|
static row(but: ButtonBuilder[]): ActionRowBuilder<ButtonBuilder>;
|
|
777
784
|
static toMessage(button: ButtonBuilder | ButtonBuilder[] | ActionRowBuilder<ButtonBuilder> | ActionRowBuilder<ButtonBuilder>[]): MessageCreateOptions;
|
|
778
785
|
static toInteraction(button: ButtonBuilder | ButtonBuilder[] | ActionRowBuilder<ButtonBuilder> | ActionRowBuilder<ButtonBuilder>[], ephemeral?: boolean): InteractionReplyOptions | InteractionEditReplyOptions;
|
|
779
|
-
private static
|
|
786
|
+
private static createRowsToReturn;
|
|
780
787
|
}
|
|
781
788
|
|
|
782
789
|
declare class UnitTime {
|
|
@@ -1064,4 +1071,4 @@ declare const SimpleDiscordBotInfo: {
|
|
|
1064
1071
|
license: string;
|
|
1065
1072
|
};
|
|
1066
1073
|
|
|
1067
|
-
export { Bot, type BotConfig, BotEnv, ButtonManager, ComponentManager, DiscordRegex, EmbedColor, EmbedManager, FileManager, GuildManager, Log, ModalManager, type RandomBotActivity, ReactionManager, SelectMenuManager, SimpleDiscordBotInfo, SimpleMutex, Time, UserManager, WebhookManager };
|
|
1074
|
+
export { Bot, type BotConfig, BotEnv, ButtonManager, ComponentManager, type ComponentManagerField, DiscordRegex, EmbedColor, EmbedManager, FileManager, GuildManager, Log, type ModalField, ModalFieldType, ModalManager, type RandomBotActivity, ReactionManager, SelectMenuManager, SimpleDiscordBotInfo, SimpleMutex, Time, UserManager, WebhookManager };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmbedBuilder, ActionRowBuilder, MessageActionRowComponentBuilder, Message, InteractionDeferReplyOptions, InteractionReplyOptions, InteractionEditReplyOptions, MessageCreateOptions, TextChannel, DMChannel, ThreadChannel, User, GuildMember, BaseInteraction, InteractionResponse, Client, ActivityType, WebhookMessageCreateOptions, EmojiResolvable, Guild, BanOptions, Snowflake, GuildBasedChannel, GuildChannelCreateOptions, ForumChannel, NewsChannel, StageChannel, StartThreadOptions, VoiceChannel, Invite, Channel, Collection, GuildBan, ModalBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, MentionableSelectMenuBuilder, ChannelSelectMenuBuilder, ChannelType, ContainerBuilder, ButtonBuilder, AttachmentBuilder } from 'discord.js';
|
|
1
|
+
import { EmbedBuilder, ActionRowBuilder, MessageActionRowComponentBuilder, Message, InteractionDeferReplyOptions, InteractionReplyOptions, InteractionEditReplyOptions, MessageCreateOptions, TextChannel, DMChannel, ThreadChannel, User, GuildMember, BaseInteraction, InteractionResponse, Client, ActivityType, WebhookMessageCreateOptions, EmojiResolvable, Guild, BanOptions, Snowflake, GuildBasedChannel, GuildChannelCreateOptions, ForumChannel, NewsChannel, StageChannel, StartThreadOptions, VoiceChannel, Invite, Channel, Collection, GuildBan, ModalBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, MentionableSelectMenuBuilder, ChannelSelectMenuBuilder, ChannelType, SeparatorSpacingSize, ContainerBuilder, ButtonBuilder, AttachmentBuilder, ButtonStyle } from 'discord.js';
|
|
2
2
|
|
|
3
3
|
type SendableComponent = EmbedBuilder | ActionRowBuilder<MessageActionRowComponentBuilder>;
|
|
4
4
|
|
|
@@ -555,6 +555,7 @@ declare enum ModalFieldType {
|
|
|
555
555
|
}
|
|
556
556
|
interface BaseModalField {
|
|
557
557
|
label: string;
|
|
558
|
+
value?: string;
|
|
558
559
|
required?: boolean;
|
|
559
560
|
}
|
|
560
561
|
interface TextModalField extends BaseModalField {
|
|
@@ -669,20 +670,23 @@ declare class SelectMenuManager {
|
|
|
669
670
|
}
|
|
670
671
|
|
|
671
672
|
interface BasicComponentManagerField {
|
|
672
|
-
name
|
|
673
|
+
name?: string;
|
|
673
674
|
value: string;
|
|
675
|
+
separator?: SeparatorSpacingSize | false;
|
|
674
676
|
}
|
|
675
677
|
interface ComponentManagerFieldThumbnail extends BasicComponentManagerField {
|
|
676
678
|
thumbnailUrl: string;
|
|
677
679
|
}
|
|
678
680
|
interface ComponentManagerFieldAccessory extends BasicComponentManagerField {
|
|
679
|
-
button: ButtonBuilder;
|
|
681
|
+
button: ButtonBuilder | ButtonBuilder[];
|
|
680
682
|
}
|
|
681
683
|
type ComponentManagerField = ComponentManagerFieldAccessory | ComponentManagerFieldThumbnail | BasicComponentManagerField;
|
|
682
684
|
interface ComponentManagerCreate {
|
|
683
685
|
title?: string | null;
|
|
686
|
+
description?: string | null;
|
|
684
687
|
color?: EmbedColor | null;
|
|
685
688
|
thumbnailUrl?: string;
|
|
689
|
+
separator?: SeparatorSpacingSize | false;
|
|
686
690
|
}
|
|
687
691
|
interface ComponentManagerFileInput {
|
|
688
692
|
buffer: Buffer;
|
|
@@ -715,6 +719,7 @@ declare class ComponentManager {
|
|
|
715
719
|
/**
|
|
716
720
|
* Quick field adder
|
|
717
721
|
*/
|
|
722
|
+
private static fieldAddText;
|
|
718
723
|
static field(container: ContainerBuilder, field: ComponentManagerField): ContainerBuilder;
|
|
719
724
|
/**
|
|
720
725
|
* Multiple fields
|
|
@@ -761,7 +766,9 @@ interface ButtonOptions {
|
|
|
761
766
|
disabled?: boolean;
|
|
762
767
|
}
|
|
763
768
|
declare class ButtonManager {
|
|
764
|
-
|
|
769
|
+
static create(options: ButtonOptions & {
|
|
770
|
+
style: ButtonStyle;
|
|
771
|
+
}): ButtonBuilder;
|
|
765
772
|
static primary(options: ButtonOptions): ButtonBuilder;
|
|
766
773
|
static success(options: ButtonOptions): ButtonBuilder;
|
|
767
774
|
static secondary(options: ButtonOptions): ButtonBuilder;
|
|
@@ -776,7 +783,7 @@ declare class ButtonManager {
|
|
|
776
783
|
static row(but: ButtonBuilder[]): ActionRowBuilder<ButtonBuilder>;
|
|
777
784
|
static toMessage(button: ButtonBuilder | ButtonBuilder[] | ActionRowBuilder<ButtonBuilder> | ActionRowBuilder<ButtonBuilder>[]): MessageCreateOptions;
|
|
778
785
|
static toInteraction(button: ButtonBuilder | ButtonBuilder[] | ActionRowBuilder<ButtonBuilder> | ActionRowBuilder<ButtonBuilder>[], ephemeral?: boolean): InteractionReplyOptions | InteractionEditReplyOptions;
|
|
779
|
-
private static
|
|
786
|
+
private static createRowsToReturn;
|
|
780
787
|
}
|
|
781
788
|
|
|
782
789
|
declare class UnitTime {
|
|
@@ -1064,4 +1071,4 @@ declare const SimpleDiscordBotInfo: {
|
|
|
1064
1071
|
license: string;
|
|
1065
1072
|
};
|
|
1066
1073
|
|
|
1067
|
-
export { Bot, type BotConfig, BotEnv, ButtonManager, ComponentManager, DiscordRegex, EmbedColor, EmbedManager, FileManager, GuildManager, Log, ModalManager, type RandomBotActivity, ReactionManager, SelectMenuManager, SimpleDiscordBotInfo, SimpleMutex, Time, UserManager, WebhookManager };
|
|
1074
|
+
export { Bot, type BotConfig, BotEnv, ButtonManager, ComponentManager, type ComponentManagerField, DiscordRegex, EmbedColor, EmbedManager, FileManager, GuildManager, Log, type ModalField, ModalFieldType, ModalManager, type RandomBotActivity, ReactionManager, SelectMenuManager, SimpleDiscordBotInfo, SimpleMutex, Time, UserManager, WebhookManager };
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,7 @@ __export(index_exports, {
|
|
|
40
40
|
FileManager: () => FileManager,
|
|
41
41
|
GuildManager: () => GuildManager,
|
|
42
42
|
Log: () => Log,
|
|
43
|
+
ModalFieldType: () => ModalFieldType,
|
|
43
44
|
ModalManager: () => ModalManager,
|
|
44
45
|
ReactionManager: () => ReactionManager,
|
|
45
46
|
SelectMenuManager: () => SelectMenuManager,
|
|
@@ -2287,6 +2288,14 @@ var UserManager = class extends BasicUserManager {
|
|
|
2287
2288
|
|
|
2288
2289
|
// src/manager/interactions/ModalManager.ts
|
|
2289
2290
|
var import_discord15 = require("discord.js");
|
|
2291
|
+
var ModalFieldType = /* @__PURE__ */ ((ModalFieldType2) => {
|
|
2292
|
+
ModalFieldType2[ModalFieldType2["SHORT"] = 0] = "SHORT";
|
|
2293
|
+
ModalFieldType2[ModalFieldType2["LONG"] = 1] = "LONG";
|
|
2294
|
+
ModalFieldType2[ModalFieldType2["NUMBER"] = 2] = "NUMBER";
|
|
2295
|
+
ModalFieldType2[ModalFieldType2["DATE"] = 3] = "DATE";
|
|
2296
|
+
ModalFieldType2[ModalFieldType2["PHONE"] = 4] = "PHONE";
|
|
2297
|
+
return ModalFieldType2;
|
|
2298
|
+
})(ModalFieldType || {});
|
|
2290
2299
|
var ModalManager = class {
|
|
2291
2300
|
/**
|
|
2292
2301
|
* Creates base Modal - SIMPLE API !
|
|
@@ -2299,6 +2308,9 @@ var ModalManager = class {
|
|
|
2299
2308
|
*/
|
|
2300
2309
|
static _createField(opt) {
|
|
2301
2310
|
const builder = new import_discord15.TextInputBuilder().setCustomId(opt.customId).setRequired(opt.required ?? false);
|
|
2311
|
+
if (opt.value) {
|
|
2312
|
+
builder.setValue(opt.value);
|
|
2313
|
+
}
|
|
2302
2314
|
if (opt.placeholder) {
|
|
2303
2315
|
builder.setPlaceholder(opt.placeholder);
|
|
2304
2316
|
} else {
|
|
@@ -2331,7 +2343,8 @@ var ModalManager = class {
|
|
|
2331
2343
|
const opt = {
|
|
2332
2344
|
...field,
|
|
2333
2345
|
customId: `${customId}_input`,
|
|
2334
|
-
placeholder: "placeholder" in field && field.placeholder ? field.placeholder : `Enter ${field.label.toLowerCase()}
|
|
2346
|
+
placeholder: "placeholder" in field && field.placeholder ? field.placeholder : `Enter ${field.label.toLowerCase()}`,
|
|
2347
|
+
value: field.value
|
|
2335
2348
|
};
|
|
2336
2349
|
modal.addLabelComponents(this._createField(opt));
|
|
2337
2350
|
return modal;
|
|
@@ -2562,7 +2575,7 @@ var ComponentManager = class {
|
|
|
2562
2575
|
if (option?.thumbnailUrl) {
|
|
2563
2576
|
const headerSection = new import_discord17.SectionBuilder().addTextDisplayComponents(
|
|
2564
2577
|
new import_discord17.TextDisplayBuilder().setContent(
|
|
2565
|
-
option?.title ?
|
|
2578
|
+
option?.title ? option.title : "\u200B"
|
|
2566
2579
|
)
|
|
2567
2580
|
).setThumbnailAccessory(
|
|
2568
2581
|
new import_discord17.ThumbnailBuilder().setURL(option.thumbnailUrl)
|
|
@@ -2570,10 +2583,15 @@ var ComponentManager = class {
|
|
|
2570
2583
|
container.addSectionComponents(headerSection);
|
|
2571
2584
|
} else {
|
|
2572
2585
|
container.addTextDisplayComponents(
|
|
2573
|
-
new import_discord17.TextDisplayBuilder().setContent(
|
|
2586
|
+
new import_discord17.TextDisplayBuilder().setContent(option.title)
|
|
2574
2587
|
);
|
|
2575
2588
|
}
|
|
2576
|
-
|
|
2589
|
+
if (option?.description) {
|
|
2590
|
+
container.addTextDisplayComponents(new import_discord17.TextDisplayBuilder().setContent(option.description));
|
|
2591
|
+
}
|
|
2592
|
+
if (option?.separator) {
|
|
2593
|
+
container.addSeparatorComponents(this.separator(option.separator));
|
|
2594
|
+
}
|
|
2577
2595
|
}
|
|
2578
2596
|
return container;
|
|
2579
2597
|
}
|
|
@@ -2611,25 +2629,30 @@ var ComponentManager = class {
|
|
|
2611
2629
|
/**
|
|
2612
2630
|
* Quick field adder
|
|
2613
2631
|
*/
|
|
2632
|
+
static fieldAddText(container, options) {
|
|
2633
|
+
options.name && container.addTextDisplayComponents(new import_discord17.TextDisplayBuilder().setContent(`__**${options.name}**__`));
|
|
2634
|
+
container.addTextDisplayComponents(new import_discord17.TextDisplayBuilder().setContent(options.value));
|
|
2635
|
+
}
|
|
2614
2636
|
static field(container, field) {
|
|
2615
|
-
if ("button" in field
|
|
2616
|
-
const
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2637
|
+
if ("button" in field && Array.isArray(field.button) && field.button.length > 0) {
|
|
2638
|
+
const actionRow = new import_discord17.ActionRowBuilder().addComponents(field.button);
|
|
2639
|
+
this.fieldAddText(container, { name: field.name, value: field.value });
|
|
2640
|
+
container.addActionRowComponents(actionRow);
|
|
2641
|
+
} else if ("button" in field && !Array.isArray(field.button) || "thumbnailUrl" in field) {
|
|
2642
|
+
const section = new import_discord17.SectionBuilder();
|
|
2643
|
+
this.fieldAddText(section, { name: field.name, value: field.value });
|
|
2644
|
+
if ("button" in field && !Array.isArray(field.button)) {
|
|
2621
2645
|
section.setButtonAccessory(field.button);
|
|
2622
2646
|
} else if ("thumbnailUrl" in field) {
|
|
2623
2647
|
section.setThumbnailAccessory(new import_discord17.ThumbnailBuilder().setURL(field.thumbnailUrl));
|
|
2624
2648
|
}
|
|
2625
2649
|
container.addSectionComponents(section);
|
|
2626
2650
|
} else {
|
|
2627
|
-
container.
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
);
|
|
2651
|
+
this.fieldAddText(container, { name: field.name, value: field.value });
|
|
2652
|
+
}
|
|
2653
|
+
if (field.separator !== false) {
|
|
2654
|
+
container.addSeparatorComponents(this.separator(field.separator));
|
|
2631
2655
|
}
|
|
2632
|
-
container.addSeparatorComponents(this.separator());
|
|
2633
2656
|
return container;
|
|
2634
2657
|
}
|
|
2635
2658
|
/*static field(container: ContainerBuilder, field: ComponentManagerField): ContainerBuilder {
|
|
@@ -2729,7 +2752,7 @@ var ComponentManager = class {
|
|
|
2729
2752
|
// src/manager/interactions/ButtonManager.ts
|
|
2730
2753
|
var import_discord18 = require("discord.js");
|
|
2731
2754
|
var ButtonManager = class _ButtonManager {
|
|
2732
|
-
static
|
|
2755
|
+
static create(options) {
|
|
2733
2756
|
const btn = new import_discord18.ButtonBuilder().setCustomId(options.customId).setLabel(options.label ?? "Button").setStyle(options.style).setDisabled(options.disabled ?? false);
|
|
2734
2757
|
if (options.emoji) {
|
|
2735
2758
|
btn.setEmoji(options.emoji);
|
|
@@ -2737,16 +2760,16 @@ var ButtonManager = class _ButtonManager {
|
|
|
2737
2760
|
return btn;
|
|
2738
2761
|
}
|
|
2739
2762
|
static primary(options) {
|
|
2740
|
-
return this.
|
|
2763
|
+
return this.create({ ...options, style: import_discord18.ButtonStyle.Primary });
|
|
2741
2764
|
}
|
|
2742
2765
|
static success(options) {
|
|
2743
|
-
return this.
|
|
2766
|
+
return this.create({ ...options, style: import_discord18.ButtonStyle.Success });
|
|
2744
2767
|
}
|
|
2745
2768
|
static secondary(options) {
|
|
2746
|
-
return this.
|
|
2769
|
+
return this.create({ ...options, style: import_discord18.ButtonStyle.Secondary });
|
|
2747
2770
|
}
|
|
2748
2771
|
static danger(options) {
|
|
2749
|
-
return this.
|
|
2772
|
+
return this.create({ ...options, style: import_discord18.ButtonStyle.Danger });
|
|
2750
2773
|
}
|
|
2751
2774
|
static link(options) {
|
|
2752
2775
|
const btn = new import_discord18.ButtonBuilder().setLabel(options.label).setStyle(import_discord18.ButtonStyle.Link).setURL(options.url);
|
|
@@ -2765,16 +2788,16 @@ var ButtonManager = class _ButtonManager {
|
|
|
2765
2788
|
}
|
|
2766
2789
|
static toMessage(button) {
|
|
2767
2790
|
return {
|
|
2768
|
-
components: this.
|
|
2791
|
+
components: this.createRowsToReturn(button)
|
|
2769
2792
|
};
|
|
2770
2793
|
}
|
|
2771
2794
|
static toInteraction(button, ephemeral = false) {
|
|
2772
2795
|
return {
|
|
2773
|
-
components: this.
|
|
2796
|
+
components: this.createRowsToReturn(button),
|
|
2774
2797
|
flags: ephemeral ? [import_discord18.MessageFlags.Ephemeral] : []
|
|
2775
2798
|
};
|
|
2776
2799
|
}
|
|
2777
|
-
static
|
|
2800
|
+
static createRowsToReturn(button) {
|
|
2778
2801
|
if (Array.isArray(button)) {
|
|
2779
2802
|
return button.map(
|
|
2780
2803
|
(btn) => btn instanceof import_discord18.ActionRowBuilder ? btn : _ButtonManager.row(btn)
|
|
@@ -2825,7 +2848,7 @@ var SimpleMutex = class {
|
|
|
2825
2848
|
// package.json
|
|
2826
2849
|
var package_default = {
|
|
2827
2850
|
name: "@spatulox/simplediscordbot",
|
|
2828
|
-
version: "1.
|
|
2851
|
+
version: "1.6.0",
|
|
2829
2852
|
author: "Spatulox",
|
|
2830
2853
|
description: "Simple discord bot framework to set up a bot under 30 secondes",
|
|
2831
2854
|
exports: {
|
|
@@ -2892,6 +2915,7 @@ var SimpleDiscordBotInfo = {
|
|
|
2892
2915
|
FileManager,
|
|
2893
2916
|
GuildManager,
|
|
2894
2917
|
Log,
|
|
2918
|
+
ModalFieldType,
|
|
2895
2919
|
ModalManager,
|
|
2896
2920
|
ReactionManager,
|
|
2897
2921
|
SelectMenuManager,
|
package/dist/index.mjs
CHANGED
|
@@ -2255,6 +2255,14 @@ import {
|
|
|
2255
2255
|
TextInputStyle,
|
|
2256
2256
|
LabelBuilder
|
|
2257
2257
|
} from "discord.js";
|
|
2258
|
+
var ModalFieldType = /* @__PURE__ */ ((ModalFieldType2) => {
|
|
2259
|
+
ModalFieldType2[ModalFieldType2["SHORT"] = 0] = "SHORT";
|
|
2260
|
+
ModalFieldType2[ModalFieldType2["LONG"] = 1] = "LONG";
|
|
2261
|
+
ModalFieldType2[ModalFieldType2["NUMBER"] = 2] = "NUMBER";
|
|
2262
|
+
ModalFieldType2[ModalFieldType2["DATE"] = 3] = "DATE";
|
|
2263
|
+
ModalFieldType2[ModalFieldType2["PHONE"] = 4] = "PHONE";
|
|
2264
|
+
return ModalFieldType2;
|
|
2265
|
+
})(ModalFieldType || {});
|
|
2258
2266
|
var ModalManager = class {
|
|
2259
2267
|
/**
|
|
2260
2268
|
* Creates base Modal - SIMPLE API !
|
|
@@ -2267,6 +2275,9 @@ var ModalManager = class {
|
|
|
2267
2275
|
*/
|
|
2268
2276
|
static _createField(opt) {
|
|
2269
2277
|
const builder = new TextInputBuilder().setCustomId(opt.customId).setRequired(opt.required ?? false);
|
|
2278
|
+
if (opt.value) {
|
|
2279
|
+
builder.setValue(opt.value);
|
|
2280
|
+
}
|
|
2270
2281
|
if (opt.placeholder) {
|
|
2271
2282
|
builder.setPlaceholder(opt.placeholder);
|
|
2272
2283
|
} else {
|
|
@@ -2299,7 +2310,8 @@ var ModalManager = class {
|
|
|
2299
2310
|
const opt = {
|
|
2300
2311
|
...field,
|
|
2301
2312
|
customId: `${customId}_input`,
|
|
2302
|
-
placeholder: "placeholder" in field && field.placeholder ? field.placeholder : `Enter ${field.label.toLowerCase()}
|
|
2313
|
+
placeholder: "placeholder" in field && field.placeholder ? field.placeholder : `Enter ${field.label.toLowerCase()}`,
|
|
2314
|
+
value: field.value
|
|
2303
2315
|
};
|
|
2304
2316
|
modal.addLabelComponents(this._createField(opt));
|
|
2305
2317
|
return modal;
|
|
@@ -2532,7 +2544,8 @@ import {
|
|
|
2532
2544
|
MediaGalleryBuilder,
|
|
2533
2545
|
MediaGalleryItemBuilder,
|
|
2534
2546
|
AttachmentBuilder,
|
|
2535
|
-
FileBuilder
|
|
2547
|
+
FileBuilder,
|
|
2548
|
+
ActionRowBuilder as ActionRowBuilder4
|
|
2536
2549
|
} from "discord.js";
|
|
2537
2550
|
var ComponentManager = class {
|
|
2538
2551
|
static get DEFAULT_COLOR() {
|
|
@@ -2551,7 +2564,7 @@ var ComponentManager = class {
|
|
|
2551
2564
|
if (option?.thumbnailUrl) {
|
|
2552
2565
|
const headerSection = new SectionBuilder().addTextDisplayComponents(
|
|
2553
2566
|
new TextDisplayBuilder().setContent(
|
|
2554
|
-
option?.title ?
|
|
2567
|
+
option?.title ? option.title : "\u200B"
|
|
2555
2568
|
)
|
|
2556
2569
|
).setThumbnailAccessory(
|
|
2557
2570
|
new ThumbnailBuilder().setURL(option.thumbnailUrl)
|
|
@@ -2559,10 +2572,15 @@ var ComponentManager = class {
|
|
|
2559
2572
|
container.addSectionComponents(headerSection);
|
|
2560
2573
|
} else {
|
|
2561
2574
|
container.addTextDisplayComponents(
|
|
2562
|
-
new TextDisplayBuilder().setContent(
|
|
2575
|
+
new TextDisplayBuilder().setContent(option.title)
|
|
2563
2576
|
);
|
|
2564
2577
|
}
|
|
2565
|
-
|
|
2578
|
+
if (option?.description) {
|
|
2579
|
+
container.addTextDisplayComponents(new TextDisplayBuilder().setContent(option.description));
|
|
2580
|
+
}
|
|
2581
|
+
if (option?.separator) {
|
|
2582
|
+
container.addSeparatorComponents(this.separator(option.separator));
|
|
2583
|
+
}
|
|
2566
2584
|
}
|
|
2567
2585
|
return container;
|
|
2568
2586
|
}
|
|
@@ -2600,25 +2618,30 @@ var ComponentManager = class {
|
|
|
2600
2618
|
/**
|
|
2601
2619
|
* Quick field adder
|
|
2602
2620
|
*/
|
|
2621
|
+
static fieldAddText(container, options) {
|
|
2622
|
+
options.name && container.addTextDisplayComponents(new TextDisplayBuilder().setContent(`__**${options.name}**__`));
|
|
2623
|
+
container.addTextDisplayComponents(new TextDisplayBuilder().setContent(options.value));
|
|
2624
|
+
}
|
|
2603
2625
|
static field(container, field) {
|
|
2604
|
-
if ("button" in field
|
|
2605
|
-
const
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2626
|
+
if ("button" in field && Array.isArray(field.button) && field.button.length > 0) {
|
|
2627
|
+
const actionRow = new ActionRowBuilder4().addComponents(field.button);
|
|
2628
|
+
this.fieldAddText(container, { name: field.name, value: field.value });
|
|
2629
|
+
container.addActionRowComponents(actionRow);
|
|
2630
|
+
} else if ("button" in field && !Array.isArray(field.button) || "thumbnailUrl" in field) {
|
|
2631
|
+
const section = new SectionBuilder();
|
|
2632
|
+
this.fieldAddText(section, { name: field.name, value: field.value });
|
|
2633
|
+
if ("button" in field && !Array.isArray(field.button)) {
|
|
2610
2634
|
section.setButtonAccessory(field.button);
|
|
2611
2635
|
} else if ("thumbnailUrl" in field) {
|
|
2612
2636
|
section.setThumbnailAccessory(new ThumbnailBuilder().setURL(field.thumbnailUrl));
|
|
2613
2637
|
}
|
|
2614
2638
|
container.addSectionComponents(section);
|
|
2615
2639
|
} else {
|
|
2616
|
-
container.
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
);
|
|
2640
|
+
this.fieldAddText(container, { name: field.name, value: field.value });
|
|
2641
|
+
}
|
|
2642
|
+
if (field.separator !== false) {
|
|
2643
|
+
container.addSeparatorComponents(this.separator(field.separator));
|
|
2620
2644
|
}
|
|
2621
|
-
container.addSeparatorComponents(this.separator());
|
|
2622
2645
|
return container;
|
|
2623
2646
|
}
|
|
2624
2647
|
/*static field(container: ContainerBuilder, field: ComponentManagerField): ContainerBuilder {
|
|
@@ -2719,11 +2742,11 @@ var ComponentManager = class {
|
|
|
2719
2742
|
import {
|
|
2720
2743
|
ButtonBuilder as ButtonBuilder2,
|
|
2721
2744
|
ButtonStyle,
|
|
2722
|
-
ActionRowBuilder as
|
|
2745
|
+
ActionRowBuilder as ActionRowBuilder5,
|
|
2723
2746
|
MessageFlags as MessageFlags5
|
|
2724
2747
|
} from "discord.js";
|
|
2725
2748
|
var ButtonManager = class _ButtonManager {
|
|
2726
|
-
static
|
|
2749
|
+
static create(options) {
|
|
2727
2750
|
const btn = new ButtonBuilder2().setCustomId(options.customId).setLabel(options.label ?? "Button").setStyle(options.style).setDisabled(options.disabled ?? false);
|
|
2728
2751
|
if (options.emoji) {
|
|
2729
2752
|
btn.setEmoji(options.emoji);
|
|
@@ -2731,16 +2754,16 @@ var ButtonManager = class _ButtonManager {
|
|
|
2731
2754
|
return btn;
|
|
2732
2755
|
}
|
|
2733
2756
|
static primary(options) {
|
|
2734
|
-
return this.
|
|
2757
|
+
return this.create({ ...options, style: ButtonStyle.Primary });
|
|
2735
2758
|
}
|
|
2736
2759
|
static success(options) {
|
|
2737
|
-
return this.
|
|
2760
|
+
return this.create({ ...options, style: ButtonStyle.Success });
|
|
2738
2761
|
}
|
|
2739
2762
|
static secondary(options) {
|
|
2740
|
-
return this.
|
|
2763
|
+
return this.create({ ...options, style: ButtonStyle.Secondary });
|
|
2741
2764
|
}
|
|
2742
2765
|
static danger(options) {
|
|
2743
|
-
return this.
|
|
2766
|
+
return this.create({ ...options, style: ButtonStyle.Danger });
|
|
2744
2767
|
}
|
|
2745
2768
|
static link(options) {
|
|
2746
2769
|
const btn = new ButtonBuilder2().setLabel(options.label).setStyle(ButtonStyle.Link).setURL(options.url);
|
|
@@ -2755,26 +2778,26 @@ var ButtonManager = class _ButtonManager {
|
|
|
2755
2778
|
}
|
|
2756
2779
|
static row(but) {
|
|
2757
2780
|
const buttons = Array.isArray(but) ? but.slice(0, 5) : [but];
|
|
2758
|
-
return new
|
|
2781
|
+
return new ActionRowBuilder5().addComponents(buttons);
|
|
2759
2782
|
}
|
|
2760
2783
|
static toMessage(button) {
|
|
2761
2784
|
return {
|
|
2762
|
-
components: this.
|
|
2785
|
+
components: this.createRowsToReturn(button)
|
|
2763
2786
|
};
|
|
2764
2787
|
}
|
|
2765
2788
|
static toInteraction(button, ephemeral = false) {
|
|
2766
2789
|
return {
|
|
2767
|
-
components: this.
|
|
2790
|
+
components: this.createRowsToReturn(button),
|
|
2768
2791
|
flags: ephemeral ? [MessageFlags5.Ephemeral] : []
|
|
2769
2792
|
};
|
|
2770
2793
|
}
|
|
2771
|
-
static
|
|
2794
|
+
static createRowsToReturn(button) {
|
|
2772
2795
|
if (Array.isArray(button)) {
|
|
2773
2796
|
return button.map(
|
|
2774
|
-
(btn) => btn instanceof
|
|
2797
|
+
(btn) => btn instanceof ActionRowBuilder5 ? btn : _ButtonManager.row(btn)
|
|
2775
2798
|
);
|
|
2776
2799
|
}
|
|
2777
|
-
return button instanceof
|
|
2800
|
+
return button instanceof ActionRowBuilder5 ? [button] : [_ButtonManager.row(button)];
|
|
2778
2801
|
}
|
|
2779
2802
|
};
|
|
2780
2803
|
|
|
@@ -2819,7 +2842,7 @@ var SimpleMutex = class {
|
|
|
2819
2842
|
// package.json
|
|
2820
2843
|
var package_default = {
|
|
2821
2844
|
name: "@spatulox/simplediscordbot",
|
|
2822
|
-
version: "1.
|
|
2845
|
+
version: "1.6.0",
|
|
2823
2846
|
author: "Spatulox",
|
|
2824
2847
|
description: "Simple discord bot framework to set up a bot under 30 secondes",
|
|
2825
2848
|
exports: {
|
|
@@ -2885,6 +2908,7 @@ export {
|
|
|
2885
2908
|
FileManager,
|
|
2886
2909
|
GuildManager,
|
|
2887
2910
|
Log,
|
|
2911
|
+
ModalFieldType,
|
|
2888
2912
|
ModalManager,
|
|
2889
2913
|
ReactionManager,
|
|
2890
2914
|
SelectMenuManager,
|