@magicyan/discord 1.7.2 → 1.7.4
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/find.cjs +12 -0
- package/dist/functions/components/find.mjs +10 -0
- package/dist/functions/components/flatten.cjs +35 -0
- package/dist/functions/components/flatten.mjs +33 -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/functions/components/thumbnail.cjs +11 -4
- package/dist/functions/components/thumbnail.mjs +11 -4
- package/dist/functions/components/utils.cjs +7 -0
- package/dist/functions/components/utils.mjs +5 -0
- package/dist/index.cjs +9 -0
- package/dist/index.d.cts +239 -40
- package/dist/index.d.mts +239 -40
- package/dist/index.d.ts +239 -40
- package/dist/index.mjs +4 -0
- package/package.json +2 -2
|
@@ -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 };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const flatten = require('./flatten.cjs');
|
|
4
|
+
|
|
5
|
+
function findMessageComponentById(source, id, type) {
|
|
6
|
+
const components = flatten.flattenMessageComponents(source);
|
|
7
|
+
return components.find(
|
|
8
|
+
(c) => c.id === id && (type === void 0 || c.type === type)
|
|
9
|
+
) ?? null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.findMessageComponentById = findMessageComponentById;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { flattenMessageComponents } from './flatten.mjs';
|
|
2
|
+
|
|
3
|
+
function findMessageComponentById(source, id, type) {
|
|
4
|
+
const components = flattenMessageComponents(source);
|
|
5
|
+
return components.find(
|
|
6
|
+
(c) => c.id === id && (type === void 0 || c.type === type)
|
|
7
|
+
) ?? null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { findMessageComponentById };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
const utils = require('./utils.cjs');
|
|
5
|
+
|
|
6
|
+
function flattenMessageComponents(source) {
|
|
7
|
+
const components = utils.resolveComponentsSource(source);
|
|
8
|
+
const hasNested = components.some(
|
|
9
|
+
(component) => component.type === discord_js.ComponentType.Container || component.type === discord_js.ComponentType.ActionRow || component.type === discord_js.ComponentType.Section
|
|
10
|
+
);
|
|
11
|
+
if (!hasNested)
|
|
12
|
+
return components;
|
|
13
|
+
const result = [];
|
|
14
|
+
function traverse(items) {
|
|
15
|
+
for (const component of items) {
|
|
16
|
+
result.push(component);
|
|
17
|
+
switch (component.type) {
|
|
18
|
+
case discord_js.ComponentType.Container:
|
|
19
|
+
case discord_js.ComponentType.ActionRow:
|
|
20
|
+
traverse(component.components);
|
|
21
|
+
break;
|
|
22
|
+
case discord_js.ComponentType.Section:
|
|
23
|
+
result.push(component.accessory);
|
|
24
|
+
if (component.components.length) {
|
|
25
|
+
traverse(component.components);
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
traverse(components);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.flattenMessageComponents = flattenMessageComponents;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ComponentType } from 'discord.js';
|
|
2
|
+
import { resolveComponentsSource } from './utils.mjs';
|
|
3
|
+
|
|
4
|
+
function flattenMessageComponents(source) {
|
|
5
|
+
const components = resolveComponentsSource(source);
|
|
6
|
+
const hasNested = components.some(
|
|
7
|
+
(component) => component.type === ComponentType.Container || component.type === ComponentType.ActionRow || component.type === ComponentType.Section
|
|
8
|
+
);
|
|
9
|
+
if (!hasNested)
|
|
10
|
+
return components;
|
|
11
|
+
const result = [];
|
|
12
|
+
function traverse(items) {
|
|
13
|
+
for (const component of items) {
|
|
14
|
+
result.push(component);
|
|
15
|
+
switch (component.type) {
|
|
16
|
+
case ComponentType.Container:
|
|
17
|
+
case ComponentType.ActionRow:
|
|
18
|
+
traverse(component.components);
|
|
19
|
+
break;
|
|
20
|
+
case ComponentType.Section:
|
|
21
|
+
result.push(component.accessory);
|
|
22
|
+
if (component.components.length) {
|
|
23
|
+
traverse(component.components);
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
traverse(components);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { flattenMessageComponents };
|
|
@@ -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 };
|
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
const discord_js = require('discord.js');
|
|
4
4
|
|
|
5
|
-
function createThumbnail(data) {
|
|
6
|
-
const thumbnail = new discord_js.ThumbnailBuilder();
|
|
5
|
+
function createThumbnail(data, id) {
|
|
7
6
|
if (typeof data === "string") {
|
|
8
|
-
return
|
|
7
|
+
return new discord_js.ThumbnailBuilder({
|
|
8
|
+
id,
|
|
9
|
+
media: { url: data }
|
|
10
|
+
});
|
|
9
11
|
}
|
|
10
12
|
if (data instanceof discord_js.AttachmentBuilder || data instanceof discord_js.Attachment) {
|
|
11
|
-
return
|
|
13
|
+
return new discord_js.ThumbnailBuilder({
|
|
14
|
+
media: { url: `attachment://${data.name}` },
|
|
15
|
+
spoiler: data.spoiler,
|
|
16
|
+
id
|
|
17
|
+
});
|
|
12
18
|
}
|
|
19
|
+
data.id ?? (data.id = id);
|
|
13
20
|
return new discord_js.ThumbnailBuilder(data);
|
|
14
21
|
}
|
|
15
22
|
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { ThumbnailBuilder, AttachmentBuilder, Attachment } from 'discord.js';
|
|
2
2
|
|
|
3
|
-
function createThumbnail(data) {
|
|
4
|
-
const thumbnail = new ThumbnailBuilder();
|
|
3
|
+
function createThumbnail(data, id) {
|
|
5
4
|
if (typeof data === "string") {
|
|
6
|
-
return
|
|
5
|
+
return new ThumbnailBuilder({
|
|
6
|
+
id,
|
|
7
|
+
media: { url: data }
|
|
8
|
+
});
|
|
7
9
|
}
|
|
8
10
|
if (data instanceof AttachmentBuilder || data instanceof Attachment) {
|
|
9
|
-
return
|
|
11
|
+
return new ThumbnailBuilder({
|
|
12
|
+
media: { url: `attachment://${data.name}` },
|
|
13
|
+
spoiler: data.spoiler,
|
|
14
|
+
id
|
|
15
|
+
});
|
|
10
16
|
}
|
|
17
|
+
data.id ?? (data.id = id);
|
|
11
18
|
return new ThumbnailBuilder(data);
|
|
12
19
|
}
|
|
13
20
|
|
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,10 @@ 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');
|
|
33
|
+
const flatten = require('./functions/components/flatten.cjs');
|
|
34
|
+
const find = require('./functions/components/find.cjs');
|
|
31
35
|
const assets = require('./functions/embeds/assets.cjs');
|
|
32
36
|
const author = require('./functions/embeds/author.cjs');
|
|
33
37
|
const embedplus = require('./functions/embeds/embedplus.cjs');
|
|
@@ -88,6 +92,11 @@ exports.createTextDisplay = text.createTextDisplay;
|
|
|
88
92
|
exports.createThumbArea = thumbarea.createThumbArea;
|
|
89
93
|
exports.createThumbnail = thumbnail.createThumbnail;
|
|
90
94
|
exports.createFileUpload = upload.createFileUpload;
|
|
95
|
+
exports.createCheckbox = checkbox.createCheckbox;
|
|
96
|
+
exports.createCheckboxGroup = checkbox.createCheckboxGroup;
|
|
97
|
+
exports.createRadioGroup = radio.createRadioGroup;
|
|
98
|
+
exports.flattenMessageComponents = flatten.flattenMessageComponents;
|
|
99
|
+
exports.findMessageComponentById = find.findMessageComponentById;
|
|
91
100
|
exports.createEmbedAsset = assets.createEmbedAsset;
|
|
92
101
|
exports.createEmbedAuthor = author.createEmbedAuthor;
|
|
93
102
|
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, TopLevelComponent, MessageActionRowComponent, ThumbnailComponent, MediaGalleryComponent, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, ChannelSelectMenuComponent, SectionComponent, SeparatorComponent, FileComponent, TextDisplayComponent, 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
|
*
|
|
@@ -595,7 +620,7 @@ type ThumbnailData = Partial<Omit<ThumbnailComponentData, "type">> | Attachment
|
|
|
595
620
|
* spoiler: true
|
|
596
621
|
* });
|
|
597
622
|
*/
|
|
598
|
-
declare function createThumbnail(data: ThumbnailData): ThumbnailBuilder;
|
|
623
|
+
declare function createThumbnail(data: ThumbnailData, id?: number): ThumbnailBuilder;
|
|
599
624
|
|
|
600
625
|
type SectionThumbnailAccessory = ThumbnailBuilder | ThumbnailData;
|
|
601
626
|
type SectionButtonAccessory = ButtonBuilder | Partial<ButtonComponentData>;
|
|
@@ -836,6 +861,180 @@ 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
|
+
|
|
952
|
+
type MessageComponentWithId = TopLevelComponent | MessageActionRowComponent | ThumbnailComponent | MediaGalleryComponent;
|
|
953
|
+
type MessageComponentSource = MessageComponentWithId[] | {
|
|
954
|
+
components: MessageComponentWithId[];
|
|
955
|
+
} | {
|
|
956
|
+
message: {
|
|
957
|
+
components: MessageComponentWithId[];
|
|
958
|
+
};
|
|
959
|
+
};
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Recursively traverses a message component tree and returns a flat array
|
|
963
|
+
* containing all components found in the structure.
|
|
964
|
+
*
|
|
965
|
+
* Supports component sources as a direct component array, an object with
|
|
966
|
+
* a `components` property, or an object containing `message.components`.
|
|
967
|
+
*
|
|
968
|
+
* Nested components inside containers and action rows are traversed
|
|
969
|
+
* recursively. For section components, the accessory component and any
|
|
970
|
+
* nested components are also included in the result.
|
|
971
|
+
*
|
|
972
|
+
* @param source The source containing the message components to flatten.
|
|
973
|
+
* @returns A flat array containing all components found in traversal order.
|
|
974
|
+
*/
|
|
975
|
+
declare function flattenMessageComponents(source: MessageComponentSource): MessageComponentWithId[];
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* Finds a component by its identifier.
|
|
979
|
+
*/
|
|
980
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number): MessageComponentWithId | null;
|
|
981
|
+
/**
|
|
982
|
+
* Finds a {@link ButtonComponent} by its identifier.
|
|
983
|
+
*/
|
|
984
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.Button): ButtonComponent | null;
|
|
985
|
+
/**
|
|
986
|
+
* Finds a {@link StringSelectMenuComponent} by its identifier.
|
|
987
|
+
*/
|
|
988
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.StringSelect): StringSelectMenuComponent | null;
|
|
989
|
+
/**
|
|
990
|
+
* Finds a {@link UserSelectMenuComponent} by its identifier.
|
|
991
|
+
*/
|
|
992
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.UserSelect): UserSelectMenuComponent | null;
|
|
993
|
+
/**
|
|
994
|
+
* Finds a {@link RoleSelectMenuComponent} by its identifier.
|
|
995
|
+
*/
|
|
996
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.RoleSelect): RoleSelectMenuComponent | null;
|
|
997
|
+
/**
|
|
998
|
+
* Finds a {@link MentionableSelectMenuComponent} by its identifier.
|
|
999
|
+
*/
|
|
1000
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.MentionableSelect): MentionableSelectMenuComponent | null;
|
|
1001
|
+
/**
|
|
1002
|
+
* Finds a {@link ChannelSelectMenuComponent} by its identifier.
|
|
1003
|
+
*/
|
|
1004
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.ChannelSelect): ChannelSelectMenuComponent | null;
|
|
1005
|
+
/**
|
|
1006
|
+
* Finds a {@link ContainerComponent} by its identifier.
|
|
1007
|
+
*/
|
|
1008
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.Container): ContainerComponent | null;
|
|
1009
|
+
/**
|
|
1010
|
+
* Finds a {@link SectionComponent} by its identifier.
|
|
1011
|
+
*/
|
|
1012
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.Section): SectionComponent | null;
|
|
1013
|
+
/**
|
|
1014
|
+
* Finds a {@link MediaGalleryComponent} by its identifier.
|
|
1015
|
+
*/
|
|
1016
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.MediaGallery): MediaGalleryComponent | null;
|
|
1017
|
+
/**
|
|
1018
|
+
* Finds a {@link ThumbnailComponent} by its identifier.
|
|
1019
|
+
*/
|
|
1020
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.Thumbnail): ThumbnailComponent | null;
|
|
1021
|
+
/**
|
|
1022
|
+
* Finds a {@link SeparatorComponent} by its identifier.
|
|
1023
|
+
*/
|
|
1024
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.Separator): SeparatorComponent | null;
|
|
1025
|
+
/**
|
|
1026
|
+
* Finds a {@link FileComponent} by its identifier.
|
|
1027
|
+
*/
|
|
1028
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.File): FileComponent | null;
|
|
1029
|
+
/**
|
|
1030
|
+
* Finds a {@link TextDisplayComponent} by its identifier.
|
|
1031
|
+
*/
|
|
1032
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.TextDisplay): TextDisplayComponent | null;
|
|
1033
|
+
/**
|
|
1034
|
+
* Finds a {@link MessageActionRowComponent} by its identifier.
|
|
1035
|
+
*/
|
|
1036
|
+
declare function findMessageComponentById(source: MessageComponentSource, id: number, type: ComponentType.ActionRow): MessageActionRowComponent | null;
|
|
1037
|
+
|
|
839
1038
|
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
840
1039
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
|
841
1040
|
declare function createEmbedAsset(source: EmbedPlusAssetData, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
@@ -1262,5 +1461,5 @@ declare function isTextInputBuilder(value: unknown): value is TextInputBuilder;
|
|
|
1262
1461
|
*/
|
|
1263
1462
|
declare function isMessage(value: unknown): value is Message;
|
|
1264
1463
|
|
|
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
|
|
1464
|
+
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, findMessageComponentById, findRole, flattenMessageComponents, getChannelUrlInfo, getMessageURLInfo, isActionRowBuilder, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, isChannelSelectMenuBuilder, isContainerBuilder, isFileBuilder, isMediaGalleryBuilder, isMediaGalleryItemBuilder, isMentionableSelectMenuBuilder, isMessage, isModalBuilder, isRoleSelectMenuBuilder, isSectionBuilder, isSeparatorBuilder, isStringSelectMenuBuilder, isTextDisplayBuilder, isTextInputBuilder, isUserSelectMenuBuilder, modalFieldsToRecord, setMobileStatus, wrapButtons };
|
|
1465
|
+
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 };
|