@magicyan/discord 1.7.1 → 1.7.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/dist/functions/components/checkbox.cjs +34 -0
- package/dist/functions/components/checkbox.mjs +31 -0
- package/dist/functions/components/modal.cjs +12 -0
- package/dist/functions/components/modal.mjs +12 -0
- package/dist/functions/components/radio.cjs +15 -0
- package/dist/functions/components/radio.mjs +13 -0
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts +152 -39
- package/dist/index.d.mts +152 -39
- package/dist/index.d.ts +152 -39
- package/dist/index.mjs +2 -0
- package/package.json +3 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
|
|
5
|
+
function createCheckbox(a, b, c) {
|
|
6
|
+
const builder = new discord_js.CheckboxBuilder();
|
|
7
|
+
if (typeof a === "string") {
|
|
8
|
+
Object.assign(builder.data, {
|
|
9
|
+
custom_id: a,
|
|
10
|
+
default: b,
|
|
11
|
+
id: c
|
|
12
|
+
});
|
|
13
|
+
return builder;
|
|
14
|
+
}
|
|
15
|
+
Object.assign(builder.data, {
|
|
16
|
+
...a,
|
|
17
|
+
custom_id: a.customId
|
|
18
|
+
});
|
|
19
|
+
return builder;
|
|
20
|
+
}
|
|
21
|
+
function createCheckboxGroup(data) {
|
|
22
|
+
const builder = new discord_js.CheckboxGroupBuilder();
|
|
23
|
+
Object.assign(builder.data, {
|
|
24
|
+
...data,
|
|
25
|
+
custom_id: data.customId,
|
|
26
|
+
max_values: data.maxValues,
|
|
27
|
+
min_values: data.minValues
|
|
28
|
+
});
|
|
29
|
+
builder.setOptions(...data.options);
|
|
30
|
+
return builder;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.createCheckbox = createCheckbox;
|
|
34
|
+
exports.createCheckboxGroup = createCheckboxGroup;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CheckboxBuilder, CheckboxGroupBuilder } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
function createCheckbox(a, b, c) {
|
|
4
|
+
const builder = new CheckboxBuilder();
|
|
5
|
+
if (typeof a === "string") {
|
|
6
|
+
Object.assign(builder.data, {
|
|
7
|
+
custom_id: a,
|
|
8
|
+
default: b,
|
|
9
|
+
id: c
|
|
10
|
+
});
|
|
11
|
+
return builder;
|
|
12
|
+
}
|
|
13
|
+
Object.assign(builder.data, {
|
|
14
|
+
...a,
|
|
15
|
+
custom_id: a.customId
|
|
16
|
+
});
|
|
17
|
+
return builder;
|
|
18
|
+
}
|
|
19
|
+
function createCheckboxGroup(data) {
|
|
20
|
+
const builder = new CheckboxGroupBuilder();
|
|
21
|
+
Object.assign(builder.data, {
|
|
22
|
+
...data,
|
|
23
|
+
custom_id: data.customId,
|
|
24
|
+
max_values: data.maxValues,
|
|
25
|
+
min_values: data.minValues
|
|
26
|
+
});
|
|
27
|
+
builder.setOptions(...data.options);
|
|
28
|
+
return builder;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { createCheckbox, createCheckboxGroup };
|
|
@@ -15,6 +15,18 @@ function modalFieldsToRecord(data, parse) {
|
|
|
15
15
|
acc[data2.customId] = Array.from(attachments?.values() ?? []).map((data3) => data3.url);
|
|
16
16
|
return acc;
|
|
17
17
|
}
|
|
18
|
+
if (data2.type === discord_js.ComponentType.CheckboxGroup) {
|
|
19
|
+
acc[data2.customId] = Array.from(data2.values);
|
|
20
|
+
return acc;
|
|
21
|
+
}
|
|
22
|
+
if (data2.type === discord_js.ComponentType.Checkbox) {
|
|
23
|
+
acc[data2.customId] = data2.value;
|
|
24
|
+
return acc;
|
|
25
|
+
}
|
|
26
|
+
if (data2.type === discord_js.ComponentType.RadioGroup) {
|
|
27
|
+
acc[data2.customId] = data2.value;
|
|
28
|
+
return acc;
|
|
29
|
+
}
|
|
18
30
|
acc[data2.customId] = Array.from(data2.values ?? []);
|
|
19
31
|
return acc;
|
|
20
32
|
}, {});
|
|
@@ -13,6 +13,18 @@ function modalFieldsToRecord(data, parse) {
|
|
|
13
13
|
acc[data2.customId] = Array.from(attachments?.values() ?? []).map((data3) => data3.url);
|
|
14
14
|
return acc;
|
|
15
15
|
}
|
|
16
|
+
if (data2.type === ComponentType.CheckboxGroup) {
|
|
17
|
+
acc[data2.customId] = Array.from(data2.values);
|
|
18
|
+
return acc;
|
|
19
|
+
}
|
|
20
|
+
if (data2.type === ComponentType.Checkbox) {
|
|
21
|
+
acc[data2.customId] = data2.value;
|
|
22
|
+
return acc;
|
|
23
|
+
}
|
|
24
|
+
if (data2.type === ComponentType.RadioGroup) {
|
|
25
|
+
acc[data2.customId] = data2.value;
|
|
26
|
+
return acc;
|
|
27
|
+
}
|
|
16
28
|
acc[data2.customId] = Array.from(data2.values ?? []);
|
|
17
29
|
return acc;
|
|
18
30
|
}, {});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
|
|
5
|
+
function createRadioGroup(data) {
|
|
6
|
+
const builder = new discord_js.RadioGroupBuilder();
|
|
7
|
+
Object.assign(builder.data, {
|
|
8
|
+
...data,
|
|
9
|
+
custom_id: data.customId
|
|
10
|
+
});
|
|
11
|
+
builder.setOptions(...data.options);
|
|
12
|
+
return builder;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.createRadioGroup = createRadioGroup;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RadioGroupBuilder } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
function createRadioGroup(data) {
|
|
4
|
+
const builder = new RadioGroupBuilder();
|
|
5
|
+
Object.assign(builder.data, {
|
|
6
|
+
...data,
|
|
7
|
+
custom_id: data.customId
|
|
8
|
+
});
|
|
9
|
+
builder.setOptions(...data.options);
|
|
10
|
+
return builder;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { createRadioGroup };
|
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,8 @@ const text = require('./functions/components/text.cjs');
|
|
|
28
28
|
const thumbarea = require('./functions/components/thumbarea.cjs');
|
|
29
29
|
const thumbnail = require('./functions/components/thumbnail.cjs');
|
|
30
30
|
const upload = require('./functions/components/upload.cjs');
|
|
31
|
+
const checkbox = require('./functions/components/checkbox.cjs');
|
|
32
|
+
const radio = require('./functions/components/radio.cjs');
|
|
31
33
|
const assets = require('./functions/embeds/assets.cjs');
|
|
32
34
|
const author = require('./functions/embeds/author.cjs');
|
|
33
35
|
const embedplus = require('./functions/embeds/embedplus.cjs');
|
|
@@ -88,6 +90,9 @@ exports.createTextDisplay = text.createTextDisplay;
|
|
|
88
90
|
exports.createThumbArea = thumbarea.createThumbArea;
|
|
89
91
|
exports.createThumbnail = thumbnail.createThumbnail;
|
|
90
92
|
exports.createFileUpload = upload.createFileUpload;
|
|
93
|
+
exports.createCheckbox = checkbox.createCheckbox;
|
|
94
|
+
exports.createCheckboxGroup = checkbox.createCheckboxGroup;
|
|
95
|
+
exports.createRadioGroup = radio.createRadioGroup;
|
|
91
96
|
exports.createEmbedAsset = assets.createEmbedAsset;
|
|
92
97
|
exports.createEmbedAuthor = author.createEmbedAuthor;
|
|
93
98
|
exports.EmbedPlusBuilder = embedplus.EmbedPlusBuilder;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, GuildEmoji, GuildMember, GuildTextBasedChannel, Message, Role, WebhookClientOptions, WebhookClient, WebhookClientData, ComponentEmojiResolvable, ButtonBuilder, ActionRowBuilder, LinkButtonComponentData, Attachment, AttachmentBuilder, MessageActionRowComponentBuilder, TextDisplayBuilder, SeparatorBuilder, FileBuilder, SectionBuilder, MediaGalleryBuilder, ContainerBuilder, ContainerComponentBuilder as ContainerComponentBuilder$1, ColorResolvable, ComponentType, ContainerComponentData, ContainerComponent, APIUnfurledMediaItem, MediaGalleryItemData, TextInputBuilder, TextInputComponentData, TextInputStyle, LabelBuilder, LabelBuilderData, ComponentInLabelData, ModalBuilder, Collection, ModalData, LabelComponentData, TextDisplayComponentData, AnyComponentBuilder, ThumbnailComponentData, ThumbnailBuilder, ButtonComponentData, FileUploadBuilder, EmbedAssetData, User, ClientUser, ImageURLOptions, EmbedFooterData, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, MediaGalleryItemBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, ChannelSelectMenuBuilder, MentionableSelectMenuBuilder } from 'discord.js';
|
|
2
|
+
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, GuildEmoji, GuildMember, GuildTextBasedChannel, Message, Role, WebhookClientOptions, WebhookClient, WebhookClientData, ComponentEmojiResolvable, ButtonBuilder, ActionRowBuilder, LinkButtonComponentData, Attachment, AttachmentBuilder, MessageActionRowComponentBuilder, TextDisplayBuilder, SeparatorBuilder, FileBuilder, SectionBuilder, MediaGalleryBuilder, ContainerBuilder, ContainerComponentBuilder as ContainerComponentBuilder$1, ColorResolvable, ComponentType, ContainerComponentData, ContainerComponent, APIUnfurledMediaItem, MediaGalleryItemData, TextInputBuilder, TextInputComponentData, TextInputStyle, LabelBuilder, LabelBuilderData, ComponentInLabelData, ModalBuilder, Collection, ModalData, LabelComponentData, TextDisplayComponentData, AnyComponentBuilder, ThumbnailComponentData, ThumbnailBuilder, ButtonComponentData, FileUploadBuilder, CheckboxComponentData, CheckboxBuilder, CheckboxGroupComponentData, CheckboxGroupBuilder, RadioGroupComponentData, RadioGroupBuilder, EmbedAssetData, User, ClientUser, ImageURLOptions, EmbedFooterData, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, MediaGalleryItemBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, ChannelSelectMenuBuilder, MentionableSelectMenuBuilder } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const chars: {
|
|
@@ -433,45 +433,70 @@ declare function createModalInput(data: Omit<TextInputComponentData, "type" | "s
|
|
|
433
433
|
style?: TextInputStyle;
|
|
434
434
|
}): ActionRowBuilder<TextInputBuilder>;
|
|
435
435
|
|
|
436
|
-
interface Unstable_CheckboxData {
|
|
437
|
-
type: ComponentType.Checkbox;
|
|
438
|
-
customId: string;
|
|
439
|
-
default?: boolean;
|
|
440
|
-
id?: number;
|
|
441
|
-
}
|
|
442
|
-
interface Unstable_CheckboxGroupData {
|
|
443
|
-
type: ComponentType.CheckboxGroup;
|
|
444
|
-
id?: number;
|
|
445
|
-
customId: string;
|
|
446
|
-
required?: boolean;
|
|
447
|
-
minValues?: number;
|
|
448
|
-
maxValues?: number;
|
|
449
|
-
options: {
|
|
450
|
-
label: string;
|
|
451
|
-
value: string;
|
|
452
|
-
description?: string;
|
|
453
|
-
default?: boolean;
|
|
454
|
-
}[];
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
interface Unstable_RadioGroupData {
|
|
458
|
-
type: ComponentType.RadioGroup;
|
|
459
|
-
id?: number;
|
|
460
|
-
customId: string;
|
|
461
|
-
required?: boolean;
|
|
462
|
-
options: {
|
|
463
|
-
label: string;
|
|
464
|
-
value: string;
|
|
465
|
-
description?: string;
|
|
466
|
-
default?: boolean;
|
|
467
|
-
}[];
|
|
468
|
-
}
|
|
469
|
-
|
|
470
436
|
interface CreateLabelData extends Omit<LabelBuilderData, "type" | "component"> {
|
|
471
|
-
component?: LabelBuilderData["component"] | ComponentInLabelData
|
|
437
|
+
component?: LabelBuilderData["component"] | ComponentInLabelData;
|
|
472
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* Creates a label component using an object configuration.
|
|
441
|
+
*
|
|
442
|
+
* This overload is useful when you already have your label data
|
|
443
|
+
* structured in an object. Each field maps directly to the
|
|
444
|
+
* {@link LabelBuilderData} properties (except `type`).
|
|
445
|
+
*
|
|
446
|
+
* The `component` field can be either raw data or a JSON-encodable builder.
|
|
447
|
+
*
|
|
448
|
+
* @param data - The configuration object containing label properties.
|
|
449
|
+
* @returns A new {@link LabelBuilder} instance configured with the provided data.
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```ts
|
|
453
|
+
* const label = createLabel({
|
|
454
|
+
* label: "Username",
|
|
455
|
+
* description: "Enter your username",
|
|
456
|
+
* component: textInput
|
|
457
|
+
* });
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
473
460
|
declare function createLabel(data: CreateLabelData): LabelBuilder;
|
|
461
|
+
/**
|
|
462
|
+
* Creates a label component with label, description and optional component.
|
|
463
|
+
*
|
|
464
|
+
* Use this overload when you want to explicitly define the label text,
|
|
465
|
+
* description and optionally attach a component.
|
|
466
|
+
*
|
|
467
|
+
* @param label - The main label text.
|
|
468
|
+
* @param description - Additional descriptive text for the label.
|
|
469
|
+
* @param component - Optional component associated with the label.
|
|
470
|
+
* @param id - Optional numeric identifier for the component.
|
|
471
|
+
* @returns A new {@link LabelBuilder} instance configured with the provided values.
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```ts
|
|
475
|
+
* const label = createLabel(
|
|
476
|
+
* "Username",
|
|
477
|
+
* "Enter your username",
|
|
478
|
+
* textInput,
|
|
479
|
+
* 1
|
|
480
|
+
* );
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
474
483
|
declare function createLabel(label: string, description?: string, component?: CreateLabelData["component"], id?: number): LabelBuilder;
|
|
484
|
+
/**
|
|
485
|
+
* Creates a label component with a label and optional component.
|
|
486
|
+
*
|
|
487
|
+
* Use this overload when you don't need a description and want
|
|
488
|
+
* a simpler way to attach a component.
|
|
489
|
+
*
|
|
490
|
+
* @param label - The main label text.
|
|
491
|
+
* @param component - Optional component associated with the label.
|
|
492
|
+
* @param id - Optional numeric identifier for the component.
|
|
493
|
+
* @returns A new {@link LabelBuilder} instance configured with the provided values.
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```ts
|
|
497
|
+
* const label = createLabel("Username", textInput, 1);
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
475
500
|
declare function createLabel(label: string, component?: CreateLabelData["component"], id?: number): LabelBuilder;
|
|
476
501
|
|
|
477
502
|
type ModalComponents = LabelBuilder | TextDisplayBuilder | string | null | boolean | undefined;
|
|
@@ -482,7 +507,7 @@ type ResolveModalData = {
|
|
|
482
507
|
} | {
|
|
483
508
|
fields: Collection<string, ModalData>;
|
|
484
509
|
} | Collection<string, ModalData>;
|
|
485
|
-
type ModalFieldsRecord = Record<string, string | string[]>;
|
|
510
|
+
type ModalFieldsRecord = Record<string, string | string[] | boolean | null>;
|
|
486
511
|
/**
|
|
487
512
|
* Converts modal submitted fields into a plain record object, mapping each component `customId` to its value.
|
|
488
513
|
*
|
|
@@ -836,6 +861,94 @@ declare function createFileUpload(customId: string, required?: boolean, maxValue
|
|
|
836
861
|
*/
|
|
837
862
|
declare function createFileUpload(customId: string, maxValues?: number, minValues?: number): FileUploadBuilder;
|
|
838
863
|
|
|
864
|
+
type CreateCheckboxData = Omit<CheckboxComponentData, "type">;
|
|
865
|
+
/**
|
|
866
|
+
* Creates a checkbox component using an object configuration.
|
|
867
|
+
*
|
|
868
|
+
* This overload is useful when you already have your checkbox data
|
|
869
|
+
* structured in an object. Each field maps directly to the
|
|
870
|
+
* {@link CheckboxComponentData} properties (except `type`).
|
|
871
|
+
*
|
|
872
|
+
* @param data - The configuration object containing checkbox properties.
|
|
873
|
+
* @returns A new {@link CheckboxBuilder} instance configured with the provided data.
|
|
874
|
+
*
|
|
875
|
+
* @example
|
|
876
|
+
* ```ts
|
|
877
|
+
* const checkbox = createCheckbox({
|
|
878
|
+
* customId: "accept_terms",
|
|
879
|
+
* default: true
|
|
880
|
+
* });
|
|
881
|
+
* ```
|
|
882
|
+
*/
|
|
883
|
+
declare function createCheckbox(data: CreateCheckboxData): CheckboxBuilder;
|
|
884
|
+
/**
|
|
885
|
+
* Creates a checkbox component using explicit parameters.
|
|
886
|
+
*
|
|
887
|
+
* Use this overload when you want a simpler and more direct way
|
|
888
|
+
* to define the checkbox without creating an object.
|
|
889
|
+
*
|
|
890
|
+
* @param customId - The custom identifier for the checkbox component.
|
|
891
|
+
* @param defaultValue - Whether the checkbox should be checked by default.
|
|
892
|
+
* @param id - Optional numeric identifier for the component.
|
|
893
|
+
* @returns A new {@link CheckboxBuilder} instance configured with the provided values.
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* ```ts
|
|
897
|
+
* const checkbox = createCheckbox("accept_terms", true, 1);
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
declare function createCheckbox(customId: string, defaultValue?: boolean, id?: number): CheckboxBuilder;
|
|
901
|
+
type CreateCheckboxGroupData = Omit<CheckboxGroupComponentData, "type">;
|
|
902
|
+
/**
|
|
903
|
+
* Creates a checkbox group component using an object configuration.
|
|
904
|
+
*
|
|
905
|
+
* This function is used to group multiple checkboxes together.
|
|
906
|
+
* Each field corresponds to the {@link CheckboxGroupComponentData} properties
|
|
907
|
+
* (except `type`), and the options are automatically applied.
|
|
908
|
+
*
|
|
909
|
+
* @param data - The configuration object containing the group settings and options.
|
|
910
|
+
* @returns A new {@link CheckboxGroupBuilder} instance configured with the provided data.
|
|
911
|
+
*
|
|
912
|
+
* @example
|
|
913
|
+
* ```ts
|
|
914
|
+
* const group = createCheckboxGroup({
|
|
915
|
+
* customId: "preferences",
|
|
916
|
+
* minValues: 1,
|
|
917
|
+
* maxValues: 3,
|
|
918
|
+
* options: [
|
|
919
|
+
* { label: "Option A", value: "a" },
|
|
920
|
+
* { label: "Option B", value: "b" }
|
|
921
|
+
* ]
|
|
922
|
+
* });
|
|
923
|
+
* ```
|
|
924
|
+
*/
|
|
925
|
+
declare function createCheckboxGroup(data: CreateCheckboxGroupData): CheckboxGroupBuilder;
|
|
926
|
+
|
|
927
|
+
type CreateRadioGroup = Omit<RadioGroupComponentData, "type">;
|
|
928
|
+
/**
|
|
929
|
+
* Creates a radio group component using an object configuration.
|
|
930
|
+
*
|
|
931
|
+
* This function is used to define a group of mutually exclusive options,
|
|
932
|
+
* where only one option can be selected at a time.
|
|
933
|
+
* Each field maps directly to the {@link RadioGroupComponentData} properties
|
|
934
|
+
* (except `type`), and the options are automatically applied.
|
|
935
|
+
*
|
|
936
|
+
* @param data - The configuration object containing the group settings and options.
|
|
937
|
+
* @returns A new {@link RadioGroupBuilder} instance configured with the provided data.
|
|
938
|
+
*
|
|
939
|
+
* @example
|
|
940
|
+
* ```ts
|
|
941
|
+
* const group = createRadioGroup({
|
|
942
|
+
* customId: "plan",
|
|
943
|
+
* options: [
|
|
944
|
+
* { label: "Free", value: "free" },
|
|
945
|
+
* { label: "Pro", value: "pro" }
|
|
946
|
+
* ]
|
|
947
|
+
* });
|
|
948
|
+
* ```
|
|
949
|
+
*/
|
|
950
|
+
declare function createRadioGroup(data: CreateRadioGroup): RadioGroupBuilder;
|
|
951
|
+
|
|
839
952
|
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
840
953
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
|
841
954
|
declare function createEmbedAsset(source: EmbedPlusAssetData, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
@@ -1262,5 +1375,5 @@ declare function isTextInputBuilder(value: unknown): value is TextInputBuilder;
|
|
|
1262
1375
|
*/
|
|
1263
1376
|
declare function isMessage(value: unknown): value is Message;
|
|
1264
1377
|
|
|
1265
|
-
export { ContainerPlusBuilder, CustomItents, CustomPartials, EmbedLimit, EmbedPlusBuilder, Separator, chars, commandMention, createComponents, createContainer, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createFile, createFileUpload, createLabel, createLinkButton, createMediaGallery, createModal, createModalFields, createModalInput, createRow, createSection, createSeparator, createTextDisplay, createTextInput, createThumbArea, createThumbnail, createWebhookClient, extractMentionId, fetchMessageFromURL, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageURLInfo, isActionRowBuilder, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, isChannelSelectMenuBuilder, isContainerBuilder, isFileBuilder, isMediaGalleryBuilder, isMediaGalleryItemBuilder, isMentionableSelectMenuBuilder, isMessage, isModalBuilder, isRoleSelectMenuBuilder, isSectionBuilder, isSeparatorBuilder, isStringSelectMenuBuilder, isTextDisplayBuilder, isTextInputBuilder, isUserSelectMenuBuilder, modalFieldsToRecord, setMobileStatus, wrapButtons };
|
|
1266
|
-
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentBuildersData, ComponentData, ContainerColor, ContainerComponentBuilder, ContainerData, ContainerInComponentType, CreateComponentData, CreateModalOptions, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty, FileUploadData, MagicComponentData, MediaGallerySource, SectionAccessory, SectionAccessoryData, SectionButtonAccessory, SectionData, SectionThumbnailAccessory, SeparatorData, ThumbAreaData, ThumbAreaThumbnail, ThumbnailData
|
|
1378
|
+
export { ContainerPlusBuilder, CustomItents, CustomPartials, EmbedLimit, EmbedPlusBuilder, Separator, chars, commandMention, createCheckbox, createCheckboxGroup, createComponents, createContainer, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createFile, createFileUpload, createLabel, createLinkButton, createMediaGallery, createModal, createModalFields, createModalInput, createRadioGroup, createRow, createSection, createSeparator, createTextDisplay, createTextInput, createThumbArea, createThumbnail, createWebhookClient, extractMentionId, fetchMessageFromURL, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageURLInfo, isActionRowBuilder, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, isChannelSelectMenuBuilder, isContainerBuilder, isFileBuilder, isMediaGalleryBuilder, isMediaGalleryItemBuilder, isMentionableSelectMenuBuilder, isMessage, isModalBuilder, isRoleSelectMenuBuilder, isSectionBuilder, isSeparatorBuilder, isStringSelectMenuBuilder, isTextDisplayBuilder, isTextInputBuilder, isUserSelectMenuBuilder, modalFieldsToRecord, setMobileStatus, wrapButtons };
|
|
1379
|
+
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentBuildersData, ComponentData, ContainerColor, ContainerComponentBuilder, ContainerData, ContainerInComponentType, CreateCheckboxData, CreateCheckboxGroupData, CreateComponentData, CreateModalOptions, CreateRadioGroup, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty, FileUploadData, MagicComponentData, MediaGallerySource, SectionAccessory, SectionAccessoryData, SectionButtonAccessory, SectionData, SectionThumbnailAccessory, SeparatorData, ThumbAreaData, ThumbAreaThumbnail, ThumbnailData };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, GuildEmoji, GuildMember, GuildTextBasedChannel, Message, Role, WebhookClientOptions, WebhookClient, WebhookClientData, ComponentEmojiResolvable, ButtonBuilder, ActionRowBuilder, LinkButtonComponentData, Attachment, AttachmentBuilder, MessageActionRowComponentBuilder, TextDisplayBuilder, SeparatorBuilder, FileBuilder, SectionBuilder, MediaGalleryBuilder, ContainerBuilder, ContainerComponentBuilder as ContainerComponentBuilder$1, ColorResolvable, ComponentType, ContainerComponentData, ContainerComponent, APIUnfurledMediaItem, MediaGalleryItemData, TextInputBuilder, TextInputComponentData, TextInputStyle, LabelBuilder, LabelBuilderData, ComponentInLabelData, ModalBuilder, Collection, ModalData, LabelComponentData, TextDisplayComponentData, AnyComponentBuilder, ThumbnailComponentData, ThumbnailBuilder, ButtonComponentData, FileUploadBuilder, EmbedAssetData, User, ClientUser, ImageURLOptions, EmbedFooterData, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, MediaGalleryItemBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, ChannelSelectMenuBuilder, MentionableSelectMenuBuilder } from 'discord.js';
|
|
2
|
+
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, GuildEmoji, GuildMember, GuildTextBasedChannel, Message, Role, WebhookClientOptions, WebhookClient, WebhookClientData, ComponentEmojiResolvable, ButtonBuilder, ActionRowBuilder, LinkButtonComponentData, Attachment, AttachmentBuilder, MessageActionRowComponentBuilder, TextDisplayBuilder, SeparatorBuilder, FileBuilder, SectionBuilder, MediaGalleryBuilder, ContainerBuilder, ContainerComponentBuilder as ContainerComponentBuilder$1, ColorResolvable, ComponentType, ContainerComponentData, ContainerComponent, APIUnfurledMediaItem, MediaGalleryItemData, TextInputBuilder, TextInputComponentData, TextInputStyle, LabelBuilder, LabelBuilderData, ComponentInLabelData, ModalBuilder, Collection, ModalData, LabelComponentData, TextDisplayComponentData, AnyComponentBuilder, ThumbnailComponentData, ThumbnailBuilder, ButtonComponentData, FileUploadBuilder, CheckboxComponentData, CheckboxBuilder, CheckboxGroupComponentData, CheckboxGroupBuilder, RadioGroupComponentData, RadioGroupBuilder, EmbedAssetData, User, ClientUser, ImageURLOptions, EmbedFooterData, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, MediaGalleryItemBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, ChannelSelectMenuBuilder, MentionableSelectMenuBuilder } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const chars: {
|
|
@@ -433,45 +433,70 @@ declare function createModalInput(data: Omit<TextInputComponentData, "type" | "s
|
|
|
433
433
|
style?: TextInputStyle;
|
|
434
434
|
}): ActionRowBuilder<TextInputBuilder>;
|
|
435
435
|
|
|
436
|
-
interface Unstable_CheckboxData {
|
|
437
|
-
type: ComponentType.Checkbox;
|
|
438
|
-
customId: string;
|
|
439
|
-
default?: boolean;
|
|
440
|
-
id?: number;
|
|
441
|
-
}
|
|
442
|
-
interface Unstable_CheckboxGroupData {
|
|
443
|
-
type: ComponentType.CheckboxGroup;
|
|
444
|
-
id?: number;
|
|
445
|
-
customId: string;
|
|
446
|
-
required?: boolean;
|
|
447
|
-
minValues?: number;
|
|
448
|
-
maxValues?: number;
|
|
449
|
-
options: {
|
|
450
|
-
label: string;
|
|
451
|
-
value: string;
|
|
452
|
-
description?: string;
|
|
453
|
-
default?: boolean;
|
|
454
|
-
}[];
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
interface Unstable_RadioGroupData {
|
|
458
|
-
type: ComponentType.RadioGroup;
|
|
459
|
-
id?: number;
|
|
460
|
-
customId: string;
|
|
461
|
-
required?: boolean;
|
|
462
|
-
options: {
|
|
463
|
-
label: string;
|
|
464
|
-
value: string;
|
|
465
|
-
description?: string;
|
|
466
|
-
default?: boolean;
|
|
467
|
-
}[];
|
|
468
|
-
}
|
|
469
|
-
|
|
470
436
|
interface CreateLabelData extends Omit<LabelBuilderData, "type" | "component"> {
|
|
471
|
-
component?: LabelBuilderData["component"] | ComponentInLabelData
|
|
437
|
+
component?: LabelBuilderData["component"] | ComponentInLabelData;
|
|
472
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* Creates a label component using an object configuration.
|
|
441
|
+
*
|
|
442
|
+
* This overload is useful when you already have your label data
|
|
443
|
+
* structured in an object. Each field maps directly to the
|
|
444
|
+
* {@link LabelBuilderData} properties (except `type`).
|
|
445
|
+
*
|
|
446
|
+
* The `component` field can be either raw data or a JSON-encodable builder.
|
|
447
|
+
*
|
|
448
|
+
* @param data - The configuration object containing label properties.
|
|
449
|
+
* @returns A new {@link LabelBuilder} instance configured with the provided data.
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```ts
|
|
453
|
+
* const label = createLabel({
|
|
454
|
+
* label: "Username",
|
|
455
|
+
* description: "Enter your username",
|
|
456
|
+
* component: textInput
|
|
457
|
+
* });
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
473
460
|
declare function createLabel(data: CreateLabelData): LabelBuilder;
|
|
461
|
+
/**
|
|
462
|
+
* Creates a label component with label, description and optional component.
|
|
463
|
+
*
|
|
464
|
+
* Use this overload when you want to explicitly define the label text,
|
|
465
|
+
* description and optionally attach a component.
|
|
466
|
+
*
|
|
467
|
+
* @param label - The main label text.
|
|
468
|
+
* @param description - Additional descriptive text for the label.
|
|
469
|
+
* @param component - Optional component associated with the label.
|
|
470
|
+
* @param id - Optional numeric identifier for the component.
|
|
471
|
+
* @returns A new {@link LabelBuilder} instance configured with the provided values.
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```ts
|
|
475
|
+
* const label = createLabel(
|
|
476
|
+
* "Username",
|
|
477
|
+
* "Enter your username",
|
|
478
|
+
* textInput,
|
|
479
|
+
* 1
|
|
480
|
+
* );
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
474
483
|
declare function createLabel(label: string, description?: string, component?: CreateLabelData["component"], id?: number): LabelBuilder;
|
|
484
|
+
/**
|
|
485
|
+
* Creates a label component with a label and optional component.
|
|
486
|
+
*
|
|
487
|
+
* Use this overload when you don't need a description and want
|
|
488
|
+
* a simpler way to attach a component.
|
|
489
|
+
*
|
|
490
|
+
* @param label - The main label text.
|
|
491
|
+
* @param component - Optional component associated with the label.
|
|
492
|
+
* @param id - Optional numeric identifier for the component.
|
|
493
|
+
* @returns A new {@link LabelBuilder} instance configured with the provided values.
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```ts
|
|
497
|
+
* const label = createLabel("Username", textInput, 1);
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
475
500
|
declare function createLabel(label: string, component?: CreateLabelData["component"], id?: number): LabelBuilder;
|
|
476
501
|
|
|
477
502
|
type ModalComponents = LabelBuilder | TextDisplayBuilder | string | null | boolean | undefined;
|
|
@@ -482,7 +507,7 @@ type ResolveModalData = {
|
|
|
482
507
|
} | {
|
|
483
508
|
fields: Collection<string, ModalData>;
|
|
484
509
|
} | Collection<string, ModalData>;
|
|
485
|
-
type ModalFieldsRecord = Record<string, string | string[]>;
|
|
510
|
+
type ModalFieldsRecord = Record<string, string | string[] | boolean | null>;
|
|
486
511
|
/**
|
|
487
512
|
* Converts modal submitted fields into a plain record object, mapping each component `customId` to its value.
|
|
488
513
|
*
|
|
@@ -836,6 +861,94 @@ declare function createFileUpload(customId: string, required?: boolean, maxValue
|
|
|
836
861
|
*/
|
|
837
862
|
declare function createFileUpload(customId: string, maxValues?: number, minValues?: number): FileUploadBuilder;
|
|
838
863
|
|
|
864
|
+
type CreateCheckboxData = Omit<CheckboxComponentData, "type">;
|
|
865
|
+
/**
|
|
866
|
+
* Creates a checkbox component using an object configuration.
|
|
867
|
+
*
|
|
868
|
+
* This overload is useful when you already have your checkbox data
|
|
869
|
+
* structured in an object. Each field maps directly to the
|
|
870
|
+
* {@link CheckboxComponentData} properties (except `type`).
|
|
871
|
+
*
|
|
872
|
+
* @param data - The configuration object containing checkbox properties.
|
|
873
|
+
* @returns A new {@link CheckboxBuilder} instance configured with the provided data.
|
|
874
|
+
*
|
|
875
|
+
* @example
|
|
876
|
+
* ```ts
|
|
877
|
+
* const checkbox = createCheckbox({
|
|
878
|
+
* customId: "accept_terms",
|
|
879
|
+
* default: true
|
|
880
|
+
* });
|
|
881
|
+
* ```
|
|
882
|
+
*/
|
|
883
|
+
declare function createCheckbox(data: CreateCheckboxData): CheckboxBuilder;
|
|
884
|
+
/**
|
|
885
|
+
* Creates a checkbox component using explicit parameters.
|
|
886
|
+
*
|
|
887
|
+
* Use this overload when you want a simpler and more direct way
|
|
888
|
+
* to define the checkbox without creating an object.
|
|
889
|
+
*
|
|
890
|
+
* @param customId - The custom identifier for the checkbox component.
|
|
891
|
+
* @param defaultValue - Whether the checkbox should be checked by default.
|
|
892
|
+
* @param id - Optional numeric identifier for the component.
|
|
893
|
+
* @returns A new {@link CheckboxBuilder} instance configured with the provided values.
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* ```ts
|
|
897
|
+
* const checkbox = createCheckbox("accept_terms", true, 1);
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
declare function createCheckbox(customId: string, defaultValue?: boolean, id?: number): CheckboxBuilder;
|
|
901
|
+
type CreateCheckboxGroupData = Omit<CheckboxGroupComponentData, "type">;
|
|
902
|
+
/**
|
|
903
|
+
* Creates a checkbox group component using an object configuration.
|
|
904
|
+
*
|
|
905
|
+
* This function is used to group multiple checkboxes together.
|
|
906
|
+
* Each field corresponds to the {@link CheckboxGroupComponentData} properties
|
|
907
|
+
* (except `type`), and the options are automatically applied.
|
|
908
|
+
*
|
|
909
|
+
* @param data - The configuration object containing the group settings and options.
|
|
910
|
+
* @returns A new {@link CheckboxGroupBuilder} instance configured with the provided data.
|
|
911
|
+
*
|
|
912
|
+
* @example
|
|
913
|
+
* ```ts
|
|
914
|
+
* const group = createCheckboxGroup({
|
|
915
|
+
* customId: "preferences",
|
|
916
|
+
* minValues: 1,
|
|
917
|
+
* maxValues: 3,
|
|
918
|
+
* options: [
|
|
919
|
+
* { label: "Option A", value: "a" },
|
|
920
|
+
* { label: "Option B", value: "b" }
|
|
921
|
+
* ]
|
|
922
|
+
* });
|
|
923
|
+
* ```
|
|
924
|
+
*/
|
|
925
|
+
declare function createCheckboxGroup(data: CreateCheckboxGroupData): CheckboxGroupBuilder;
|
|
926
|
+
|
|
927
|
+
type CreateRadioGroup = Omit<RadioGroupComponentData, "type">;
|
|
928
|
+
/**
|
|
929
|
+
* Creates a radio group component using an object configuration.
|
|
930
|
+
*
|
|
931
|
+
* This function is used to define a group of mutually exclusive options,
|
|
932
|
+
* where only one option can be selected at a time.
|
|
933
|
+
* Each field maps directly to the {@link RadioGroupComponentData} properties
|
|
934
|
+
* (except `type`), and the options are automatically applied.
|
|
935
|
+
*
|
|
936
|
+
* @param data - The configuration object containing the group settings and options.
|
|
937
|
+
* @returns A new {@link RadioGroupBuilder} instance configured with the provided data.
|
|
938
|
+
*
|
|
939
|
+
* @example
|
|
940
|
+
* ```ts
|
|
941
|
+
* const group = createRadioGroup({
|
|
942
|
+
* customId: "plan",
|
|
943
|
+
* options: [
|
|
944
|
+
* { label: "Free", value: "free" },
|
|
945
|
+
* { label: "Pro", value: "pro" }
|
|
946
|
+
* ]
|
|
947
|
+
* });
|
|
948
|
+
* ```
|
|
949
|
+
*/
|
|
950
|
+
declare function createRadioGroup(data: CreateRadioGroup): RadioGroupBuilder;
|
|
951
|
+
|
|
839
952
|
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
840
953
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
|
841
954
|
declare function createEmbedAsset(source: EmbedPlusAssetData, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
@@ -1262,5 +1375,5 @@ declare function isTextInputBuilder(value: unknown): value is TextInputBuilder;
|
|
|
1262
1375
|
*/
|
|
1263
1376
|
declare function isMessage(value: unknown): value is Message;
|
|
1264
1377
|
|
|
1265
|
-
export { ContainerPlusBuilder, CustomItents, CustomPartials, EmbedLimit, EmbedPlusBuilder, Separator, chars, commandMention, createComponents, createContainer, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createFile, createFileUpload, createLabel, createLinkButton, createMediaGallery, createModal, createModalFields, createModalInput, createRow, createSection, createSeparator, createTextDisplay, createTextInput, createThumbArea, createThumbnail, createWebhookClient, extractMentionId, fetchMessageFromURL, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageURLInfo, isActionRowBuilder, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, isChannelSelectMenuBuilder, isContainerBuilder, isFileBuilder, isMediaGalleryBuilder, isMediaGalleryItemBuilder, isMentionableSelectMenuBuilder, isMessage, isModalBuilder, isRoleSelectMenuBuilder, isSectionBuilder, isSeparatorBuilder, isStringSelectMenuBuilder, isTextDisplayBuilder, isTextInputBuilder, isUserSelectMenuBuilder, modalFieldsToRecord, setMobileStatus, wrapButtons };
|
|
1266
|
-
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentBuildersData, ComponentData, ContainerColor, ContainerComponentBuilder, ContainerData, ContainerInComponentType, CreateComponentData, CreateModalOptions, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty, FileUploadData, MagicComponentData, MediaGallerySource, SectionAccessory, SectionAccessoryData, SectionButtonAccessory, SectionData, SectionThumbnailAccessory, SeparatorData, ThumbAreaData, ThumbAreaThumbnail, ThumbnailData
|
|
1378
|
+
export { ContainerPlusBuilder, CustomItents, CustomPartials, EmbedLimit, EmbedPlusBuilder, Separator, chars, commandMention, createCheckbox, createCheckboxGroup, createComponents, createContainer, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createFile, createFileUpload, createLabel, createLinkButton, createMediaGallery, createModal, createModalFields, createModalInput, createRadioGroup, createRow, createSection, createSeparator, createTextDisplay, createTextInput, createThumbArea, createThumbnail, createWebhookClient, extractMentionId, fetchMessageFromURL, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageURLInfo, isActionRowBuilder, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, isChannelSelectMenuBuilder, isContainerBuilder, isFileBuilder, isMediaGalleryBuilder, isMediaGalleryItemBuilder, isMentionableSelectMenuBuilder, isMessage, isModalBuilder, isRoleSelectMenuBuilder, isSectionBuilder, isSeparatorBuilder, isStringSelectMenuBuilder, isTextDisplayBuilder, isTextInputBuilder, isUserSelectMenuBuilder, modalFieldsToRecord, setMobileStatus, wrapButtons };
|
|
1379
|
+
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentBuildersData, ComponentData, ContainerColor, ContainerComponentBuilder, ContainerData, ContainerInComponentType, CreateCheckboxData, CreateCheckboxGroupData, CreateComponentData, CreateModalOptions, CreateRadioGroup, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty, FileUploadData, MagicComponentData, MediaGallerySource, SectionAccessory, SectionAccessoryData, SectionButtonAccessory, SectionData, SectionThumbnailAccessory, SeparatorData, ThumbAreaData, ThumbAreaThumbnail, ThumbnailData };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, GuildEmoji, GuildMember, GuildTextBasedChannel, Message, Role, WebhookClientOptions, WebhookClient, WebhookClientData, ComponentEmojiResolvable, ButtonBuilder, ActionRowBuilder, LinkButtonComponentData, Attachment, AttachmentBuilder, MessageActionRowComponentBuilder, TextDisplayBuilder, SeparatorBuilder, FileBuilder, SectionBuilder, MediaGalleryBuilder, ContainerBuilder, ContainerComponentBuilder as ContainerComponentBuilder$1, ColorResolvable, ComponentType, ContainerComponentData, ContainerComponent, APIUnfurledMediaItem, MediaGalleryItemData, TextInputBuilder, TextInputComponentData, TextInputStyle, LabelBuilder, LabelBuilderData, ComponentInLabelData, ModalBuilder, Collection, ModalData, LabelComponentData, TextDisplayComponentData, AnyComponentBuilder, ThumbnailComponentData, ThumbnailBuilder, ButtonComponentData, FileUploadBuilder, EmbedAssetData, User, ClientUser, ImageURLOptions, EmbedFooterData, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, MediaGalleryItemBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, ChannelSelectMenuBuilder, MentionableSelectMenuBuilder } from 'discord.js';
|
|
2
|
+
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, GuildEmoji, GuildMember, GuildTextBasedChannel, Message, Role, WebhookClientOptions, WebhookClient, WebhookClientData, ComponentEmojiResolvable, ButtonBuilder, ActionRowBuilder, LinkButtonComponentData, Attachment, AttachmentBuilder, MessageActionRowComponentBuilder, TextDisplayBuilder, SeparatorBuilder, FileBuilder, SectionBuilder, MediaGalleryBuilder, ContainerBuilder, ContainerComponentBuilder as ContainerComponentBuilder$1, ColorResolvable, ComponentType, ContainerComponentData, ContainerComponent, APIUnfurledMediaItem, MediaGalleryItemData, TextInputBuilder, TextInputComponentData, TextInputStyle, LabelBuilder, LabelBuilderData, ComponentInLabelData, ModalBuilder, Collection, ModalData, LabelComponentData, TextDisplayComponentData, AnyComponentBuilder, ThumbnailComponentData, ThumbnailBuilder, ButtonComponentData, FileUploadBuilder, CheckboxComponentData, CheckboxBuilder, CheckboxGroupComponentData, CheckboxGroupBuilder, RadioGroupComponentData, RadioGroupBuilder, EmbedAssetData, User, ClientUser, ImageURLOptions, EmbedFooterData, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, MediaGalleryItemBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, ChannelSelectMenuBuilder, MentionableSelectMenuBuilder } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const chars: {
|
|
@@ -433,45 +433,70 @@ declare function createModalInput(data: Omit<TextInputComponentData, "type" | "s
|
|
|
433
433
|
style?: TextInputStyle;
|
|
434
434
|
}): ActionRowBuilder<TextInputBuilder>;
|
|
435
435
|
|
|
436
|
-
interface Unstable_CheckboxData {
|
|
437
|
-
type: ComponentType.Checkbox;
|
|
438
|
-
customId: string;
|
|
439
|
-
default?: boolean;
|
|
440
|
-
id?: number;
|
|
441
|
-
}
|
|
442
|
-
interface Unstable_CheckboxGroupData {
|
|
443
|
-
type: ComponentType.CheckboxGroup;
|
|
444
|
-
id?: number;
|
|
445
|
-
customId: string;
|
|
446
|
-
required?: boolean;
|
|
447
|
-
minValues?: number;
|
|
448
|
-
maxValues?: number;
|
|
449
|
-
options: {
|
|
450
|
-
label: string;
|
|
451
|
-
value: string;
|
|
452
|
-
description?: string;
|
|
453
|
-
default?: boolean;
|
|
454
|
-
}[];
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
interface Unstable_RadioGroupData {
|
|
458
|
-
type: ComponentType.RadioGroup;
|
|
459
|
-
id?: number;
|
|
460
|
-
customId: string;
|
|
461
|
-
required?: boolean;
|
|
462
|
-
options: {
|
|
463
|
-
label: string;
|
|
464
|
-
value: string;
|
|
465
|
-
description?: string;
|
|
466
|
-
default?: boolean;
|
|
467
|
-
}[];
|
|
468
|
-
}
|
|
469
|
-
|
|
470
436
|
interface CreateLabelData extends Omit<LabelBuilderData, "type" | "component"> {
|
|
471
|
-
component?: LabelBuilderData["component"] | ComponentInLabelData
|
|
437
|
+
component?: LabelBuilderData["component"] | ComponentInLabelData;
|
|
472
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* Creates a label component using an object configuration.
|
|
441
|
+
*
|
|
442
|
+
* This overload is useful when you already have your label data
|
|
443
|
+
* structured in an object. Each field maps directly to the
|
|
444
|
+
* {@link LabelBuilderData} properties (except `type`).
|
|
445
|
+
*
|
|
446
|
+
* The `component` field can be either raw data or a JSON-encodable builder.
|
|
447
|
+
*
|
|
448
|
+
* @param data - The configuration object containing label properties.
|
|
449
|
+
* @returns A new {@link LabelBuilder} instance configured with the provided data.
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```ts
|
|
453
|
+
* const label = createLabel({
|
|
454
|
+
* label: "Username",
|
|
455
|
+
* description: "Enter your username",
|
|
456
|
+
* component: textInput
|
|
457
|
+
* });
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
473
460
|
declare function createLabel(data: CreateLabelData): LabelBuilder;
|
|
461
|
+
/**
|
|
462
|
+
* Creates a label component with label, description and optional component.
|
|
463
|
+
*
|
|
464
|
+
* Use this overload when you want to explicitly define the label text,
|
|
465
|
+
* description and optionally attach a component.
|
|
466
|
+
*
|
|
467
|
+
* @param label - The main label text.
|
|
468
|
+
* @param description - Additional descriptive text for the label.
|
|
469
|
+
* @param component - Optional component associated with the label.
|
|
470
|
+
* @param id - Optional numeric identifier for the component.
|
|
471
|
+
* @returns A new {@link LabelBuilder} instance configured with the provided values.
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```ts
|
|
475
|
+
* const label = createLabel(
|
|
476
|
+
* "Username",
|
|
477
|
+
* "Enter your username",
|
|
478
|
+
* textInput,
|
|
479
|
+
* 1
|
|
480
|
+
* );
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
474
483
|
declare function createLabel(label: string, description?: string, component?: CreateLabelData["component"], id?: number): LabelBuilder;
|
|
484
|
+
/**
|
|
485
|
+
* Creates a label component with a label and optional component.
|
|
486
|
+
*
|
|
487
|
+
* Use this overload when you don't need a description and want
|
|
488
|
+
* a simpler way to attach a component.
|
|
489
|
+
*
|
|
490
|
+
* @param label - The main label text.
|
|
491
|
+
* @param component - Optional component associated with the label.
|
|
492
|
+
* @param id - Optional numeric identifier for the component.
|
|
493
|
+
* @returns A new {@link LabelBuilder} instance configured with the provided values.
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```ts
|
|
497
|
+
* const label = createLabel("Username", textInput, 1);
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
475
500
|
declare function createLabel(label: string, component?: CreateLabelData["component"], id?: number): LabelBuilder;
|
|
476
501
|
|
|
477
502
|
type ModalComponents = LabelBuilder | TextDisplayBuilder | string | null | boolean | undefined;
|
|
@@ -482,7 +507,7 @@ type ResolveModalData = {
|
|
|
482
507
|
} | {
|
|
483
508
|
fields: Collection<string, ModalData>;
|
|
484
509
|
} | Collection<string, ModalData>;
|
|
485
|
-
type ModalFieldsRecord = Record<string, string | string[]>;
|
|
510
|
+
type ModalFieldsRecord = Record<string, string | string[] | boolean | null>;
|
|
486
511
|
/**
|
|
487
512
|
* Converts modal submitted fields into a plain record object, mapping each component `customId` to its value.
|
|
488
513
|
*
|
|
@@ -836,6 +861,94 @@ declare function createFileUpload(customId: string, required?: boolean, maxValue
|
|
|
836
861
|
*/
|
|
837
862
|
declare function createFileUpload(customId: string, maxValues?: number, minValues?: number): FileUploadBuilder;
|
|
838
863
|
|
|
864
|
+
type CreateCheckboxData = Omit<CheckboxComponentData, "type">;
|
|
865
|
+
/**
|
|
866
|
+
* Creates a checkbox component using an object configuration.
|
|
867
|
+
*
|
|
868
|
+
* This overload is useful when you already have your checkbox data
|
|
869
|
+
* structured in an object. Each field maps directly to the
|
|
870
|
+
* {@link CheckboxComponentData} properties (except `type`).
|
|
871
|
+
*
|
|
872
|
+
* @param data - The configuration object containing checkbox properties.
|
|
873
|
+
* @returns A new {@link CheckboxBuilder} instance configured with the provided data.
|
|
874
|
+
*
|
|
875
|
+
* @example
|
|
876
|
+
* ```ts
|
|
877
|
+
* const checkbox = createCheckbox({
|
|
878
|
+
* customId: "accept_terms",
|
|
879
|
+
* default: true
|
|
880
|
+
* });
|
|
881
|
+
* ```
|
|
882
|
+
*/
|
|
883
|
+
declare function createCheckbox(data: CreateCheckboxData): CheckboxBuilder;
|
|
884
|
+
/**
|
|
885
|
+
* Creates a checkbox component using explicit parameters.
|
|
886
|
+
*
|
|
887
|
+
* Use this overload when you want a simpler and more direct way
|
|
888
|
+
* to define the checkbox without creating an object.
|
|
889
|
+
*
|
|
890
|
+
* @param customId - The custom identifier for the checkbox component.
|
|
891
|
+
* @param defaultValue - Whether the checkbox should be checked by default.
|
|
892
|
+
* @param id - Optional numeric identifier for the component.
|
|
893
|
+
* @returns A new {@link CheckboxBuilder} instance configured with the provided values.
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* ```ts
|
|
897
|
+
* const checkbox = createCheckbox("accept_terms", true, 1);
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
declare function createCheckbox(customId: string, defaultValue?: boolean, id?: number): CheckboxBuilder;
|
|
901
|
+
type CreateCheckboxGroupData = Omit<CheckboxGroupComponentData, "type">;
|
|
902
|
+
/**
|
|
903
|
+
* Creates a checkbox group component using an object configuration.
|
|
904
|
+
*
|
|
905
|
+
* This function is used to group multiple checkboxes together.
|
|
906
|
+
* Each field corresponds to the {@link CheckboxGroupComponentData} properties
|
|
907
|
+
* (except `type`), and the options are automatically applied.
|
|
908
|
+
*
|
|
909
|
+
* @param data - The configuration object containing the group settings and options.
|
|
910
|
+
* @returns A new {@link CheckboxGroupBuilder} instance configured with the provided data.
|
|
911
|
+
*
|
|
912
|
+
* @example
|
|
913
|
+
* ```ts
|
|
914
|
+
* const group = createCheckboxGroup({
|
|
915
|
+
* customId: "preferences",
|
|
916
|
+
* minValues: 1,
|
|
917
|
+
* maxValues: 3,
|
|
918
|
+
* options: [
|
|
919
|
+
* { label: "Option A", value: "a" },
|
|
920
|
+
* { label: "Option B", value: "b" }
|
|
921
|
+
* ]
|
|
922
|
+
* });
|
|
923
|
+
* ```
|
|
924
|
+
*/
|
|
925
|
+
declare function createCheckboxGroup(data: CreateCheckboxGroupData): CheckboxGroupBuilder;
|
|
926
|
+
|
|
927
|
+
type CreateRadioGroup = Omit<RadioGroupComponentData, "type">;
|
|
928
|
+
/**
|
|
929
|
+
* Creates a radio group component using an object configuration.
|
|
930
|
+
*
|
|
931
|
+
* This function is used to define a group of mutually exclusive options,
|
|
932
|
+
* where only one option can be selected at a time.
|
|
933
|
+
* Each field maps directly to the {@link RadioGroupComponentData} properties
|
|
934
|
+
* (except `type`), and the options are automatically applied.
|
|
935
|
+
*
|
|
936
|
+
* @param data - The configuration object containing the group settings and options.
|
|
937
|
+
* @returns A new {@link RadioGroupBuilder} instance configured with the provided data.
|
|
938
|
+
*
|
|
939
|
+
* @example
|
|
940
|
+
* ```ts
|
|
941
|
+
* const group = createRadioGroup({
|
|
942
|
+
* customId: "plan",
|
|
943
|
+
* options: [
|
|
944
|
+
* { label: "Free", value: "free" },
|
|
945
|
+
* { label: "Pro", value: "pro" }
|
|
946
|
+
* ]
|
|
947
|
+
* });
|
|
948
|
+
* ```
|
|
949
|
+
*/
|
|
950
|
+
declare function createRadioGroup(data: CreateRadioGroup): RadioGroupBuilder;
|
|
951
|
+
|
|
839
952
|
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
840
953
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
|
841
954
|
declare function createEmbedAsset(source: EmbedPlusAssetData, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
@@ -1262,5 +1375,5 @@ declare function isTextInputBuilder(value: unknown): value is TextInputBuilder;
|
|
|
1262
1375
|
*/
|
|
1263
1376
|
declare function isMessage(value: unknown): value is Message;
|
|
1264
1377
|
|
|
1265
|
-
export { ContainerPlusBuilder, CustomItents, CustomPartials, EmbedLimit, EmbedPlusBuilder, Separator, chars, commandMention, createComponents, createContainer, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createFile, createFileUpload, createLabel, createLinkButton, createMediaGallery, createModal, createModalFields, createModalInput, createRow, createSection, createSeparator, createTextDisplay, createTextInput, createThumbArea, createThumbnail, createWebhookClient, extractMentionId, fetchMessageFromURL, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageURLInfo, isActionRowBuilder, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, isChannelSelectMenuBuilder, isContainerBuilder, isFileBuilder, isMediaGalleryBuilder, isMediaGalleryItemBuilder, isMentionableSelectMenuBuilder, isMessage, isModalBuilder, isRoleSelectMenuBuilder, isSectionBuilder, isSeparatorBuilder, isStringSelectMenuBuilder, isTextDisplayBuilder, isTextInputBuilder, isUserSelectMenuBuilder, modalFieldsToRecord, setMobileStatus, wrapButtons };
|
|
1266
|
-
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentBuildersData, ComponentData, ContainerColor, ContainerComponentBuilder, ContainerData, ContainerInComponentType, CreateComponentData, CreateModalOptions, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty, FileUploadData, MagicComponentData, MediaGallerySource, SectionAccessory, SectionAccessoryData, SectionButtonAccessory, SectionData, SectionThumbnailAccessory, SeparatorData, ThumbAreaData, ThumbAreaThumbnail, ThumbnailData
|
|
1378
|
+
export { ContainerPlusBuilder, CustomItents, CustomPartials, EmbedLimit, EmbedPlusBuilder, Separator, chars, commandMention, createCheckbox, createCheckboxGroup, createComponents, createContainer, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createFile, createFileUpload, createLabel, createLinkButton, createMediaGallery, createModal, createModalFields, createModalInput, createRadioGroup, createRow, createSection, createSeparator, createTextDisplay, createTextInput, createThumbArea, createThumbnail, createWebhookClient, extractMentionId, fetchMessageFromURL, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageURLInfo, isActionRowBuilder, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, isChannelSelectMenuBuilder, isContainerBuilder, isFileBuilder, isMediaGalleryBuilder, isMediaGalleryItemBuilder, isMentionableSelectMenuBuilder, isMessage, isModalBuilder, isRoleSelectMenuBuilder, isSectionBuilder, isSeparatorBuilder, isStringSelectMenuBuilder, isTextDisplayBuilder, isTextInputBuilder, isUserSelectMenuBuilder, modalFieldsToRecord, setMobileStatus, wrapButtons };
|
|
1379
|
+
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentBuildersData, ComponentData, ContainerColor, ContainerComponentBuilder, ContainerData, ContainerInComponentType, CreateCheckboxData, CreateCheckboxGroupData, CreateComponentData, CreateModalOptions, CreateRadioGroup, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty, FileUploadData, MagicComponentData, MediaGallerySource, SectionAccessory, SectionAccessoryData, SectionButtonAccessory, SectionData, SectionThumbnailAccessory, SeparatorData, ThumbAreaData, ThumbAreaThumbnail, ThumbnailData };
|
package/dist/index.mjs
CHANGED
|
@@ -26,6 +26,8 @@ export { createTextDisplay } from './functions/components/text.mjs';
|
|
|
26
26
|
export { createThumbArea } from './functions/components/thumbarea.mjs';
|
|
27
27
|
export { createThumbnail } from './functions/components/thumbnail.mjs';
|
|
28
28
|
export { createFileUpload } from './functions/components/upload.mjs';
|
|
29
|
+
export { createCheckbox, createCheckboxGroup } from './functions/components/checkbox.mjs';
|
|
30
|
+
export { createRadioGroup } from './functions/components/radio.mjs';
|
|
29
31
|
export { createEmbedAsset } from './functions/embeds/assets.mjs';
|
|
30
32
|
export { createEmbedAuthor } from './functions/embeds/author.mjs';
|
|
31
33
|
export { EmbedPlusBuilder, createEmbed } from './functions/embeds/embedplus.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicyan/discord",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"description": "Simple functions to facilitate discord bot development",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test": "vitest"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"discord.js": "^14.
|
|
42
|
+
"discord.js": "^14.26.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@magicyan/config": "*",
|
|
@@ -49,6 +49,6 @@
|
|
|
49
49
|
"vitest": "^2.1.9"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@magicyan/core": "
|
|
52
|
+
"@magicyan/core": "*"
|
|
53
53
|
}
|
|
54
54
|
}
|