@magicyan/discord 1.4.5 → 1.4.7
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/constants/separator.cjs +28 -0
- package/dist/constants/separator.mjs +26 -0
- package/dist/functions/components/buttons.cjs +12 -0
- package/dist/functions/components/buttons.mjs +12 -1
- package/dist/functions/components/components.cjs +1 -1
- package/dist/functions/components/components.mjs +1 -1
- package/dist/functions/components/container.cjs +6 -2
- package/dist/functions/components/container.mjs +6 -2
- package/dist/functions/components/row.cjs +3 -1
- package/dist/functions/components/row.mjs +3 -1
- package/dist/functions/components/section.cjs +6 -13
- package/dist/functions/components/section.mjs +6 -13
- package/dist/functions/components/separator.cjs +4 -3
- package/dist/functions/components/separator.mjs +4 -3
- package/dist/index.cjs +5 -2
- package/dist/index.d.cts +143 -42
- package/dist/index.d.mts +143 -42
- package/dist/index.d.ts +143 -42
- package/dist/index.mjs +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const separator = require('../functions/components/separator.cjs');
|
|
4
|
+
|
|
5
|
+
const Separator = {
|
|
6
|
+
/**
|
|
7
|
+
* Default separator with small spacing and visible divider.
|
|
8
|
+
* Equivalent to: `createSeparator()`
|
|
9
|
+
*/
|
|
10
|
+
Default: separator.createSeparator(),
|
|
11
|
+
/**
|
|
12
|
+
* Separator with large spacing and visible divider.
|
|
13
|
+
* Equivalent to: `createSeparator(true)`
|
|
14
|
+
*/
|
|
15
|
+
Large: separator.createSeparator(true),
|
|
16
|
+
/**
|
|
17
|
+
* Separator with large spacing and no visible divider.
|
|
18
|
+
* Equivalent to: `createSeparator(true, false)`
|
|
19
|
+
*/
|
|
20
|
+
LargeHidden: separator.createSeparator(true, false),
|
|
21
|
+
/**
|
|
22
|
+
* Separator with small spacing and no visible divider.
|
|
23
|
+
* Equivalent to: `createSeparator(false, false)`
|
|
24
|
+
*/
|
|
25
|
+
Hidden: separator.createSeparator(false, false)
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.Separator = Separator;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createSeparator } from '../functions/components/separator.mjs';
|
|
2
|
+
|
|
3
|
+
const Separator = {
|
|
4
|
+
/**
|
|
5
|
+
* Default separator with small spacing and visible divider.
|
|
6
|
+
* Equivalent to: `createSeparator()`
|
|
7
|
+
*/
|
|
8
|
+
Default: createSeparator(),
|
|
9
|
+
/**
|
|
10
|
+
* Separator with large spacing and visible divider.
|
|
11
|
+
* Equivalent to: `createSeparator(true)`
|
|
12
|
+
*/
|
|
13
|
+
Large: createSeparator(true),
|
|
14
|
+
/**
|
|
15
|
+
* Separator with large spacing and no visible divider.
|
|
16
|
+
* Equivalent to: `createSeparator(true, false)`
|
|
17
|
+
*/
|
|
18
|
+
LargeHidden: createSeparator(true, false),
|
|
19
|
+
/**
|
|
20
|
+
* Separator with small spacing and no visible divider.
|
|
21
|
+
* Equivalent to: `createSeparator(false, false)`
|
|
22
|
+
*/
|
|
23
|
+
Hidden: createSeparator(false, false)
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { Separator };
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const discord_js = require('discord.js');
|
|
4
|
+
const row = require('./row.cjs');
|
|
4
5
|
|
|
5
6
|
function createLinkButton(data) {
|
|
6
7
|
data.label ?? (data.label = data.url);
|
|
7
8
|
return new discord_js.ButtonBuilder({ style: discord_js.ButtonStyle.Link, ...data });
|
|
8
9
|
}
|
|
10
|
+
function wrapButtons(maxItemsPerRow, ...buttons) {
|
|
11
|
+
const items = buttons.flat();
|
|
12
|
+
const result = [];
|
|
13
|
+
for (let index = 0; index < items.length; index += maxItemsPerRow) {
|
|
14
|
+
result.push(row.createRow(
|
|
15
|
+
items.slice(index, index + maxItemsPerRow)
|
|
16
|
+
));
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
9
20
|
|
|
10
21
|
exports.createLinkButton = createLinkButton;
|
|
22
|
+
exports.wrapButtons = wrapButtons;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { ButtonBuilder, ButtonStyle } from 'discord.js';
|
|
2
|
+
import { createRow } from './row.mjs';
|
|
2
3
|
|
|
3
4
|
function createLinkButton(data) {
|
|
4
5
|
data.label ?? (data.label = data.url);
|
|
5
6
|
return new ButtonBuilder({ style: ButtonStyle.Link, ...data });
|
|
6
7
|
}
|
|
8
|
+
function wrapButtons(maxItemsPerRow, ...buttons) {
|
|
9
|
+
const items = buttons.flat();
|
|
10
|
+
const result = [];
|
|
11
|
+
for (let index = 0; index < items.length; index += maxItemsPerRow) {
|
|
12
|
+
result.push(createRow(
|
|
13
|
+
items.slice(index, index + maxItemsPerRow)
|
|
14
|
+
));
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
7
18
|
|
|
8
|
-
export { createLinkButton };
|
|
19
|
+
export { createLinkButton, wrapButtons };
|
|
@@ -8,7 +8,7 @@ const row = require('./row.cjs');
|
|
|
8
8
|
const text = require('./text.cjs');
|
|
9
9
|
|
|
10
10
|
function createComponents(...data) {
|
|
11
|
-
return data.filter((value) => value !== null && value !== void 0).map((component) => {
|
|
11
|
+
return data.flat().filter((value) => value !== null && value !== void 0).map((component) => {
|
|
12
12
|
if (typeof component === "string") {
|
|
13
13
|
return text.createTextDisplay(component);
|
|
14
14
|
}
|
|
@@ -6,7 +6,7 @@ import { createRow } from './row.mjs';
|
|
|
6
6
|
import { createTextDisplay } from './text.mjs';
|
|
7
7
|
|
|
8
8
|
function createComponents(...data) {
|
|
9
|
-
return data.filter((value) => value !== null && value !== void 0).map((component) => {
|
|
9
|
+
return data.flat().filter((value) => value !== null && value !== void 0).map((component) => {
|
|
10
10
|
if (typeof component === "string") {
|
|
11
11
|
return createTextDisplay(component);
|
|
12
12
|
}
|
|
@@ -7,7 +7,7 @@ const gallery = require('./gallery.cjs');
|
|
|
7
7
|
const row = require('./row.cjs');
|
|
8
8
|
const text = require('./text.cjs');
|
|
9
9
|
|
|
10
|
-
function createContainer(data, ...
|
|
10
|
+
function createContainer(data, ...items) {
|
|
11
11
|
const container = new discord_js.ContainerBuilder();
|
|
12
12
|
const addComponent = (component) => {
|
|
13
13
|
if (!component)
|
|
@@ -62,12 +62,16 @@ function createContainer(data, ...components) {
|
|
|
62
62
|
if (isContainerData(data)) {
|
|
63
63
|
if (data.accentColor)
|
|
64
64
|
setColor(data.accentColor);
|
|
65
|
+
if (data.spoiler !== void 0)
|
|
66
|
+
container.setSpoiler(data.spoiler);
|
|
67
|
+
if (data.id !== void 0)
|
|
68
|
+
container.setId(data.id);
|
|
65
69
|
for (const component of data.components)
|
|
66
70
|
addComponent(component);
|
|
67
71
|
return container;
|
|
68
72
|
}
|
|
69
73
|
setColor(data);
|
|
70
|
-
for (const component of
|
|
74
|
+
for (const component of items.flat())
|
|
71
75
|
addComponent(component);
|
|
72
76
|
return container;
|
|
73
77
|
}
|
|
@@ -5,7 +5,7 @@ import { createMediaGallery } from './gallery.mjs';
|
|
|
5
5
|
import { createRow } from './row.mjs';
|
|
6
6
|
import { createTextDisplay } from './text.mjs';
|
|
7
7
|
|
|
8
|
-
function createContainer(data, ...
|
|
8
|
+
function createContainer(data, ...items) {
|
|
9
9
|
const container = new ContainerBuilder();
|
|
10
10
|
const addComponent = (component) => {
|
|
11
11
|
if (!component)
|
|
@@ -60,12 +60,16 @@ function createContainer(data, ...components) {
|
|
|
60
60
|
if (isContainerData(data)) {
|
|
61
61
|
if (data.accentColor)
|
|
62
62
|
setColor(data.accentColor);
|
|
63
|
+
if (data.spoiler !== void 0)
|
|
64
|
+
container.setSpoiler(data.spoiler);
|
|
65
|
+
if (data.id !== void 0)
|
|
66
|
+
container.setId(data.id);
|
|
63
67
|
for (const component of data.components)
|
|
64
68
|
addComponent(component);
|
|
65
69
|
return container;
|
|
66
70
|
}
|
|
67
71
|
setColor(data);
|
|
68
|
-
for (const component of
|
|
72
|
+
for (const component of items.flat())
|
|
69
73
|
addComponent(component);
|
|
70
74
|
return container;
|
|
71
75
|
}
|
|
@@ -4,7 +4,7 @@ const discord_js = require('discord.js');
|
|
|
4
4
|
const text = require('./text.cjs');
|
|
5
5
|
const thumbnail = require('./thumbnail.cjs');
|
|
6
6
|
|
|
7
|
-
function createSection(
|
|
7
|
+
function createSection(argA, argB) {
|
|
8
8
|
const section = new discord_js.SectionBuilder();
|
|
9
9
|
function setAccessory(data2) {
|
|
10
10
|
if (data2 instanceof discord_js.ButtonBuilder) {
|
|
@@ -14,19 +14,14 @@ function createSection(data) {
|
|
|
14
14
|
return section.setThumbnailAccessory(data2);
|
|
15
15
|
}
|
|
16
16
|
if (typeof data2 === "string") {
|
|
17
|
-
return section.setThumbnailAccessory(
|
|
18
|
-
thumbnail.createThumbnail(data2)
|
|
19
|
-
);
|
|
17
|
+
return section.setThumbnailAccessory(thumbnail.createThumbnail(data2));
|
|
20
18
|
}
|
|
21
19
|
if ("media" in data2 || "description" in data2) {
|
|
22
|
-
return section.setThumbnailAccessory(
|
|
23
|
-
thumbnail.createThumbnail(data2)
|
|
24
|
-
);
|
|
20
|
+
return section.setThumbnailAccessory(thumbnail.createThumbnail(data2));
|
|
25
21
|
}
|
|
26
|
-
return section.setButtonAccessory(
|
|
27
|
-
new discord_js.ButtonBuilder(data2)
|
|
28
|
-
);
|
|
22
|
+
return section.setButtonAccessory(new discord_js.ButtonBuilder(data2));
|
|
29
23
|
}
|
|
24
|
+
const data = typeof argA === "string" ? { content: argA, accessory: argB } : argA;
|
|
30
25
|
if (data.accessory || data.button || data.thumbnail) {
|
|
31
26
|
setAccessory(data.accessory ?? data.button ?? data.thumbnail);
|
|
32
27
|
}
|
|
@@ -35,9 +30,7 @@ function createSection(data) {
|
|
|
35
30
|
data.content.map((text$1) => text.createTextDisplay(text$1))
|
|
36
31
|
);
|
|
37
32
|
} else {
|
|
38
|
-
section.addTextDisplayComponents(
|
|
39
|
-
text.createTextDisplay(data.content)
|
|
40
|
-
);
|
|
33
|
+
section.addTextDisplayComponents(text.createTextDisplay(data.content));
|
|
41
34
|
}
|
|
42
35
|
return section;
|
|
43
36
|
}
|
|
@@ -2,7 +2,7 @@ import { SectionBuilder, ButtonBuilder, ThumbnailBuilder } from 'discord.js';
|
|
|
2
2
|
import { createTextDisplay } from './text.mjs';
|
|
3
3
|
import { createThumbnail } from './thumbnail.mjs';
|
|
4
4
|
|
|
5
|
-
function createSection(
|
|
5
|
+
function createSection(argA, argB) {
|
|
6
6
|
const section = new SectionBuilder();
|
|
7
7
|
function setAccessory(data2) {
|
|
8
8
|
if (data2 instanceof ButtonBuilder) {
|
|
@@ -12,19 +12,14 @@ function createSection(data) {
|
|
|
12
12
|
return section.setThumbnailAccessory(data2);
|
|
13
13
|
}
|
|
14
14
|
if (typeof data2 === "string") {
|
|
15
|
-
return section.setThumbnailAccessory(
|
|
16
|
-
createThumbnail(data2)
|
|
17
|
-
);
|
|
15
|
+
return section.setThumbnailAccessory(createThumbnail(data2));
|
|
18
16
|
}
|
|
19
17
|
if ("media" in data2 || "description" in data2) {
|
|
20
|
-
return section.setThumbnailAccessory(
|
|
21
|
-
createThumbnail(data2)
|
|
22
|
-
);
|
|
18
|
+
return section.setThumbnailAccessory(createThumbnail(data2));
|
|
23
19
|
}
|
|
24
|
-
return section.setButtonAccessory(
|
|
25
|
-
new ButtonBuilder(data2)
|
|
26
|
-
);
|
|
20
|
+
return section.setButtonAccessory(new ButtonBuilder(data2));
|
|
27
21
|
}
|
|
22
|
+
const data = typeof argA === "string" ? { content: argA, accessory: argB } : argA;
|
|
28
23
|
if (data.accessory || data.button || data.thumbnail) {
|
|
29
24
|
setAccessory(data.accessory ?? data.button ?? data.thumbnail);
|
|
30
25
|
}
|
|
@@ -33,9 +28,7 @@ function createSection(data) {
|
|
|
33
28
|
data.content.map((text) => createTextDisplay(text))
|
|
34
29
|
);
|
|
35
30
|
} else {
|
|
36
|
-
section.addTextDisplayComponents(
|
|
37
|
-
createTextDisplay(data.content)
|
|
38
|
-
);
|
|
31
|
+
section.addTextDisplayComponents(createTextDisplay(data.content));
|
|
39
32
|
}
|
|
40
33
|
return section;
|
|
41
34
|
}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const discord_js = require('discord.js');
|
|
4
4
|
|
|
5
|
-
function createSeparator(
|
|
5
|
+
function createSeparator(argA, argB) {
|
|
6
|
+
const [large, divider] = typeof argA === "object" ? [argA.large, argA.divider] : [argA, argB];
|
|
6
7
|
return new discord_js.SeparatorBuilder({
|
|
7
|
-
divider
|
|
8
|
-
spacing:
|
|
8
|
+
divider,
|
|
9
|
+
spacing: large ? discord_js.SeparatorSpacingSize.Large : discord_js.SeparatorSpacingSize.Small
|
|
9
10
|
});
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SeparatorBuilder, SeparatorSpacingSize } from 'discord.js';
|
|
2
2
|
|
|
3
|
-
function createSeparator(
|
|
3
|
+
function createSeparator(argA, argB) {
|
|
4
|
+
const [large, divider] = typeof argA === "object" ? [argA.large, argA.divider] : [argA, argB];
|
|
4
5
|
return new SeparatorBuilder({
|
|
5
|
-
divider
|
|
6
|
-
spacing:
|
|
6
|
+
divider,
|
|
7
|
+
spacing: large ? SeparatorSpacingSize.Large : SeparatorSpacingSize.Small
|
|
7
8
|
});
|
|
8
9
|
}
|
|
9
10
|
|
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const chars = require('./constants/chars.cjs');
|
|
4
4
|
const client = require('./constants/client.cjs');
|
|
5
5
|
const embed = require('./constants/embed.cjs');
|
|
6
|
+
const separator = require('./constants/separator.cjs');
|
|
6
7
|
const misc = require('./functions/misc.cjs');
|
|
7
8
|
const assets = require('./functions/embeds/assets.cjs');
|
|
8
9
|
const author = require('./functions/embeds/author.cjs');
|
|
@@ -13,7 +14,7 @@ const buttons = require('./functions/components/buttons.cjs');
|
|
|
13
14
|
const row = require('./functions/components/row.cjs');
|
|
14
15
|
const file = require('./functions/components/file.cjs');
|
|
15
16
|
const gallery = require('./functions/components/gallery.cjs');
|
|
16
|
-
const separator = require('./functions/components/separator.cjs');
|
|
17
|
+
const separator$1 = require('./functions/components/separator.cjs');
|
|
17
18
|
const section = require('./functions/components/section.cjs');
|
|
18
19
|
const text = require('./functions/components/text.cjs');
|
|
19
20
|
const thumbnail = require('./functions/components/thumbnail.cjs');
|
|
@@ -39,6 +40,7 @@ exports.chars = chars.chars;
|
|
|
39
40
|
exports.CustomItents = client.CustomItents;
|
|
40
41
|
exports.CustomPartials = client.CustomPartials;
|
|
41
42
|
exports.EmbedLimit = embed.EmbedLimit;
|
|
43
|
+
exports.Separator = separator.Separator;
|
|
42
44
|
exports.setMobileStatus = misc.setMobileStatus;
|
|
43
45
|
exports.createEmbedAsset = assets.createEmbedAsset;
|
|
44
46
|
exports.createEmbedAuthor = author.createEmbedAuthor;
|
|
@@ -47,10 +49,11 @@ exports.createEmbed = embedplus.createEmbed;
|
|
|
47
49
|
exports.createEmbedFooter = footer.createEmbedFooter;
|
|
48
50
|
exports.createEmbedFiles = files.createEmbedFiles;
|
|
49
51
|
exports.createLinkButton = buttons.createLinkButton;
|
|
52
|
+
exports.wrapButtons = buttons.wrapButtons;
|
|
50
53
|
exports.createRow = row.createRow;
|
|
51
54
|
exports.createFile = file.createFile;
|
|
52
55
|
exports.createMediaGallery = gallery.createMediaGallery;
|
|
53
|
-
exports.createSeparator = separator.createSeparator;
|
|
56
|
+
exports.createSeparator = separator$1.createSeparator;
|
|
54
57
|
exports.createSection = section.createSection;
|
|
55
58
|
exports.createTextDisplay = text.createTextDisplay;
|
|
56
59
|
exports.createThumbnail = thumbnail.createThumbnail;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, ButtonBuilder, LinkButtonComponentData, AnyComponentBuilder,
|
|
2
|
+
import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, ButtonBuilder, ActionRowBuilder, LinkButtonComponentData, AnyComponentBuilder, FileBuilder, APIUnfurledMediaItem, MediaGalleryBuilder, MediaGalleryItemData, SeparatorBuilder, ThumbnailComponentData, ThumbnailBuilder, ButtonComponentData, SectionBuilder, TextDisplayBuilder, MessageActionRowComponentBuilder, ContainerBuilder, ContainerComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, TextInputBuilder, ModalSubmitInteraction, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role, WebhookClientOptions, WebhookClient, WebhookClientData, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, ChannelSelectMenuBuilder, MentionableSelectMenuBuilder } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const chars: {
|
|
@@ -31,6 +31,32 @@ declare enum EmbedLimit {
|
|
|
31
31
|
URL = 2048
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Predefined separator spacing variants for quick use.
|
|
36
|
+
*/
|
|
37
|
+
declare const Separator: {
|
|
38
|
+
/**
|
|
39
|
+
* Default separator with small spacing and visible divider.
|
|
40
|
+
* Equivalent to: `createSeparator()`
|
|
41
|
+
*/
|
|
42
|
+
readonly Default: discord_js.SeparatorBuilder;
|
|
43
|
+
/**
|
|
44
|
+
* Separator with large spacing and visible divider.
|
|
45
|
+
* Equivalent to: `createSeparator(true)`
|
|
46
|
+
*/
|
|
47
|
+
readonly Large: discord_js.SeparatorBuilder;
|
|
48
|
+
/**
|
|
49
|
+
* Separator with large spacing and no visible divider.
|
|
50
|
+
* Equivalent to: `createSeparator(true, false)`
|
|
51
|
+
*/
|
|
52
|
+
readonly LargeHidden: discord_js.SeparatorBuilder;
|
|
53
|
+
/**
|
|
54
|
+
* Separator with small spacing and no visible divider.
|
|
55
|
+
* Equivalent to: `createSeparator(false, false)`
|
|
56
|
+
*/
|
|
57
|
+
readonly Hidden: discord_js.SeparatorBuilder;
|
|
58
|
+
};
|
|
59
|
+
|
|
34
60
|
declare function setMobileStatus(): void;
|
|
35
61
|
|
|
36
62
|
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
@@ -182,8 +208,65 @@ declare function createEmbedFiles(embed: EmbedBuilder, options?: CreateEmbedFile
|
|
|
182
208
|
interface CreateLinkButtonData extends Omit<LinkButtonComponentData, "style" | "type"> {
|
|
183
209
|
}
|
|
184
210
|
declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
|
|
211
|
+
/**
|
|
212
|
+
* Wraps buttons into multiple {@link ActionRowBuilder} instances with a maximum number of buttons per row.
|
|
213
|
+
*
|
|
214
|
+
* This function takes a list of {@link ButtonBuilder} instances (or arrays of them) and groups them into
|
|
215
|
+
* multiple `ActionRowBuilder<ButtonBuilder>` objects, ensuring that each row contains no more than the specified
|
|
216
|
+
* number of buttons.
|
|
217
|
+
*
|
|
218
|
+
* @param maxItemsPerRow - The maximum number of buttons to include in each row.
|
|
219
|
+
* @param buttons - A variadic list of {@link ButtonBuilder} instances or arrays of them to be wrapped.
|
|
220
|
+
*
|
|
221
|
+
* @returns An array of {@link ActionRowBuilder} instances, each containing up to `maxItemsPerRow` buttons.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* const button1 = new ButtonBuilder().setLabel("A").setCustomId("a").setStyle(ButtonStyle.Primary);
|
|
225
|
+
* const button2 = new ButtonBuilder().setLabel("B").setCustomId("b").setStyle(ButtonStyle.Primary);
|
|
226
|
+
* const button3 = new ButtonBuilder().setLabel("C").setCustomId("c").setStyle(ButtonStyle.Primary);
|
|
227
|
+
*
|
|
228
|
+
* const rows = wrapButtons(2, button1, button2, button3);
|
|
229
|
+
* // Result: Two rows, the first with [button1, button2], the second with [button3]
|
|
230
|
+
*/
|
|
231
|
+
declare function wrapButtons(maxItemsPerRow: number, ...buttons: (ButtonBuilder | ButtonBuilder[])[]): ActionRowBuilder<ButtonBuilder>[];
|
|
185
232
|
|
|
186
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Creates an {@link ActionRowBuilder} containing one or more UI components.
|
|
235
|
+
*
|
|
236
|
+
* This function accepts individual components or arrays of components, flattens them,
|
|
237
|
+
* and returns an action row builder suitable for use in Discord messages.
|
|
238
|
+
* It's designed to support any component builder type that extends {@link AnyComponentBuilder}.
|
|
239
|
+
*
|
|
240
|
+
* ---
|
|
241
|
+
* While this function supports any valid message component (such as buttons, select menus, etc.),
|
|
242
|
+
* the examples below demonstrate common use cases using {@link ButtonBuilder} and {@link StringSelectMenuBuilder}.
|
|
243
|
+
*
|
|
244
|
+
* @typeParam Component - A type extending {@link AnyComponentBuilder}, such as a button or select menu builder.
|
|
245
|
+
*
|
|
246
|
+
* @param components - A variadic list of component instances or arrays of component instances to include in the row.
|
|
247
|
+
*
|
|
248
|
+
* @returns An {@link ActionRowBuilder} instance containing all provided components.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* // Create a row with two buttons
|
|
252
|
+
* const row = createRow(
|
|
253
|
+
* new ButtonBuilder().setCustomId("yes").setLabel("Yes").setStyle(ButtonStyle.Success),
|
|
254
|
+
* new ButtonBuilder().setCustomId("no").setLabel("No").setStyle(ButtonStyle.Danger)
|
|
255
|
+
* );
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* // Create a row with a string select menu
|
|
259
|
+
* const row = createRow([
|
|
260
|
+
* new StringSelectMenuBuilder()
|
|
261
|
+
* .setCustomId("choose")
|
|
262
|
+
* .setPlaceholder("Make a selection")
|
|
263
|
+
* .addOptions(
|
|
264
|
+
* { label: "Option 1", value: "opt1" },
|
|
265
|
+
* { label: "Option 2", value: "opt2" }
|
|
266
|
+
* )
|
|
267
|
+
* ]);
|
|
268
|
+
*/
|
|
269
|
+
declare function createRow<Component extends AnyComponentBuilder>(...components: (Component | Component[])[]): ActionRowBuilder<Component>;
|
|
187
270
|
|
|
188
271
|
type FileSource = string | Attachment | AttachmentBuilder;
|
|
189
272
|
interface CreateFileOptions extends Omit<APIUnfurledMediaItem, "url"> {
|
|
@@ -266,32 +349,42 @@ interface SeparatorData {
|
|
|
266
349
|
large?: boolean;
|
|
267
350
|
}
|
|
268
351
|
/**
|
|
269
|
-
* Creates a {@link SeparatorBuilder} component with
|
|
352
|
+
* Creates a {@link SeparatorBuilder} component with configurable visibility and spacing.
|
|
270
353
|
*
|
|
271
|
-
* This function generates a separator that can be
|
|
272
|
-
*
|
|
273
|
-
*
|
|
354
|
+
* This function generates a separator component that can be customized for:
|
|
355
|
+
* - Visibility (`divider`: whether the visual divider line is shown).
|
|
356
|
+
* - Spacing (`large`: whether to use large or small spacing).
|
|
274
357
|
*
|
|
275
|
-
*
|
|
276
|
-
* - `divider` (optional): If `false`, the separator divider will be disabled and won't be rendered. Default is `true`.
|
|
277
|
-
* - `large` (optional): If `true`, the separator will have a large spacing. Default is `false` (small spacing).
|
|
358
|
+
* It accepts parameters in two formats:
|
|
278
359
|
*
|
|
279
|
-
*
|
|
360
|
+
* **1. As an object:**
|
|
361
|
+
* @param data - An optional object with the following properties:
|
|
362
|
+
* - `divider` (boolean, optional): Whether the divider is visible. Defaults to `true`.
|
|
363
|
+
* - `large` (boolean, optional): Whether to use large spacing. Defaults to `false`.
|
|
364
|
+
*
|
|
365
|
+
* **2. As positional arguments:**
|
|
366
|
+
* @param large - Whether to use large spacing. Defaults to `false`.
|
|
367
|
+
* @param divider - Whether the divider is visible. Defaults to `true`.
|
|
280
368
|
*
|
|
281
369
|
* @returns A {@link SeparatorBuilder} instance with the specified configuration.
|
|
282
370
|
*
|
|
283
371
|
* @example
|
|
284
|
-
* //
|
|
372
|
+
* // Using object syntax with default options
|
|
285
373
|
* const separator = createSeparator();
|
|
286
374
|
*
|
|
287
375
|
* @example
|
|
288
|
-
* //
|
|
289
|
-
* const separator = createSeparator({ divider: false });
|
|
376
|
+
* // Using object syntax to disable the divider and enable large spacing
|
|
377
|
+
* const separator = createSeparator({ divider: false, large: true });
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* // Using positional arguments: large spacing, visible divider
|
|
381
|
+
* const separator = createSeparator(true, true);
|
|
290
382
|
*
|
|
291
383
|
* @example
|
|
292
|
-
* //
|
|
293
|
-
* const separator = createSeparator(
|
|
384
|
+
* // Using positional arguments: small spacing, hidden divider
|
|
385
|
+
* const separator = createSeparator(false, false);
|
|
294
386
|
*/
|
|
387
|
+
declare function createSeparator(large?: boolean, divider?: boolean): SeparatorBuilder;
|
|
295
388
|
declare function createSeparator(data?: SeparatorData): SeparatorBuilder;
|
|
296
389
|
|
|
297
390
|
type ThumbnailData = Partial<Omit<ThumbnailComponentData, "type">> | Attachment | AttachmentBuilder | string;
|
|
@@ -342,46 +435,53 @@ type SectionData = SectionAccessoryData & {
|
|
|
342
435
|
content: string | string[];
|
|
343
436
|
};
|
|
344
437
|
/**
|
|
345
|
-
* Creates a {@link SectionBuilder} component with customizable content
|
|
438
|
+
* Creates a {@link SectionBuilder} component with customizable text content and a single visual accessory.
|
|
346
439
|
*
|
|
347
|
-
* This function
|
|
348
|
-
*
|
|
349
|
-
*
|
|
440
|
+
* This function allows you to generate a section with content (as a string or an array of strings)
|
|
441
|
+
* and optionally include a single accessory, which can be a button or a thumbnail.
|
|
442
|
+
* You can provide the accessory in multiple forms: a builder instance, a plain data object, or a URL string (for thumbnails).
|
|
350
443
|
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
444
|
+
* ---
|
|
445
|
+
* ### Overloads:
|
|
446
|
+
*
|
|
447
|
+
* 1. `createSection(content, accessory)`
|
|
448
|
+
* Pass content as a string and an accessory separately.
|
|
449
|
+
*
|
|
450
|
+
* 2. `createSection({ content, accessory | button | thumbnail })`
|
|
451
|
+
* Pass an object with full configuration, using only one of the accessory types.
|
|
355
452
|
*
|
|
356
|
-
*
|
|
453
|
+
* ---
|
|
357
454
|
*
|
|
358
|
-
* @
|
|
455
|
+
* @param content - The main content of the section. Only used in overload 1.
|
|
456
|
+
* @param accessory - A {@link ButtonBuilder}, {@link ThumbnailBuilder}, or raw data used to build the accessory. Only used in overload 1.
|
|
457
|
+
*
|
|
458
|
+
* @param data - An object in overload 2 containing:
|
|
459
|
+
* - `content`: A string or array of strings for display.
|
|
460
|
+
* - `accessory`: (optional) A single accessory, either a button or thumbnail.
|
|
461
|
+
* - `button`: (optional) A {@link ButtonBuilder} or partial button data. Mutually exclusive with `thumbnail` and `accessory`.
|
|
462
|
+
* - `thumbnail`: (optional) A {@link ThumbnailBuilder}, {@link ThumbnailData}, or image URL. Mutually exclusive with `button` and `accessory`.
|
|
463
|
+
*
|
|
464
|
+
* @returns A configured {@link SectionBuilder} instance with the provided content and accessory.
|
|
359
465
|
*
|
|
360
466
|
* @example
|
|
361
|
-
* //
|
|
362
|
-
* const section = createSection(
|
|
363
|
-
* content: "Welcome to the section!",
|
|
364
|
-
* button: new ButtonBuilder({
|
|
365
|
-
* customId: "welcome/button",
|
|
366
|
-
* label: "Click Me",
|
|
367
|
-
* style: ButtonStyle.Success,
|
|
368
|
-
* }),
|
|
369
|
-
* });
|
|
467
|
+
* // Overload 1: Using content and accessory separately
|
|
468
|
+
* const section = createSection("Hello World", new ButtonBuilder().setLabel("Click"));
|
|
370
469
|
*
|
|
371
470
|
* @example
|
|
372
|
-
* //
|
|
471
|
+
* // Overload 2: Using content and thumbnail URL via `thumbnail`
|
|
373
472
|
* const section = createSection({
|
|
374
|
-
* content: "
|
|
473
|
+
* content: "Here's an image section",
|
|
375
474
|
* thumbnail: "https://example.com/image.png"
|
|
376
475
|
* });
|
|
377
476
|
*
|
|
378
477
|
* @example
|
|
379
|
-
* //
|
|
478
|
+
* // Overload 2: Using content and button via `accessory`
|
|
380
479
|
* const section = createSection({
|
|
381
|
-
* content:
|
|
382
|
-
*
|
|
480
|
+
* content: "Button section",
|
|
481
|
+
* accessory: new ButtonBuilder().setCustomId("id").setLabel("Press").setStyle(ButtonStyle.Primary)
|
|
383
482
|
* });
|
|
384
483
|
*/
|
|
484
|
+
declare function createSection(content: string, accessory: SectionAccessory): SectionBuilder;
|
|
385
485
|
declare function createSection(data: SectionData): SectionBuilder;
|
|
386
486
|
|
|
387
487
|
/**
|
|
@@ -406,7 +506,8 @@ declare function createSection(data: SectionData): SectionBuilder;
|
|
|
406
506
|
declare function createTextDisplay(content: string, id?: number): TextDisplayBuilder;
|
|
407
507
|
|
|
408
508
|
type ComponentData = TextDisplayBuilder | SeparatorBuilder | FileBuilder | SectionBuilder | MediaGalleryBuilder | ActionRowBuilder<MessageActionRowComponentBuilder> | MessageActionRowComponentBuilder[] | MessageActionRowComponentBuilder | Attachment | AttachmentBuilder | string | null | undefined;
|
|
409
|
-
|
|
509
|
+
type CreateComponentData = ComponentData | ContainerBuilder;
|
|
510
|
+
declare function createComponents(...data: (CreateComponentData | CreateComponentData[])[]): (SeparatorBuilder | TextDisplayBuilder | FileBuilder | SectionBuilder | MediaGalleryBuilder | ActionRowBuilder<MessageActionRowComponentBuilder> | ContainerBuilder)[];
|
|
410
511
|
|
|
411
512
|
type ContainerColor = (string & {}) | ColorResolvable;
|
|
412
513
|
interface ContainerData extends Omit<ContainerComponentData, "accentColor" | "type" | "components"> {
|
|
@@ -456,7 +557,7 @@ interface ContainerData extends Omit<ContainerComponentData, "accentColor" | "ty
|
|
|
456
557
|
* const container = createContainer([255, 0, 0], "Red alert");
|
|
457
558
|
*/
|
|
458
559
|
declare function createContainer(data: ContainerData): ContainerBuilder;
|
|
459
|
-
declare function createContainer(data: ColorResolvable | string, ...components: ComponentData[]): ContainerBuilder;
|
|
560
|
+
declare function createContainer(data: ColorResolvable | string, ...components: (ComponentData | ComponentData[])[]): ContainerBuilder;
|
|
460
561
|
|
|
461
562
|
type GuildChannelType = Exclude<ChannelType, ChannelType.DM>;
|
|
462
563
|
type FindChannelFilter<T extends GuildChannelType> = (channel: GetChannelType<T>) => boolean;
|
|
@@ -593,5 +694,5 @@ declare function isAnySelectMenuBuilder(value: unknown): value is AnySelectMenuB
|
|
|
593
694
|
|
|
594
695
|
declare function isButtonBuilder(value: unknown): value is ButtonBuilder;
|
|
595
696
|
|
|
596
|
-
export { CustomItents, CustomPartials, EmbedLimit, EmbedPlusBuilder, chars, commandMention, createComponents, createContainer, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createFile, createLinkButton, createMediaGallery, createModalFields, createModalInput, createRow, createSection, createSeparator, createTextDisplay, createThumbnail, createWebhookClient, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, modalFieldsToRecord, setMobileStatus };
|
|
697
|
+
export { CustomItents, CustomPartials, EmbedLimit, EmbedPlusBuilder, Separator, chars, commandMention, createComponents, createContainer, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createFile, createLinkButton, createMediaGallery, createModalFields, createModalInput, createRow, createSection, createSeparator, createTextDisplay, createThumbnail, createWebhookClient, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, modalFieldsToRecord, setMobileStatus, wrapButtons };
|
|
597
698
|
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentData, ContainerColor, ContainerData, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty, SectionAccessory, SectionAccessoryData, SectionButtonAccessory, SectionData, SectionThumbnailAccessory, SeparatorData, ThumbnailData };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, ButtonBuilder, LinkButtonComponentData, AnyComponentBuilder,
|
|
2
|
+
import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, ButtonBuilder, ActionRowBuilder, LinkButtonComponentData, AnyComponentBuilder, FileBuilder, APIUnfurledMediaItem, MediaGalleryBuilder, MediaGalleryItemData, SeparatorBuilder, ThumbnailComponentData, ThumbnailBuilder, ButtonComponentData, SectionBuilder, TextDisplayBuilder, MessageActionRowComponentBuilder, ContainerBuilder, ContainerComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, TextInputBuilder, ModalSubmitInteraction, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role, WebhookClientOptions, WebhookClient, WebhookClientData, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, ChannelSelectMenuBuilder, MentionableSelectMenuBuilder } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const chars: {
|
|
@@ -31,6 +31,32 @@ declare enum EmbedLimit {
|
|
|
31
31
|
URL = 2048
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Predefined separator spacing variants for quick use.
|
|
36
|
+
*/
|
|
37
|
+
declare const Separator: {
|
|
38
|
+
/**
|
|
39
|
+
* Default separator with small spacing and visible divider.
|
|
40
|
+
* Equivalent to: `createSeparator()`
|
|
41
|
+
*/
|
|
42
|
+
readonly Default: discord_js.SeparatorBuilder;
|
|
43
|
+
/**
|
|
44
|
+
* Separator with large spacing and visible divider.
|
|
45
|
+
* Equivalent to: `createSeparator(true)`
|
|
46
|
+
*/
|
|
47
|
+
readonly Large: discord_js.SeparatorBuilder;
|
|
48
|
+
/**
|
|
49
|
+
* Separator with large spacing and no visible divider.
|
|
50
|
+
* Equivalent to: `createSeparator(true, false)`
|
|
51
|
+
*/
|
|
52
|
+
readonly LargeHidden: discord_js.SeparatorBuilder;
|
|
53
|
+
/**
|
|
54
|
+
* Separator with small spacing and no visible divider.
|
|
55
|
+
* Equivalent to: `createSeparator(false, false)`
|
|
56
|
+
*/
|
|
57
|
+
readonly Hidden: discord_js.SeparatorBuilder;
|
|
58
|
+
};
|
|
59
|
+
|
|
34
60
|
declare function setMobileStatus(): void;
|
|
35
61
|
|
|
36
62
|
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
@@ -182,8 +208,65 @@ declare function createEmbedFiles(embed: EmbedBuilder, options?: CreateEmbedFile
|
|
|
182
208
|
interface CreateLinkButtonData extends Omit<LinkButtonComponentData, "style" | "type"> {
|
|
183
209
|
}
|
|
184
210
|
declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
|
|
211
|
+
/**
|
|
212
|
+
* Wraps buttons into multiple {@link ActionRowBuilder} instances with a maximum number of buttons per row.
|
|
213
|
+
*
|
|
214
|
+
* This function takes a list of {@link ButtonBuilder} instances (or arrays of them) and groups them into
|
|
215
|
+
* multiple `ActionRowBuilder<ButtonBuilder>` objects, ensuring that each row contains no more than the specified
|
|
216
|
+
* number of buttons.
|
|
217
|
+
*
|
|
218
|
+
* @param maxItemsPerRow - The maximum number of buttons to include in each row.
|
|
219
|
+
* @param buttons - A variadic list of {@link ButtonBuilder} instances or arrays of them to be wrapped.
|
|
220
|
+
*
|
|
221
|
+
* @returns An array of {@link ActionRowBuilder} instances, each containing up to `maxItemsPerRow` buttons.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* const button1 = new ButtonBuilder().setLabel("A").setCustomId("a").setStyle(ButtonStyle.Primary);
|
|
225
|
+
* const button2 = new ButtonBuilder().setLabel("B").setCustomId("b").setStyle(ButtonStyle.Primary);
|
|
226
|
+
* const button3 = new ButtonBuilder().setLabel("C").setCustomId("c").setStyle(ButtonStyle.Primary);
|
|
227
|
+
*
|
|
228
|
+
* const rows = wrapButtons(2, button1, button2, button3);
|
|
229
|
+
* // Result: Two rows, the first with [button1, button2], the second with [button3]
|
|
230
|
+
*/
|
|
231
|
+
declare function wrapButtons(maxItemsPerRow: number, ...buttons: (ButtonBuilder | ButtonBuilder[])[]): ActionRowBuilder<ButtonBuilder>[];
|
|
185
232
|
|
|
186
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Creates an {@link ActionRowBuilder} containing one or more UI components.
|
|
235
|
+
*
|
|
236
|
+
* This function accepts individual components or arrays of components, flattens them,
|
|
237
|
+
* and returns an action row builder suitable for use in Discord messages.
|
|
238
|
+
* It's designed to support any component builder type that extends {@link AnyComponentBuilder}.
|
|
239
|
+
*
|
|
240
|
+
* ---
|
|
241
|
+
* While this function supports any valid message component (such as buttons, select menus, etc.),
|
|
242
|
+
* the examples below demonstrate common use cases using {@link ButtonBuilder} and {@link StringSelectMenuBuilder}.
|
|
243
|
+
*
|
|
244
|
+
* @typeParam Component - A type extending {@link AnyComponentBuilder}, such as a button or select menu builder.
|
|
245
|
+
*
|
|
246
|
+
* @param components - A variadic list of component instances or arrays of component instances to include in the row.
|
|
247
|
+
*
|
|
248
|
+
* @returns An {@link ActionRowBuilder} instance containing all provided components.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* // Create a row with two buttons
|
|
252
|
+
* const row = createRow(
|
|
253
|
+
* new ButtonBuilder().setCustomId("yes").setLabel("Yes").setStyle(ButtonStyle.Success),
|
|
254
|
+
* new ButtonBuilder().setCustomId("no").setLabel("No").setStyle(ButtonStyle.Danger)
|
|
255
|
+
* );
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* // Create a row with a string select menu
|
|
259
|
+
* const row = createRow([
|
|
260
|
+
* new StringSelectMenuBuilder()
|
|
261
|
+
* .setCustomId("choose")
|
|
262
|
+
* .setPlaceholder("Make a selection")
|
|
263
|
+
* .addOptions(
|
|
264
|
+
* { label: "Option 1", value: "opt1" },
|
|
265
|
+
* { label: "Option 2", value: "opt2" }
|
|
266
|
+
* )
|
|
267
|
+
* ]);
|
|
268
|
+
*/
|
|
269
|
+
declare function createRow<Component extends AnyComponentBuilder>(...components: (Component | Component[])[]): ActionRowBuilder<Component>;
|
|
187
270
|
|
|
188
271
|
type FileSource = string | Attachment | AttachmentBuilder;
|
|
189
272
|
interface CreateFileOptions extends Omit<APIUnfurledMediaItem, "url"> {
|
|
@@ -266,32 +349,42 @@ interface SeparatorData {
|
|
|
266
349
|
large?: boolean;
|
|
267
350
|
}
|
|
268
351
|
/**
|
|
269
|
-
* Creates a {@link SeparatorBuilder} component with
|
|
352
|
+
* Creates a {@link SeparatorBuilder} component with configurable visibility and spacing.
|
|
270
353
|
*
|
|
271
|
-
* This function generates a separator that can be
|
|
272
|
-
*
|
|
273
|
-
*
|
|
354
|
+
* This function generates a separator component that can be customized for:
|
|
355
|
+
* - Visibility (`divider`: whether the visual divider line is shown).
|
|
356
|
+
* - Spacing (`large`: whether to use large or small spacing).
|
|
274
357
|
*
|
|
275
|
-
*
|
|
276
|
-
* - `divider` (optional): If `false`, the separator divider will be disabled and won't be rendered. Default is `true`.
|
|
277
|
-
* - `large` (optional): If `true`, the separator will have a large spacing. Default is `false` (small spacing).
|
|
358
|
+
* It accepts parameters in two formats:
|
|
278
359
|
*
|
|
279
|
-
*
|
|
360
|
+
* **1. As an object:**
|
|
361
|
+
* @param data - An optional object with the following properties:
|
|
362
|
+
* - `divider` (boolean, optional): Whether the divider is visible. Defaults to `true`.
|
|
363
|
+
* - `large` (boolean, optional): Whether to use large spacing. Defaults to `false`.
|
|
364
|
+
*
|
|
365
|
+
* **2. As positional arguments:**
|
|
366
|
+
* @param large - Whether to use large spacing. Defaults to `false`.
|
|
367
|
+
* @param divider - Whether the divider is visible. Defaults to `true`.
|
|
280
368
|
*
|
|
281
369
|
* @returns A {@link SeparatorBuilder} instance with the specified configuration.
|
|
282
370
|
*
|
|
283
371
|
* @example
|
|
284
|
-
* //
|
|
372
|
+
* // Using object syntax with default options
|
|
285
373
|
* const separator = createSeparator();
|
|
286
374
|
*
|
|
287
375
|
* @example
|
|
288
|
-
* //
|
|
289
|
-
* const separator = createSeparator({ divider: false });
|
|
376
|
+
* // Using object syntax to disable the divider and enable large spacing
|
|
377
|
+
* const separator = createSeparator({ divider: false, large: true });
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* // Using positional arguments: large spacing, visible divider
|
|
381
|
+
* const separator = createSeparator(true, true);
|
|
290
382
|
*
|
|
291
383
|
* @example
|
|
292
|
-
* //
|
|
293
|
-
* const separator = createSeparator(
|
|
384
|
+
* // Using positional arguments: small spacing, hidden divider
|
|
385
|
+
* const separator = createSeparator(false, false);
|
|
294
386
|
*/
|
|
387
|
+
declare function createSeparator(large?: boolean, divider?: boolean): SeparatorBuilder;
|
|
295
388
|
declare function createSeparator(data?: SeparatorData): SeparatorBuilder;
|
|
296
389
|
|
|
297
390
|
type ThumbnailData = Partial<Omit<ThumbnailComponentData, "type">> | Attachment | AttachmentBuilder | string;
|
|
@@ -342,46 +435,53 @@ type SectionData = SectionAccessoryData & {
|
|
|
342
435
|
content: string | string[];
|
|
343
436
|
};
|
|
344
437
|
/**
|
|
345
|
-
* Creates a {@link SectionBuilder} component with customizable content
|
|
438
|
+
* Creates a {@link SectionBuilder} component with customizable text content and a single visual accessory.
|
|
346
439
|
*
|
|
347
|
-
* This function
|
|
348
|
-
*
|
|
349
|
-
*
|
|
440
|
+
* This function allows you to generate a section with content (as a string or an array of strings)
|
|
441
|
+
* and optionally include a single accessory, which can be a button or a thumbnail.
|
|
442
|
+
* You can provide the accessory in multiple forms: a builder instance, a plain data object, or a URL string (for thumbnails).
|
|
350
443
|
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
444
|
+
* ---
|
|
445
|
+
* ### Overloads:
|
|
446
|
+
*
|
|
447
|
+
* 1. `createSection(content, accessory)`
|
|
448
|
+
* Pass content as a string and an accessory separately.
|
|
449
|
+
*
|
|
450
|
+
* 2. `createSection({ content, accessory | button | thumbnail })`
|
|
451
|
+
* Pass an object with full configuration, using only one of the accessory types.
|
|
355
452
|
*
|
|
356
|
-
*
|
|
453
|
+
* ---
|
|
357
454
|
*
|
|
358
|
-
* @
|
|
455
|
+
* @param content - The main content of the section. Only used in overload 1.
|
|
456
|
+
* @param accessory - A {@link ButtonBuilder}, {@link ThumbnailBuilder}, or raw data used to build the accessory. Only used in overload 1.
|
|
457
|
+
*
|
|
458
|
+
* @param data - An object in overload 2 containing:
|
|
459
|
+
* - `content`: A string or array of strings for display.
|
|
460
|
+
* - `accessory`: (optional) A single accessory, either a button or thumbnail.
|
|
461
|
+
* - `button`: (optional) A {@link ButtonBuilder} or partial button data. Mutually exclusive with `thumbnail` and `accessory`.
|
|
462
|
+
* - `thumbnail`: (optional) A {@link ThumbnailBuilder}, {@link ThumbnailData}, or image URL. Mutually exclusive with `button` and `accessory`.
|
|
463
|
+
*
|
|
464
|
+
* @returns A configured {@link SectionBuilder} instance with the provided content and accessory.
|
|
359
465
|
*
|
|
360
466
|
* @example
|
|
361
|
-
* //
|
|
362
|
-
* const section = createSection(
|
|
363
|
-
* content: "Welcome to the section!",
|
|
364
|
-
* button: new ButtonBuilder({
|
|
365
|
-
* customId: "welcome/button",
|
|
366
|
-
* label: "Click Me",
|
|
367
|
-
* style: ButtonStyle.Success,
|
|
368
|
-
* }),
|
|
369
|
-
* });
|
|
467
|
+
* // Overload 1: Using content and accessory separately
|
|
468
|
+
* const section = createSection("Hello World", new ButtonBuilder().setLabel("Click"));
|
|
370
469
|
*
|
|
371
470
|
* @example
|
|
372
|
-
* //
|
|
471
|
+
* // Overload 2: Using content and thumbnail URL via `thumbnail`
|
|
373
472
|
* const section = createSection({
|
|
374
|
-
* content: "
|
|
473
|
+
* content: "Here's an image section",
|
|
375
474
|
* thumbnail: "https://example.com/image.png"
|
|
376
475
|
* });
|
|
377
476
|
*
|
|
378
477
|
* @example
|
|
379
|
-
* //
|
|
478
|
+
* // Overload 2: Using content and button via `accessory`
|
|
380
479
|
* const section = createSection({
|
|
381
|
-
* content:
|
|
382
|
-
*
|
|
480
|
+
* content: "Button section",
|
|
481
|
+
* accessory: new ButtonBuilder().setCustomId("id").setLabel("Press").setStyle(ButtonStyle.Primary)
|
|
383
482
|
* });
|
|
384
483
|
*/
|
|
484
|
+
declare function createSection(content: string, accessory: SectionAccessory): SectionBuilder;
|
|
385
485
|
declare function createSection(data: SectionData): SectionBuilder;
|
|
386
486
|
|
|
387
487
|
/**
|
|
@@ -406,7 +506,8 @@ declare function createSection(data: SectionData): SectionBuilder;
|
|
|
406
506
|
declare function createTextDisplay(content: string, id?: number): TextDisplayBuilder;
|
|
407
507
|
|
|
408
508
|
type ComponentData = TextDisplayBuilder | SeparatorBuilder | FileBuilder | SectionBuilder | MediaGalleryBuilder | ActionRowBuilder<MessageActionRowComponentBuilder> | MessageActionRowComponentBuilder[] | MessageActionRowComponentBuilder | Attachment | AttachmentBuilder | string | null | undefined;
|
|
409
|
-
|
|
509
|
+
type CreateComponentData = ComponentData | ContainerBuilder;
|
|
510
|
+
declare function createComponents(...data: (CreateComponentData | CreateComponentData[])[]): (SeparatorBuilder | TextDisplayBuilder | FileBuilder | SectionBuilder | MediaGalleryBuilder | ActionRowBuilder<MessageActionRowComponentBuilder> | ContainerBuilder)[];
|
|
410
511
|
|
|
411
512
|
type ContainerColor = (string & {}) | ColorResolvable;
|
|
412
513
|
interface ContainerData extends Omit<ContainerComponentData, "accentColor" | "type" | "components"> {
|
|
@@ -456,7 +557,7 @@ interface ContainerData extends Omit<ContainerComponentData, "accentColor" | "ty
|
|
|
456
557
|
* const container = createContainer([255, 0, 0], "Red alert");
|
|
457
558
|
*/
|
|
458
559
|
declare function createContainer(data: ContainerData): ContainerBuilder;
|
|
459
|
-
declare function createContainer(data: ColorResolvable | string, ...components: ComponentData[]): ContainerBuilder;
|
|
560
|
+
declare function createContainer(data: ColorResolvable | string, ...components: (ComponentData | ComponentData[])[]): ContainerBuilder;
|
|
460
561
|
|
|
461
562
|
type GuildChannelType = Exclude<ChannelType, ChannelType.DM>;
|
|
462
563
|
type FindChannelFilter<T extends GuildChannelType> = (channel: GetChannelType<T>) => boolean;
|
|
@@ -593,5 +694,5 @@ declare function isAnySelectMenuBuilder(value: unknown): value is AnySelectMenuB
|
|
|
593
694
|
|
|
594
695
|
declare function isButtonBuilder(value: unknown): value is ButtonBuilder;
|
|
595
696
|
|
|
596
|
-
export { CustomItents, CustomPartials, EmbedLimit, EmbedPlusBuilder, chars, commandMention, createComponents, createContainer, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createFile, createLinkButton, createMediaGallery, createModalFields, createModalInput, createRow, createSection, createSeparator, createTextDisplay, createThumbnail, createWebhookClient, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, modalFieldsToRecord, setMobileStatus };
|
|
697
|
+
export { CustomItents, CustomPartials, EmbedLimit, EmbedPlusBuilder, Separator, chars, commandMention, createComponents, createContainer, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createFile, createLinkButton, createMediaGallery, createModalFields, createModalInput, createRow, createSection, createSeparator, createTextDisplay, createThumbnail, createWebhookClient, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, modalFieldsToRecord, setMobileStatus, wrapButtons };
|
|
597
698
|
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentData, ContainerColor, ContainerData, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty, SectionAccessory, SectionAccessoryData, SectionButtonAccessory, SectionData, SectionThumbnailAccessory, SeparatorData, ThumbnailData };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, ButtonBuilder, LinkButtonComponentData, AnyComponentBuilder,
|
|
2
|
+
import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, ButtonBuilder, ActionRowBuilder, LinkButtonComponentData, AnyComponentBuilder, FileBuilder, APIUnfurledMediaItem, MediaGalleryBuilder, MediaGalleryItemData, SeparatorBuilder, ThumbnailComponentData, ThumbnailBuilder, ButtonComponentData, SectionBuilder, TextDisplayBuilder, MessageActionRowComponentBuilder, ContainerBuilder, ContainerComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, TextInputBuilder, ModalSubmitInteraction, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role, WebhookClientOptions, WebhookClient, WebhookClientData, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, ChannelSelectMenuBuilder, MentionableSelectMenuBuilder } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const chars: {
|
|
@@ -31,6 +31,32 @@ declare enum EmbedLimit {
|
|
|
31
31
|
URL = 2048
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Predefined separator spacing variants for quick use.
|
|
36
|
+
*/
|
|
37
|
+
declare const Separator: {
|
|
38
|
+
/**
|
|
39
|
+
* Default separator with small spacing and visible divider.
|
|
40
|
+
* Equivalent to: `createSeparator()`
|
|
41
|
+
*/
|
|
42
|
+
readonly Default: discord_js.SeparatorBuilder;
|
|
43
|
+
/**
|
|
44
|
+
* Separator with large spacing and visible divider.
|
|
45
|
+
* Equivalent to: `createSeparator(true)`
|
|
46
|
+
*/
|
|
47
|
+
readonly Large: discord_js.SeparatorBuilder;
|
|
48
|
+
/**
|
|
49
|
+
* Separator with large spacing and no visible divider.
|
|
50
|
+
* Equivalent to: `createSeparator(true, false)`
|
|
51
|
+
*/
|
|
52
|
+
readonly LargeHidden: discord_js.SeparatorBuilder;
|
|
53
|
+
/**
|
|
54
|
+
* Separator with small spacing and no visible divider.
|
|
55
|
+
* Equivalent to: `createSeparator(false, false)`
|
|
56
|
+
*/
|
|
57
|
+
readonly Hidden: discord_js.SeparatorBuilder;
|
|
58
|
+
};
|
|
59
|
+
|
|
34
60
|
declare function setMobileStatus(): void;
|
|
35
61
|
|
|
36
62
|
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
@@ -182,8 +208,65 @@ declare function createEmbedFiles(embed: EmbedBuilder, options?: CreateEmbedFile
|
|
|
182
208
|
interface CreateLinkButtonData extends Omit<LinkButtonComponentData, "style" | "type"> {
|
|
183
209
|
}
|
|
184
210
|
declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
|
|
211
|
+
/**
|
|
212
|
+
* Wraps buttons into multiple {@link ActionRowBuilder} instances with a maximum number of buttons per row.
|
|
213
|
+
*
|
|
214
|
+
* This function takes a list of {@link ButtonBuilder} instances (or arrays of them) and groups them into
|
|
215
|
+
* multiple `ActionRowBuilder<ButtonBuilder>` objects, ensuring that each row contains no more than the specified
|
|
216
|
+
* number of buttons.
|
|
217
|
+
*
|
|
218
|
+
* @param maxItemsPerRow - The maximum number of buttons to include in each row.
|
|
219
|
+
* @param buttons - A variadic list of {@link ButtonBuilder} instances or arrays of them to be wrapped.
|
|
220
|
+
*
|
|
221
|
+
* @returns An array of {@link ActionRowBuilder} instances, each containing up to `maxItemsPerRow` buttons.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* const button1 = new ButtonBuilder().setLabel("A").setCustomId("a").setStyle(ButtonStyle.Primary);
|
|
225
|
+
* const button2 = new ButtonBuilder().setLabel("B").setCustomId("b").setStyle(ButtonStyle.Primary);
|
|
226
|
+
* const button3 = new ButtonBuilder().setLabel("C").setCustomId("c").setStyle(ButtonStyle.Primary);
|
|
227
|
+
*
|
|
228
|
+
* const rows = wrapButtons(2, button1, button2, button3);
|
|
229
|
+
* // Result: Two rows, the first with [button1, button2], the second with [button3]
|
|
230
|
+
*/
|
|
231
|
+
declare function wrapButtons(maxItemsPerRow: number, ...buttons: (ButtonBuilder | ButtonBuilder[])[]): ActionRowBuilder<ButtonBuilder>[];
|
|
185
232
|
|
|
186
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Creates an {@link ActionRowBuilder} containing one or more UI components.
|
|
235
|
+
*
|
|
236
|
+
* This function accepts individual components or arrays of components, flattens them,
|
|
237
|
+
* and returns an action row builder suitable for use in Discord messages.
|
|
238
|
+
* It's designed to support any component builder type that extends {@link AnyComponentBuilder}.
|
|
239
|
+
*
|
|
240
|
+
* ---
|
|
241
|
+
* While this function supports any valid message component (such as buttons, select menus, etc.),
|
|
242
|
+
* the examples below demonstrate common use cases using {@link ButtonBuilder} and {@link StringSelectMenuBuilder}.
|
|
243
|
+
*
|
|
244
|
+
* @typeParam Component - A type extending {@link AnyComponentBuilder}, such as a button or select menu builder.
|
|
245
|
+
*
|
|
246
|
+
* @param components - A variadic list of component instances or arrays of component instances to include in the row.
|
|
247
|
+
*
|
|
248
|
+
* @returns An {@link ActionRowBuilder} instance containing all provided components.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* // Create a row with two buttons
|
|
252
|
+
* const row = createRow(
|
|
253
|
+
* new ButtonBuilder().setCustomId("yes").setLabel("Yes").setStyle(ButtonStyle.Success),
|
|
254
|
+
* new ButtonBuilder().setCustomId("no").setLabel("No").setStyle(ButtonStyle.Danger)
|
|
255
|
+
* );
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* // Create a row with a string select menu
|
|
259
|
+
* const row = createRow([
|
|
260
|
+
* new StringSelectMenuBuilder()
|
|
261
|
+
* .setCustomId("choose")
|
|
262
|
+
* .setPlaceholder("Make a selection")
|
|
263
|
+
* .addOptions(
|
|
264
|
+
* { label: "Option 1", value: "opt1" },
|
|
265
|
+
* { label: "Option 2", value: "opt2" }
|
|
266
|
+
* )
|
|
267
|
+
* ]);
|
|
268
|
+
*/
|
|
269
|
+
declare function createRow<Component extends AnyComponentBuilder>(...components: (Component | Component[])[]): ActionRowBuilder<Component>;
|
|
187
270
|
|
|
188
271
|
type FileSource = string | Attachment | AttachmentBuilder;
|
|
189
272
|
interface CreateFileOptions extends Omit<APIUnfurledMediaItem, "url"> {
|
|
@@ -266,32 +349,42 @@ interface SeparatorData {
|
|
|
266
349
|
large?: boolean;
|
|
267
350
|
}
|
|
268
351
|
/**
|
|
269
|
-
* Creates a {@link SeparatorBuilder} component with
|
|
352
|
+
* Creates a {@link SeparatorBuilder} component with configurable visibility and spacing.
|
|
270
353
|
*
|
|
271
|
-
* This function generates a separator that can be
|
|
272
|
-
*
|
|
273
|
-
*
|
|
354
|
+
* This function generates a separator component that can be customized for:
|
|
355
|
+
* - Visibility (`divider`: whether the visual divider line is shown).
|
|
356
|
+
* - Spacing (`large`: whether to use large or small spacing).
|
|
274
357
|
*
|
|
275
|
-
*
|
|
276
|
-
* - `divider` (optional): If `false`, the separator divider will be disabled and won't be rendered. Default is `true`.
|
|
277
|
-
* - `large` (optional): If `true`, the separator will have a large spacing. Default is `false` (small spacing).
|
|
358
|
+
* It accepts parameters in two formats:
|
|
278
359
|
*
|
|
279
|
-
*
|
|
360
|
+
* **1. As an object:**
|
|
361
|
+
* @param data - An optional object with the following properties:
|
|
362
|
+
* - `divider` (boolean, optional): Whether the divider is visible. Defaults to `true`.
|
|
363
|
+
* - `large` (boolean, optional): Whether to use large spacing. Defaults to `false`.
|
|
364
|
+
*
|
|
365
|
+
* **2. As positional arguments:**
|
|
366
|
+
* @param large - Whether to use large spacing. Defaults to `false`.
|
|
367
|
+
* @param divider - Whether the divider is visible. Defaults to `true`.
|
|
280
368
|
*
|
|
281
369
|
* @returns A {@link SeparatorBuilder} instance with the specified configuration.
|
|
282
370
|
*
|
|
283
371
|
* @example
|
|
284
|
-
* //
|
|
372
|
+
* // Using object syntax with default options
|
|
285
373
|
* const separator = createSeparator();
|
|
286
374
|
*
|
|
287
375
|
* @example
|
|
288
|
-
* //
|
|
289
|
-
* const separator = createSeparator({ divider: false });
|
|
376
|
+
* // Using object syntax to disable the divider and enable large spacing
|
|
377
|
+
* const separator = createSeparator({ divider: false, large: true });
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* // Using positional arguments: large spacing, visible divider
|
|
381
|
+
* const separator = createSeparator(true, true);
|
|
290
382
|
*
|
|
291
383
|
* @example
|
|
292
|
-
* //
|
|
293
|
-
* const separator = createSeparator(
|
|
384
|
+
* // Using positional arguments: small spacing, hidden divider
|
|
385
|
+
* const separator = createSeparator(false, false);
|
|
294
386
|
*/
|
|
387
|
+
declare function createSeparator(large?: boolean, divider?: boolean): SeparatorBuilder;
|
|
295
388
|
declare function createSeparator(data?: SeparatorData): SeparatorBuilder;
|
|
296
389
|
|
|
297
390
|
type ThumbnailData = Partial<Omit<ThumbnailComponentData, "type">> | Attachment | AttachmentBuilder | string;
|
|
@@ -342,46 +435,53 @@ type SectionData = SectionAccessoryData & {
|
|
|
342
435
|
content: string | string[];
|
|
343
436
|
};
|
|
344
437
|
/**
|
|
345
|
-
* Creates a {@link SectionBuilder} component with customizable content
|
|
438
|
+
* Creates a {@link SectionBuilder} component with customizable text content and a single visual accessory.
|
|
346
439
|
*
|
|
347
|
-
* This function
|
|
348
|
-
*
|
|
349
|
-
*
|
|
440
|
+
* This function allows you to generate a section with content (as a string or an array of strings)
|
|
441
|
+
* and optionally include a single accessory, which can be a button or a thumbnail.
|
|
442
|
+
* You can provide the accessory in multiple forms: a builder instance, a plain data object, or a URL string (for thumbnails).
|
|
350
443
|
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
444
|
+
* ---
|
|
445
|
+
* ### Overloads:
|
|
446
|
+
*
|
|
447
|
+
* 1. `createSection(content, accessory)`
|
|
448
|
+
* Pass content as a string and an accessory separately.
|
|
449
|
+
*
|
|
450
|
+
* 2. `createSection({ content, accessory | button | thumbnail })`
|
|
451
|
+
* Pass an object with full configuration, using only one of the accessory types.
|
|
355
452
|
*
|
|
356
|
-
*
|
|
453
|
+
* ---
|
|
357
454
|
*
|
|
358
|
-
* @
|
|
455
|
+
* @param content - The main content of the section. Only used in overload 1.
|
|
456
|
+
* @param accessory - A {@link ButtonBuilder}, {@link ThumbnailBuilder}, or raw data used to build the accessory. Only used in overload 1.
|
|
457
|
+
*
|
|
458
|
+
* @param data - An object in overload 2 containing:
|
|
459
|
+
* - `content`: A string or array of strings for display.
|
|
460
|
+
* - `accessory`: (optional) A single accessory, either a button or thumbnail.
|
|
461
|
+
* - `button`: (optional) A {@link ButtonBuilder} or partial button data. Mutually exclusive with `thumbnail` and `accessory`.
|
|
462
|
+
* - `thumbnail`: (optional) A {@link ThumbnailBuilder}, {@link ThumbnailData}, or image URL. Mutually exclusive with `button` and `accessory`.
|
|
463
|
+
*
|
|
464
|
+
* @returns A configured {@link SectionBuilder} instance with the provided content and accessory.
|
|
359
465
|
*
|
|
360
466
|
* @example
|
|
361
|
-
* //
|
|
362
|
-
* const section = createSection(
|
|
363
|
-
* content: "Welcome to the section!",
|
|
364
|
-
* button: new ButtonBuilder({
|
|
365
|
-
* customId: "welcome/button",
|
|
366
|
-
* label: "Click Me",
|
|
367
|
-
* style: ButtonStyle.Success,
|
|
368
|
-
* }),
|
|
369
|
-
* });
|
|
467
|
+
* // Overload 1: Using content and accessory separately
|
|
468
|
+
* const section = createSection("Hello World", new ButtonBuilder().setLabel("Click"));
|
|
370
469
|
*
|
|
371
470
|
* @example
|
|
372
|
-
* //
|
|
471
|
+
* // Overload 2: Using content and thumbnail URL via `thumbnail`
|
|
373
472
|
* const section = createSection({
|
|
374
|
-
* content: "
|
|
473
|
+
* content: "Here's an image section",
|
|
375
474
|
* thumbnail: "https://example.com/image.png"
|
|
376
475
|
* });
|
|
377
476
|
*
|
|
378
477
|
* @example
|
|
379
|
-
* //
|
|
478
|
+
* // Overload 2: Using content and button via `accessory`
|
|
380
479
|
* const section = createSection({
|
|
381
|
-
* content:
|
|
382
|
-
*
|
|
480
|
+
* content: "Button section",
|
|
481
|
+
* accessory: new ButtonBuilder().setCustomId("id").setLabel("Press").setStyle(ButtonStyle.Primary)
|
|
383
482
|
* });
|
|
384
483
|
*/
|
|
484
|
+
declare function createSection(content: string, accessory: SectionAccessory): SectionBuilder;
|
|
385
485
|
declare function createSection(data: SectionData): SectionBuilder;
|
|
386
486
|
|
|
387
487
|
/**
|
|
@@ -406,7 +506,8 @@ declare function createSection(data: SectionData): SectionBuilder;
|
|
|
406
506
|
declare function createTextDisplay(content: string, id?: number): TextDisplayBuilder;
|
|
407
507
|
|
|
408
508
|
type ComponentData = TextDisplayBuilder | SeparatorBuilder | FileBuilder | SectionBuilder | MediaGalleryBuilder | ActionRowBuilder<MessageActionRowComponentBuilder> | MessageActionRowComponentBuilder[] | MessageActionRowComponentBuilder | Attachment | AttachmentBuilder | string | null | undefined;
|
|
409
|
-
|
|
509
|
+
type CreateComponentData = ComponentData | ContainerBuilder;
|
|
510
|
+
declare function createComponents(...data: (CreateComponentData | CreateComponentData[])[]): (SeparatorBuilder | TextDisplayBuilder | FileBuilder | SectionBuilder | MediaGalleryBuilder | ActionRowBuilder<MessageActionRowComponentBuilder> | ContainerBuilder)[];
|
|
410
511
|
|
|
411
512
|
type ContainerColor = (string & {}) | ColorResolvable;
|
|
412
513
|
interface ContainerData extends Omit<ContainerComponentData, "accentColor" | "type" | "components"> {
|
|
@@ -456,7 +557,7 @@ interface ContainerData extends Omit<ContainerComponentData, "accentColor" | "ty
|
|
|
456
557
|
* const container = createContainer([255, 0, 0], "Red alert");
|
|
457
558
|
*/
|
|
458
559
|
declare function createContainer(data: ContainerData): ContainerBuilder;
|
|
459
|
-
declare function createContainer(data: ColorResolvable | string, ...components: ComponentData[]): ContainerBuilder;
|
|
560
|
+
declare function createContainer(data: ColorResolvable | string, ...components: (ComponentData | ComponentData[])[]): ContainerBuilder;
|
|
460
561
|
|
|
461
562
|
type GuildChannelType = Exclude<ChannelType, ChannelType.DM>;
|
|
462
563
|
type FindChannelFilter<T extends GuildChannelType> = (channel: GetChannelType<T>) => boolean;
|
|
@@ -593,5 +694,5 @@ declare function isAnySelectMenuBuilder(value: unknown): value is AnySelectMenuB
|
|
|
593
694
|
|
|
594
695
|
declare function isButtonBuilder(value: unknown): value is ButtonBuilder;
|
|
595
696
|
|
|
596
|
-
export { CustomItents, CustomPartials, EmbedLimit, EmbedPlusBuilder, chars, commandMention, createComponents, createContainer, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createFile, createLinkButton, createMediaGallery, createModalFields, createModalInput, createRow, createSection, createSeparator, createTextDisplay, createThumbnail, createWebhookClient, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, modalFieldsToRecord, setMobileStatus };
|
|
697
|
+
export { CustomItents, CustomPartials, EmbedLimit, EmbedPlusBuilder, Separator, chars, commandMention, createComponents, createContainer, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createFile, createLinkButton, createMediaGallery, createModalFields, createModalInput, createRow, createSection, createSeparator, createTextDisplay, createThumbnail, createWebhookClient, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, isAnySelectMenuBuilder, isAttachment, isButtonBuilder, modalFieldsToRecord, setMobileStatus, wrapButtons };
|
|
597
698
|
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentData, ContainerColor, ContainerData, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty, SectionAccessory, SectionAccessoryData, SectionButtonAccessory, SectionData, SectionThumbnailAccessory, SeparatorData, ThumbnailData };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export { chars } from './constants/chars.mjs';
|
|
2
2
|
export { CustomItents, CustomPartials } from './constants/client.mjs';
|
|
3
3
|
export { EmbedLimit } from './constants/embed.mjs';
|
|
4
|
+
export { Separator } from './constants/separator.mjs';
|
|
4
5
|
export { setMobileStatus } from './functions/misc.mjs';
|
|
5
6
|
export { createEmbedAsset } from './functions/embeds/assets.mjs';
|
|
6
7
|
export { createEmbedAuthor } from './functions/embeds/author.mjs';
|
|
7
8
|
export { EmbedPlusBuilder, createEmbed } from './functions/embeds/embedplus.mjs';
|
|
8
9
|
export { createEmbedFooter } from './functions/embeds/footer.mjs';
|
|
9
10
|
export { createEmbedFiles } from './functions/embeds/files.mjs';
|
|
10
|
-
export { createLinkButton } from './functions/components/buttons.mjs';
|
|
11
|
+
export { createLinkButton, wrapButtons } from './functions/components/buttons.mjs';
|
|
11
12
|
export { createRow } from './functions/components/row.mjs';
|
|
12
13
|
export { createFile } from './functions/components/file.mjs';
|
|
13
14
|
export { createMediaGallery } from './functions/components/gallery.mjs';
|