@magicyan/discord 1.4.4 → 1.4.6
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/container.cjs +23 -7
- package/dist/functions/components/container.mjs +24 -8
- package/dist/index.d.cts +33 -47
- package/dist/index.d.mts +33 -47
- package/dist/index.d.ts +33 -47
- package/package.json +2 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const core = require('@magicyan/core');
|
|
4
3
|
const discord_js = require('discord.js');
|
|
5
4
|
const attachment = require('../../guards/attachment.cjs');
|
|
6
5
|
const selectmenu = require('../../guards/selectmenu.cjs');
|
|
@@ -8,14 +7,11 @@ const gallery = require('./gallery.cjs');
|
|
|
8
7
|
const row = require('./row.cjs');
|
|
9
8
|
const text = require('./text.cjs');
|
|
10
9
|
|
|
11
|
-
function createContainer(data) {
|
|
10
|
+
function createContainer(data, ...components) {
|
|
12
11
|
const container = new discord_js.ContainerBuilder();
|
|
13
|
-
|
|
14
|
-
typeof data.accentColor === "string" ? data.accentColor in discord_js.Colors ? discord_js.Colors[data.accentColor] : core.hexToRgb(data.accentColor) : data.accentColor
|
|
15
|
-
);
|
|
16
|
-
for (const component of data.components) {
|
|
12
|
+
const addComponent = (component) => {
|
|
17
13
|
if (!component)
|
|
18
|
-
|
|
14
|
+
return;
|
|
19
15
|
if (typeof component === "string") {
|
|
20
16
|
container.addTextDisplayComponents(
|
|
21
17
|
text.createTextDisplay(component)
|
|
@@ -56,7 +52,27 @@ function createContainer(data) {
|
|
|
56
52
|
if (component instanceof discord_js.SeparatorBuilder) {
|
|
57
53
|
container.addSeparatorComponents(component);
|
|
58
54
|
}
|
|
55
|
+
};
|
|
56
|
+
const setColor = (color) => {
|
|
57
|
+
container.setAccentColor(
|
|
58
|
+
discord_js.resolveColor(color)
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
const isContainerData = (value) => typeof value === "object" && "components" in value && Array.isArray(value.components);
|
|
62
|
+
if (isContainerData(data)) {
|
|
63
|
+
if (data.accentColor)
|
|
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);
|
|
69
|
+
for (const component of data.components)
|
|
70
|
+
addComponent(component);
|
|
71
|
+
return container;
|
|
59
72
|
}
|
|
73
|
+
setColor(data);
|
|
74
|
+
for (const component of components)
|
|
75
|
+
addComponent(component);
|
|
60
76
|
return container;
|
|
61
77
|
}
|
|
62
78
|
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ContainerBuilder, Colors, TextDisplayBuilder, ActionRowBuilder, ButtonBuilder, SectionBuilder, FileBuilder, MediaGalleryBuilder, SeparatorBuilder } from 'discord.js';
|
|
1
|
+
import { ContainerBuilder, TextDisplayBuilder, ActionRowBuilder, ButtonBuilder, SectionBuilder, FileBuilder, MediaGalleryBuilder, SeparatorBuilder, resolveColor } from 'discord.js';
|
|
3
2
|
import { isAttachment } from '../../guards/attachment.mjs';
|
|
4
3
|
import { isAnySelectMenuBuilder } from '../../guards/selectmenu.mjs';
|
|
5
4
|
import { createMediaGallery } from './gallery.mjs';
|
|
6
5
|
import { createRow } from './row.mjs';
|
|
7
6
|
import { createTextDisplay } from './text.mjs';
|
|
8
7
|
|
|
9
|
-
function createContainer(data) {
|
|
8
|
+
function createContainer(data, ...components) {
|
|
10
9
|
const container = new ContainerBuilder();
|
|
11
|
-
|
|
12
|
-
typeof data.accentColor === "string" ? data.accentColor in Colors ? Colors[data.accentColor] : hexToRgb(data.accentColor) : data.accentColor
|
|
13
|
-
);
|
|
14
|
-
for (const component of data.components) {
|
|
10
|
+
const addComponent = (component) => {
|
|
15
11
|
if (!component)
|
|
16
|
-
|
|
12
|
+
return;
|
|
17
13
|
if (typeof component === "string") {
|
|
18
14
|
container.addTextDisplayComponents(
|
|
19
15
|
createTextDisplay(component)
|
|
@@ -54,7 +50,27 @@ function createContainer(data) {
|
|
|
54
50
|
if (component instanceof SeparatorBuilder) {
|
|
55
51
|
container.addSeparatorComponents(component);
|
|
56
52
|
}
|
|
53
|
+
};
|
|
54
|
+
const setColor = (color) => {
|
|
55
|
+
container.setAccentColor(
|
|
56
|
+
resolveColor(color)
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
const isContainerData = (value) => typeof value === "object" && "components" in value && Array.isArray(value.components);
|
|
60
|
+
if (isContainerData(data)) {
|
|
61
|
+
if (data.accentColor)
|
|
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);
|
|
67
|
+
for (const component of data.components)
|
|
68
|
+
addComponent(component);
|
|
69
|
+
return container;
|
|
57
70
|
}
|
|
71
|
+
setColor(data);
|
|
72
|
+
for (const component of components)
|
|
73
|
+
addComponent(component);
|
|
58
74
|
return container;
|
|
59
75
|
}
|
|
60
76
|
|
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, ActionRowBuilder, FileBuilder, APIUnfurledMediaItem, MediaGalleryBuilder, MediaGalleryItemData, SeparatorBuilder, ThumbnailComponentData, ThumbnailBuilder, ButtonComponentData, SectionBuilder, TextDisplayBuilder, MessageActionRowComponentBuilder, ContainerBuilder,
|
|
2
|
+
import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, ButtonBuilder, LinkButtonComponentData, AnyComponentBuilder, ActionRowBuilder, 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: {
|
|
@@ -406,71 +406,57 @@ declare function createSection(data: SectionData): SectionBuilder;
|
|
|
406
406
|
declare function createTextDisplay(content: string, id?: number): TextDisplayBuilder;
|
|
407
407
|
|
|
408
408
|
type ComponentData = TextDisplayBuilder | SeparatorBuilder | FileBuilder | SectionBuilder | MediaGalleryBuilder | ActionRowBuilder<MessageActionRowComponentBuilder> | MessageActionRowComponentBuilder[] | MessageActionRowComponentBuilder | Attachment | AttachmentBuilder | string | null | undefined;
|
|
409
|
-
declare function createComponents(...data: (ComponentData | ContainerBuilder)[]): (
|
|
409
|
+
declare function createComponents(...data: (ComponentData | ContainerBuilder)[]): (SeparatorBuilder | TextDisplayBuilder | FileBuilder | SectionBuilder | MediaGalleryBuilder | ActionRowBuilder<MessageActionRowComponentBuilder> | ContainerBuilder)[];
|
|
410
410
|
|
|
411
|
-
type
|
|
412
|
-
type ContainerColor = (string & {}) | number | null | RGBTuple | PresetColor;
|
|
411
|
+
type ContainerColor = (string & {}) | ColorResolvable;
|
|
413
412
|
interface ContainerData extends Omit<ContainerComponentData, "accentColor" | "type" | "components"> {
|
|
414
413
|
accentColor?: ContainerColor;
|
|
415
414
|
components: ComponentData[];
|
|
416
415
|
}
|
|
417
416
|
/**
|
|
418
|
-
* Creates a {@link ContainerBuilder} component with
|
|
417
|
+
* Creates a {@link ContainerBuilder} component with optional accent color and a set of child components.
|
|
419
418
|
*
|
|
420
|
-
* This function
|
|
421
|
-
*
|
|
422
|
-
*
|
|
419
|
+
* This function can be used in two ways:
|
|
420
|
+
* 1. By passing an object with `accentColor` and `components` properties.
|
|
421
|
+
* 2. By passing the `accentColor` directly followed by a list of components.
|
|
423
422
|
*
|
|
424
|
-
*
|
|
425
|
-
* - `
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
* -
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
423
|
+
* The container can include various types of components such as:
|
|
424
|
+
* - `string` (converted to `TextDisplayBuilder`)
|
|
425
|
+
* - {@link TextDisplayBuilder}
|
|
426
|
+
* - {@link ActionRowBuilder}
|
|
427
|
+
* - Arrays of components (converted to an action row)
|
|
428
|
+
* - {@link ButtonBuilder}
|
|
429
|
+
* - {@link SectionBuilder}
|
|
430
|
+
* - {@link MediaGalleryBuilder}
|
|
431
|
+
* - {@link FileBuilder}
|
|
432
|
+
* - {@link SeparatorBuilder}
|
|
433
|
+
* - Discord attachments (treated as media galleries)
|
|
434
434
|
*
|
|
435
|
-
* @param data -
|
|
435
|
+
* @param data - Either a `ContainerData` object containing `accentColor` and `components`, or the accent color directly.
|
|
436
|
+
* @param components - When using the overload with accent color as the first parameter, this is the list of components to include in the container.
|
|
436
437
|
*
|
|
437
|
-
* @returns A {@link ContainerBuilder} instance with
|
|
438
|
+
* @returns A {@link ContainerBuilder} instance with all components and styles applied.
|
|
438
439
|
*
|
|
439
440
|
* @example
|
|
440
|
-
* //
|
|
441
|
+
* // Using ContainerData object
|
|
441
442
|
* const container = createContainer({
|
|
442
|
-
* accentColor: "#ff5733",
|
|
443
|
-
* components: [
|
|
444
|
-
* "This is a text display component"
|
|
445
|
-
* ]
|
|
443
|
+
* accentColor: "#ff5733",
|
|
444
|
+
* components: ["Welcome to the app!"]
|
|
446
445
|
* });
|
|
447
446
|
*
|
|
448
447
|
* @example
|
|
449
|
-
* //
|
|
450
|
-
* const container = createContainer(
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* content: "-# Increment counter",
|
|
455
|
-
* button: new ButtonBuilder({
|
|
456
|
-
* customId: `counter/increment`,
|
|
457
|
-
* label: "+",
|
|
458
|
-
* style: ButtonStyle.Success
|
|
459
|
-
* })
|
|
460
|
-
* }),
|
|
461
|
-
* ]
|
|
462
|
-
* });
|
|
448
|
+
* // Using color and components as separate arguments
|
|
449
|
+
* const container = createContainer("Red",
|
|
450
|
+
* new TextDisplayBuilder().setText("Alert!"),
|
|
451
|
+
* new SeparatorBuilder()
|
|
452
|
+
* );
|
|
463
453
|
*
|
|
464
454
|
* @example
|
|
465
|
-
* //
|
|
466
|
-
* const container = createContainer(
|
|
467
|
-
* accentColor: [255, 87, 51], // RGB tuple
|
|
468
|
-
* components: [
|
|
469
|
-
* "Here's some content."
|
|
470
|
-
* ]
|
|
471
|
-
* });
|
|
455
|
+
* // Using RGB tuple
|
|
456
|
+
* const container = createContainer([255, 0, 0], "Red alert");
|
|
472
457
|
*/
|
|
473
458
|
declare function createContainer(data: ContainerData): ContainerBuilder;
|
|
459
|
+
declare function createContainer(data: ColorResolvable | string, ...components: ComponentData[]): ContainerBuilder;
|
|
474
460
|
|
|
475
461
|
type GuildChannelType = Exclude<ChannelType, ChannelType.DM>;
|
|
476
462
|
type FindChannelFilter<T extends GuildChannelType> = (channel: GetChannelType<T>) => boolean;
|
|
@@ -608,4 +594,4 @@ declare function isAnySelectMenuBuilder(value: unknown): value is AnySelectMenuB
|
|
|
608
594
|
declare function isButtonBuilder(value: unknown): value is ButtonBuilder;
|
|
609
595
|
|
|
610
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 };
|
|
611
|
-
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentData, ContainerColor, ContainerData, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty,
|
|
597
|
+
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, ActionRowBuilder, FileBuilder, APIUnfurledMediaItem, MediaGalleryBuilder, MediaGalleryItemData, SeparatorBuilder, ThumbnailComponentData, ThumbnailBuilder, ButtonComponentData, SectionBuilder, TextDisplayBuilder, MessageActionRowComponentBuilder, ContainerBuilder,
|
|
2
|
+
import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, ButtonBuilder, LinkButtonComponentData, AnyComponentBuilder, ActionRowBuilder, 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: {
|
|
@@ -406,71 +406,57 @@ declare function createSection(data: SectionData): SectionBuilder;
|
|
|
406
406
|
declare function createTextDisplay(content: string, id?: number): TextDisplayBuilder;
|
|
407
407
|
|
|
408
408
|
type ComponentData = TextDisplayBuilder | SeparatorBuilder | FileBuilder | SectionBuilder | MediaGalleryBuilder | ActionRowBuilder<MessageActionRowComponentBuilder> | MessageActionRowComponentBuilder[] | MessageActionRowComponentBuilder | Attachment | AttachmentBuilder | string | null | undefined;
|
|
409
|
-
declare function createComponents(...data: (ComponentData | ContainerBuilder)[]): (
|
|
409
|
+
declare function createComponents(...data: (ComponentData | ContainerBuilder)[]): (SeparatorBuilder | TextDisplayBuilder | FileBuilder | SectionBuilder | MediaGalleryBuilder | ActionRowBuilder<MessageActionRowComponentBuilder> | ContainerBuilder)[];
|
|
410
410
|
|
|
411
|
-
type
|
|
412
|
-
type ContainerColor = (string & {}) | number | null | RGBTuple | PresetColor;
|
|
411
|
+
type ContainerColor = (string & {}) | ColorResolvable;
|
|
413
412
|
interface ContainerData extends Omit<ContainerComponentData, "accentColor" | "type" | "components"> {
|
|
414
413
|
accentColor?: ContainerColor;
|
|
415
414
|
components: ComponentData[];
|
|
416
415
|
}
|
|
417
416
|
/**
|
|
418
|
-
* Creates a {@link ContainerBuilder} component with
|
|
417
|
+
* Creates a {@link ContainerBuilder} component with optional accent color and a set of child components.
|
|
419
418
|
*
|
|
420
|
-
* This function
|
|
421
|
-
*
|
|
422
|
-
*
|
|
419
|
+
* This function can be used in two ways:
|
|
420
|
+
* 1. By passing an object with `accentColor` and `components` properties.
|
|
421
|
+
* 2. By passing the `accentColor` directly followed by a list of components.
|
|
423
422
|
*
|
|
424
|
-
*
|
|
425
|
-
* - `
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
* -
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
423
|
+
* The container can include various types of components such as:
|
|
424
|
+
* - `string` (converted to `TextDisplayBuilder`)
|
|
425
|
+
* - {@link TextDisplayBuilder}
|
|
426
|
+
* - {@link ActionRowBuilder}
|
|
427
|
+
* - Arrays of components (converted to an action row)
|
|
428
|
+
* - {@link ButtonBuilder}
|
|
429
|
+
* - {@link SectionBuilder}
|
|
430
|
+
* - {@link MediaGalleryBuilder}
|
|
431
|
+
* - {@link FileBuilder}
|
|
432
|
+
* - {@link SeparatorBuilder}
|
|
433
|
+
* - Discord attachments (treated as media galleries)
|
|
434
434
|
*
|
|
435
|
-
* @param data -
|
|
435
|
+
* @param data - Either a `ContainerData` object containing `accentColor` and `components`, or the accent color directly.
|
|
436
|
+
* @param components - When using the overload with accent color as the first parameter, this is the list of components to include in the container.
|
|
436
437
|
*
|
|
437
|
-
* @returns A {@link ContainerBuilder} instance with
|
|
438
|
+
* @returns A {@link ContainerBuilder} instance with all components and styles applied.
|
|
438
439
|
*
|
|
439
440
|
* @example
|
|
440
|
-
* //
|
|
441
|
+
* // Using ContainerData object
|
|
441
442
|
* const container = createContainer({
|
|
442
|
-
* accentColor: "#ff5733",
|
|
443
|
-
* components: [
|
|
444
|
-
* "This is a text display component"
|
|
445
|
-
* ]
|
|
443
|
+
* accentColor: "#ff5733",
|
|
444
|
+
* components: ["Welcome to the app!"]
|
|
446
445
|
* });
|
|
447
446
|
*
|
|
448
447
|
* @example
|
|
449
|
-
* //
|
|
450
|
-
* const container = createContainer(
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* content: "-# Increment counter",
|
|
455
|
-
* button: new ButtonBuilder({
|
|
456
|
-
* customId: `counter/increment`,
|
|
457
|
-
* label: "+",
|
|
458
|
-
* style: ButtonStyle.Success
|
|
459
|
-
* })
|
|
460
|
-
* }),
|
|
461
|
-
* ]
|
|
462
|
-
* });
|
|
448
|
+
* // Using color and components as separate arguments
|
|
449
|
+
* const container = createContainer("Red",
|
|
450
|
+
* new TextDisplayBuilder().setText("Alert!"),
|
|
451
|
+
* new SeparatorBuilder()
|
|
452
|
+
* );
|
|
463
453
|
*
|
|
464
454
|
* @example
|
|
465
|
-
* //
|
|
466
|
-
* const container = createContainer(
|
|
467
|
-
* accentColor: [255, 87, 51], // RGB tuple
|
|
468
|
-
* components: [
|
|
469
|
-
* "Here's some content."
|
|
470
|
-
* ]
|
|
471
|
-
* });
|
|
455
|
+
* // Using RGB tuple
|
|
456
|
+
* const container = createContainer([255, 0, 0], "Red alert");
|
|
472
457
|
*/
|
|
473
458
|
declare function createContainer(data: ContainerData): ContainerBuilder;
|
|
459
|
+
declare function createContainer(data: ColorResolvable | string, ...components: ComponentData[]): ContainerBuilder;
|
|
474
460
|
|
|
475
461
|
type GuildChannelType = Exclude<ChannelType, ChannelType.DM>;
|
|
476
462
|
type FindChannelFilter<T extends GuildChannelType> = (channel: GetChannelType<T>) => boolean;
|
|
@@ -608,4 +594,4 @@ declare function isAnySelectMenuBuilder(value: unknown): value is AnySelectMenuB
|
|
|
608
594
|
declare function isButtonBuilder(value: unknown): value is ButtonBuilder;
|
|
609
595
|
|
|
610
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 };
|
|
611
|
-
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentData, ContainerColor, ContainerData, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty,
|
|
597
|
+
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, ActionRowBuilder, FileBuilder, APIUnfurledMediaItem, MediaGalleryBuilder, MediaGalleryItemData, SeparatorBuilder, ThumbnailComponentData, ThumbnailBuilder, ButtonComponentData, SectionBuilder, TextDisplayBuilder, MessageActionRowComponentBuilder, ContainerBuilder,
|
|
2
|
+
import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, ButtonBuilder, LinkButtonComponentData, AnyComponentBuilder, ActionRowBuilder, 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: {
|
|
@@ -406,71 +406,57 @@ declare function createSection(data: SectionData): SectionBuilder;
|
|
|
406
406
|
declare function createTextDisplay(content: string, id?: number): TextDisplayBuilder;
|
|
407
407
|
|
|
408
408
|
type ComponentData = TextDisplayBuilder | SeparatorBuilder | FileBuilder | SectionBuilder | MediaGalleryBuilder | ActionRowBuilder<MessageActionRowComponentBuilder> | MessageActionRowComponentBuilder[] | MessageActionRowComponentBuilder | Attachment | AttachmentBuilder | string | null | undefined;
|
|
409
|
-
declare function createComponents(...data: (ComponentData | ContainerBuilder)[]): (
|
|
409
|
+
declare function createComponents(...data: (ComponentData | ContainerBuilder)[]): (SeparatorBuilder | TextDisplayBuilder | FileBuilder | SectionBuilder | MediaGalleryBuilder | ActionRowBuilder<MessageActionRowComponentBuilder> | ContainerBuilder)[];
|
|
410
410
|
|
|
411
|
-
type
|
|
412
|
-
type ContainerColor = (string & {}) | number | null | RGBTuple | PresetColor;
|
|
411
|
+
type ContainerColor = (string & {}) | ColorResolvable;
|
|
413
412
|
interface ContainerData extends Omit<ContainerComponentData, "accentColor" | "type" | "components"> {
|
|
414
413
|
accentColor?: ContainerColor;
|
|
415
414
|
components: ComponentData[];
|
|
416
415
|
}
|
|
417
416
|
/**
|
|
418
|
-
* Creates a {@link ContainerBuilder} component with
|
|
417
|
+
* Creates a {@link ContainerBuilder} component with optional accent color and a set of child components.
|
|
419
418
|
*
|
|
420
|
-
* This function
|
|
421
|
-
*
|
|
422
|
-
*
|
|
419
|
+
* This function can be used in two ways:
|
|
420
|
+
* 1. By passing an object with `accentColor` and `components` properties.
|
|
421
|
+
* 2. By passing the `accentColor` directly followed by a list of components.
|
|
423
422
|
*
|
|
424
|
-
*
|
|
425
|
-
* - `
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
* -
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
423
|
+
* The container can include various types of components such as:
|
|
424
|
+
* - `string` (converted to `TextDisplayBuilder`)
|
|
425
|
+
* - {@link TextDisplayBuilder}
|
|
426
|
+
* - {@link ActionRowBuilder}
|
|
427
|
+
* - Arrays of components (converted to an action row)
|
|
428
|
+
* - {@link ButtonBuilder}
|
|
429
|
+
* - {@link SectionBuilder}
|
|
430
|
+
* - {@link MediaGalleryBuilder}
|
|
431
|
+
* - {@link FileBuilder}
|
|
432
|
+
* - {@link SeparatorBuilder}
|
|
433
|
+
* - Discord attachments (treated as media galleries)
|
|
434
434
|
*
|
|
435
|
-
* @param data -
|
|
435
|
+
* @param data - Either a `ContainerData` object containing `accentColor` and `components`, or the accent color directly.
|
|
436
|
+
* @param components - When using the overload with accent color as the first parameter, this is the list of components to include in the container.
|
|
436
437
|
*
|
|
437
|
-
* @returns A {@link ContainerBuilder} instance with
|
|
438
|
+
* @returns A {@link ContainerBuilder} instance with all components and styles applied.
|
|
438
439
|
*
|
|
439
440
|
* @example
|
|
440
|
-
* //
|
|
441
|
+
* // Using ContainerData object
|
|
441
442
|
* const container = createContainer({
|
|
442
|
-
* accentColor: "#ff5733",
|
|
443
|
-
* components: [
|
|
444
|
-
* "This is a text display component"
|
|
445
|
-
* ]
|
|
443
|
+
* accentColor: "#ff5733",
|
|
444
|
+
* components: ["Welcome to the app!"]
|
|
446
445
|
* });
|
|
447
446
|
*
|
|
448
447
|
* @example
|
|
449
|
-
* //
|
|
450
|
-
* const container = createContainer(
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* content: "-# Increment counter",
|
|
455
|
-
* button: new ButtonBuilder({
|
|
456
|
-
* customId: `counter/increment`,
|
|
457
|
-
* label: "+",
|
|
458
|
-
* style: ButtonStyle.Success
|
|
459
|
-
* })
|
|
460
|
-
* }),
|
|
461
|
-
* ]
|
|
462
|
-
* });
|
|
448
|
+
* // Using color and components as separate arguments
|
|
449
|
+
* const container = createContainer("Red",
|
|
450
|
+
* new TextDisplayBuilder().setText("Alert!"),
|
|
451
|
+
* new SeparatorBuilder()
|
|
452
|
+
* );
|
|
463
453
|
*
|
|
464
454
|
* @example
|
|
465
|
-
* //
|
|
466
|
-
* const container = createContainer(
|
|
467
|
-
* accentColor: [255, 87, 51], // RGB tuple
|
|
468
|
-
* components: [
|
|
469
|
-
* "Here's some content."
|
|
470
|
-
* ]
|
|
471
|
-
* });
|
|
455
|
+
* // Using RGB tuple
|
|
456
|
+
* const container = createContainer([255, 0, 0], "Red alert");
|
|
472
457
|
*/
|
|
473
458
|
declare function createContainer(data: ContainerData): ContainerBuilder;
|
|
459
|
+
declare function createContainer(data: ColorResolvable | string, ...components: ComponentData[]): ContainerBuilder;
|
|
474
460
|
|
|
475
461
|
type GuildChannelType = Exclude<ChannelType, ChannelType.DM>;
|
|
476
462
|
type FindChannelFilter<T extends GuildChannelType> = (channel: GetChannelType<T>) => boolean;
|
|
@@ -608,4 +594,4 @@ declare function isAnySelectMenuBuilder(value: unknown): value is AnySelectMenuB
|
|
|
608
594
|
declare function isButtonBuilder(value: unknown): value is ButtonBuilder;
|
|
609
595
|
|
|
610
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 };
|
|
611
|
-
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentData, ContainerColor, ContainerData, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty,
|
|
597
|
+
export type { AnyEmbedData, AnySelectMenuBuilder, ComponentData, ContainerColor, ContainerData, EmbedPlusAssetData, EmbedPlusAuthorData, EmbedPlusColorData, EmbedPlusData, EmbedPlusFooterData, EmbedPlusProperty, SectionAccessory, SectionAccessoryData, SectionButtonAccessory, SectionData, SectionThumbnailAccessory, SeparatorData, ThumbnailData };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicyan/discord",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "Simple functions to facilitate discord bot development",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -49,6 +49,6 @@
|
|
|
49
49
|
"vitest": "^2.1.9"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@magicyan/core": "^1.0
|
|
52
|
+
"@magicyan/core": "^1.1.0"
|
|
53
53
|
}
|
|
54
54
|
}
|