@magicyan/discord 1.3.1 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/functions/{components.cjs → components/buttons.cjs} +0 -4
- package/dist/functions/components/buttons.mjs +8 -0
- package/dist/functions/components/components.cjs +28 -0
- package/dist/functions/components/components.mjs +26 -0
- package/dist/functions/components/container.cjs +63 -0
- package/dist/functions/components/container.mjs +61 -0
- package/dist/functions/components/file.cjs +17 -0
- package/dist/functions/components/file.mjs +15 -0
- package/dist/functions/components/gallery.cjs +26 -0
- package/dist/functions/components/gallery.mjs +24 -0
- package/dist/functions/components/row.cjs +9 -0
- package/dist/functions/components/row.mjs +7 -0
- package/dist/functions/components/section.cjs +29 -0
- package/dist/functions/components/section.mjs +27 -0
- package/dist/functions/components/separator.cjs +12 -0
- package/dist/functions/components/separator.mjs +10 -0
- package/dist/functions/components/text.cjs +12 -0
- package/dist/functions/components/text.mjs +10 -0
- package/dist/functions/components/thumbnail.cjs +16 -0
- package/dist/functions/components/thumbnail.mjs +14 -0
- package/dist/functions/embeds/embedplus.cjs +11 -15
- package/dist/functions/embeds/embedplus.mjs +11 -15
- package/dist/functions/embeds/footer.cjs +3 -0
- package/dist/functions/embeds/footer.mjs +3 -0
- package/dist/functions/modals.cjs +4 -7
- package/dist/functions/modals.mjs +3 -6
- package/dist/guards/attachment.cjs +9 -0
- package/dist/guards/attachment.mjs +7 -0
- package/dist/guards/selectmenu.cjs +9 -0
- package/dist/guards/selectmenu.mjs +7 -0
- package/dist/index.cjs +24 -3
- package/dist/index.d.cts +293 -7
- package/dist/index.d.mts +293 -7
- package/dist/index.d.ts +293 -7
- package/dist/index.mjs +12 -1
- package/package.json +3 -3
- package/dist/functions/components.mjs +0 -11
|
@@ -2,13 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const discord_js = require('discord.js');
|
|
4
4
|
|
|
5
|
-
function createRow(...components) {
|
|
6
|
-
return new discord_js.ActionRowBuilder({ components });
|
|
7
|
-
}
|
|
8
5
|
function createLinkButton(data) {
|
|
9
6
|
data.label ?? (data.label = data.url);
|
|
10
7
|
return new discord_js.ButtonBuilder({ style: discord_js.ButtonStyle.Link, ...data });
|
|
11
8
|
}
|
|
12
9
|
|
|
13
10
|
exports.createLinkButton = createLinkButton;
|
|
14
|
-
exports.createRow = createRow;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
const selectmenu = require('../../guards/selectmenu.cjs');
|
|
5
|
+
const attachment = require('../../guards/attachment.cjs');
|
|
6
|
+
const gallery = require('./gallery.cjs');
|
|
7
|
+
const text = require('./text.cjs');
|
|
8
|
+
const row = require('./row.cjs');
|
|
9
|
+
|
|
10
|
+
function createComponents(...data) {
|
|
11
|
+
return data.filter((value) => value !== null).map((component) => {
|
|
12
|
+
if (typeof component === "string") {
|
|
13
|
+
return text.createTextDisplay(component);
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(component)) {
|
|
16
|
+
return row.createRow(...component);
|
|
17
|
+
}
|
|
18
|
+
if (selectmenu.isAnySelectMenuBuilder(component) || component instanceof discord_js.ButtonBuilder) {
|
|
19
|
+
return row.createRow(component);
|
|
20
|
+
}
|
|
21
|
+
if (attachment.isAttachment(component)) {
|
|
22
|
+
return gallery.createMediaGallery(component);
|
|
23
|
+
}
|
|
24
|
+
return component;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.createComponents = createComponents;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ButtonBuilder } from 'discord.js';
|
|
2
|
+
import { isAnySelectMenuBuilder } from '../../guards/selectmenu.mjs';
|
|
3
|
+
import { isAttachment } from '../../guards/attachment.mjs';
|
|
4
|
+
import { createMediaGallery } from './gallery.mjs';
|
|
5
|
+
import { createTextDisplay } from './text.mjs';
|
|
6
|
+
import { createRow } from './row.mjs';
|
|
7
|
+
|
|
8
|
+
function createComponents(...data) {
|
|
9
|
+
return data.filter((value) => value !== null).map((component) => {
|
|
10
|
+
if (typeof component === "string") {
|
|
11
|
+
return createTextDisplay(component);
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(component)) {
|
|
14
|
+
return createRow(...component);
|
|
15
|
+
}
|
|
16
|
+
if (isAnySelectMenuBuilder(component) || component instanceof ButtonBuilder) {
|
|
17
|
+
return createRow(component);
|
|
18
|
+
}
|
|
19
|
+
if (isAttachment(component)) {
|
|
20
|
+
return createMediaGallery(component);
|
|
21
|
+
}
|
|
22
|
+
return component;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { createComponents };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const core = require('@magicyan/core');
|
|
4
|
+
const discord_js = require('discord.js');
|
|
5
|
+
const selectmenu = require('../../guards/selectmenu.cjs');
|
|
6
|
+
const attachment = require('../../guards/attachment.cjs');
|
|
7
|
+
const gallery = require('./gallery.cjs');
|
|
8
|
+
const text = require('./text.cjs');
|
|
9
|
+
const row = require('./row.cjs');
|
|
10
|
+
|
|
11
|
+
function createContainer(data) {
|
|
12
|
+
const container = new discord_js.ContainerBuilder();
|
|
13
|
+
data.accentColor && container.setAccentColor(
|
|
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) {
|
|
17
|
+
if (!component)
|
|
18
|
+
continue;
|
|
19
|
+
if (typeof component === "string") {
|
|
20
|
+
container.addTextDisplayComponents(
|
|
21
|
+
text.createTextDisplay(component)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (component instanceof discord_js.TextDisplayBuilder) {
|
|
25
|
+
container.addTextDisplayComponents(
|
|
26
|
+
component
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
if (component instanceof discord_js.ActionRowBuilder) {
|
|
30
|
+
container.addActionRowComponents(component);
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(component)) {
|
|
33
|
+
container.addActionRowComponents(
|
|
34
|
+
row.createRow(...component)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (selectmenu.isAnySelectMenuBuilder(component) || component instanceof discord_js.ButtonBuilder) {
|
|
38
|
+
container.addActionRowComponents(
|
|
39
|
+
row.createRow(component)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
if (component instanceof discord_js.SectionBuilder) {
|
|
43
|
+
container.addSectionComponents(component);
|
|
44
|
+
}
|
|
45
|
+
if (component instanceof discord_js.FileBuilder) {
|
|
46
|
+
container.addFileComponents(component);
|
|
47
|
+
}
|
|
48
|
+
if (component instanceof discord_js.MediaGalleryBuilder) {
|
|
49
|
+
container.addMediaGalleryComponents(component);
|
|
50
|
+
}
|
|
51
|
+
if (attachment.isAttachment(component)) {
|
|
52
|
+
container.addMediaGalleryComponents(
|
|
53
|
+
gallery.createMediaGallery(component)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (component instanceof discord_js.SeparatorBuilder) {
|
|
57
|
+
container.addSeparatorComponents(component);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return container;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
exports.createContainer = createContainer;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { hexToRgb } from '@magicyan/core';
|
|
2
|
+
import { ContainerBuilder, Colors, TextDisplayBuilder, ActionRowBuilder, ButtonBuilder, SectionBuilder, FileBuilder, MediaGalleryBuilder, SeparatorBuilder } from 'discord.js';
|
|
3
|
+
import { isAnySelectMenuBuilder } from '../../guards/selectmenu.mjs';
|
|
4
|
+
import { isAttachment } from '../../guards/attachment.mjs';
|
|
5
|
+
import { createMediaGallery } from './gallery.mjs';
|
|
6
|
+
import { createTextDisplay } from './text.mjs';
|
|
7
|
+
import { createRow } from './row.mjs';
|
|
8
|
+
|
|
9
|
+
function createContainer(data) {
|
|
10
|
+
const container = new ContainerBuilder();
|
|
11
|
+
data.accentColor && container.setAccentColor(
|
|
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) {
|
|
15
|
+
if (!component)
|
|
16
|
+
continue;
|
|
17
|
+
if (typeof component === "string") {
|
|
18
|
+
container.addTextDisplayComponents(
|
|
19
|
+
createTextDisplay(component)
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
if (component instanceof TextDisplayBuilder) {
|
|
23
|
+
container.addTextDisplayComponents(
|
|
24
|
+
component
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
if (component instanceof ActionRowBuilder) {
|
|
28
|
+
container.addActionRowComponents(component);
|
|
29
|
+
}
|
|
30
|
+
if (Array.isArray(component)) {
|
|
31
|
+
container.addActionRowComponents(
|
|
32
|
+
createRow(...component)
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
if (isAnySelectMenuBuilder(component) || component instanceof ButtonBuilder) {
|
|
36
|
+
container.addActionRowComponents(
|
|
37
|
+
createRow(component)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (component instanceof SectionBuilder) {
|
|
41
|
+
container.addSectionComponents(component);
|
|
42
|
+
}
|
|
43
|
+
if (component instanceof FileBuilder) {
|
|
44
|
+
container.addFileComponents(component);
|
|
45
|
+
}
|
|
46
|
+
if (component instanceof MediaGalleryBuilder) {
|
|
47
|
+
container.addMediaGalleryComponents(component);
|
|
48
|
+
}
|
|
49
|
+
if (isAttachment(component)) {
|
|
50
|
+
container.addMediaGalleryComponents(
|
|
51
|
+
createMediaGallery(component)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
if (component instanceof SeparatorBuilder) {
|
|
55
|
+
container.addSeparatorComponents(component);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return container;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { createContainer };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
|
|
5
|
+
function createFile(source, options = {}) {
|
|
6
|
+
const prefix = "attachment://";
|
|
7
|
+
const url = source instanceof discord_js.AttachmentBuilder || source instanceof discord_js.Attachment ? `${prefix}${source.name}` : source;
|
|
8
|
+
return new discord_js.FileBuilder({
|
|
9
|
+
spoiler: options.spoiler,
|
|
10
|
+
file: {
|
|
11
|
+
...options,
|
|
12
|
+
url
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.createFile = createFile;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AttachmentBuilder, Attachment, FileBuilder } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
function createFile(source, options = {}) {
|
|
4
|
+
const prefix = "attachment://";
|
|
5
|
+
const url = source instanceof AttachmentBuilder || source instanceof Attachment ? `${prefix}${source.name}` : source;
|
|
6
|
+
return new FileBuilder({
|
|
7
|
+
spoiler: options.spoiler,
|
|
8
|
+
file: {
|
|
9
|
+
...options,
|
|
10
|
+
url
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { createFile };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
const attachment = require('../../guards/attachment.cjs');
|
|
5
|
+
|
|
6
|
+
function createMediaGallery(...items) {
|
|
7
|
+
const gallery = new discord_js.MediaGalleryBuilder();
|
|
8
|
+
for (const item of items) {
|
|
9
|
+
if (typeof item === "string") {
|
|
10
|
+
gallery.addItems({
|
|
11
|
+
media: { url: item }
|
|
12
|
+
});
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (attachment.isAttachment(item)) {
|
|
16
|
+
gallery.addItems({
|
|
17
|
+
media: { url: `attachment://${item.name}` }
|
|
18
|
+
});
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
gallery.addItems(item);
|
|
22
|
+
}
|
|
23
|
+
return gallery;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exports.createMediaGallery = createMediaGallery;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MediaGalleryBuilder } from 'discord.js';
|
|
2
|
+
import { isAttachment } from '../../guards/attachment.mjs';
|
|
3
|
+
|
|
4
|
+
function createMediaGallery(...items) {
|
|
5
|
+
const gallery = new MediaGalleryBuilder();
|
|
6
|
+
for (const item of items) {
|
|
7
|
+
if (typeof item === "string") {
|
|
8
|
+
gallery.addItems({
|
|
9
|
+
media: { url: item }
|
|
10
|
+
});
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (isAttachment(item)) {
|
|
14
|
+
gallery.addItems({
|
|
15
|
+
media: { url: `attachment://${item.name}` }
|
|
16
|
+
});
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
gallery.addItems(item);
|
|
20
|
+
}
|
|
21
|
+
return gallery;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { createMediaGallery };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
const text = require('./text.cjs');
|
|
5
|
+
const thumbnail = require('./thumbnail.cjs');
|
|
6
|
+
|
|
7
|
+
function createSection(data) {
|
|
8
|
+
const section = new discord_js.SectionBuilder();
|
|
9
|
+
if (data.button) {
|
|
10
|
+
section.setButtonAccessory(data.button);
|
|
11
|
+
}
|
|
12
|
+
if (data.thumbnail) {
|
|
13
|
+
section.setThumbnailAccessory(
|
|
14
|
+
thumbnail.createThumbnail(data.thumbnail)
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
if (Array.isArray(data.content)) {
|
|
18
|
+
section.addTextDisplayComponents(
|
|
19
|
+
data.content.map(text.createTextDisplay)
|
|
20
|
+
);
|
|
21
|
+
} else {
|
|
22
|
+
section.addTextDisplayComponents(
|
|
23
|
+
text.createTextDisplay(data.content)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return section;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.createSection = createSection;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SectionBuilder } from 'discord.js';
|
|
2
|
+
import { createTextDisplay } from './text.mjs';
|
|
3
|
+
import { createThumbnail } from './thumbnail.mjs';
|
|
4
|
+
|
|
5
|
+
function createSection(data) {
|
|
6
|
+
const section = new SectionBuilder();
|
|
7
|
+
if (data.button) {
|
|
8
|
+
section.setButtonAccessory(data.button);
|
|
9
|
+
}
|
|
10
|
+
if (data.thumbnail) {
|
|
11
|
+
section.setThumbnailAccessory(
|
|
12
|
+
createThumbnail(data.thumbnail)
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(data.content)) {
|
|
16
|
+
section.addTextDisplayComponents(
|
|
17
|
+
data.content.map(createTextDisplay)
|
|
18
|
+
);
|
|
19
|
+
} else {
|
|
20
|
+
section.addTextDisplayComponents(
|
|
21
|
+
createTextDisplay(data.content)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return section;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { createSection };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
|
|
5
|
+
function createSeparator(data = {}) {
|
|
6
|
+
return new discord_js.SeparatorBuilder({
|
|
7
|
+
divider: data.divider,
|
|
8
|
+
spacing: data.large ? discord_js.SeparatorSpacingSize.Large : discord_js.SeparatorSpacingSize.Small
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.createSeparator = createSeparator;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SeparatorBuilder, SeparatorSpacingSize } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
function createSeparator(data = {}) {
|
|
4
|
+
return new SeparatorBuilder({
|
|
5
|
+
divider: data.divider,
|
|
6
|
+
spacing: data.large ? SeparatorSpacingSize.Large : SeparatorSpacingSize.Small
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { createSeparator };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
|
|
5
|
+
function createThumbnail(data) {
|
|
6
|
+
const thumbnail = new discord_js.ThumbnailBuilder();
|
|
7
|
+
if (typeof data === "string") {
|
|
8
|
+
return thumbnail.setURL(data);
|
|
9
|
+
}
|
|
10
|
+
if (data instanceof discord_js.AttachmentBuilder || data instanceof discord_js.Attachment) {
|
|
11
|
+
return thumbnail.setURL(`attachment://${data.name}`).setSpoiler(data.spoiler);
|
|
12
|
+
}
|
|
13
|
+
return new discord_js.ThumbnailBuilder(data);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.createThumbnail = createThumbnail;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ThumbnailBuilder, AttachmentBuilder, Attachment } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
function createThumbnail(data) {
|
|
4
|
+
const thumbnail = new ThumbnailBuilder();
|
|
5
|
+
if (typeof data === "string") {
|
|
6
|
+
return thumbnail.setURL(data);
|
|
7
|
+
}
|
|
8
|
+
if (data instanceof AttachmentBuilder || data instanceof Attachment) {
|
|
9
|
+
return thumbnail.setURL(`attachment://${data.name}`).setSpoiler(data.spoiler);
|
|
10
|
+
}
|
|
11
|
+
return new ThumbnailBuilder(data);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { createThumbnail };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const core = require('@magicyan/core');
|
|
3
4
|
const discord_js = require('discord.js');
|
|
5
|
+
const chars = require('../../constants/chars.cjs');
|
|
6
|
+
const colors = require('../../constants/colors.cjs');
|
|
4
7
|
const assets = require('./assets.cjs');
|
|
5
8
|
const fields = require('./fields.cjs');
|
|
6
9
|
const footer = require('./footer.cjs');
|
|
7
|
-
const chars = require('../../constants/chars.cjs');
|
|
8
|
-
const colors = require('../../constants/colors.cjs');
|
|
9
10
|
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -25,17 +26,22 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
25
26
|
const builderData = Object.assign({}, extendsData, embedData, { fields: fields$1 });
|
|
26
27
|
if (builderData.url)
|
|
27
28
|
builderData.url = builderData.url.toString();
|
|
28
|
-
const { color, footer: footer$1, image, thumbnail, timestamp } = embedData;
|
|
29
|
-
if (footer$1)
|
|
29
|
+
const { color, footer: footer$1, image, thumbnail, timestamp, description } = embedData;
|
|
30
|
+
if (!footer$1)
|
|
31
|
+
delete builderData.footer;
|
|
32
|
+
if (footer$1) {
|
|
30
33
|
Object.assign(builderData, { footer: footer.createEmbedFooter(footer$1) });
|
|
34
|
+
}
|
|
31
35
|
if (image)
|
|
32
36
|
Object.assign(builderData, { image: assets.createEmbedAsset(image) });
|
|
33
37
|
if (thumbnail)
|
|
34
38
|
Object.assign(builderData, { thumbnail: assets.createEmbedAsset(thumbnail) });
|
|
39
|
+
if (description)
|
|
40
|
+
builderData.description = core.brBuilder(description);
|
|
35
41
|
const embed = new discord_js.EmbedBuilder(builderData);
|
|
36
42
|
if (timestamp)
|
|
37
43
|
embed.setTimestamp(
|
|
38
|
-
typeof timestamp === "string" ? new Date(timestamp) : timestamp
|
|
44
|
+
typeof timestamp === "string" ? new Date(timestamp) : typeof timestamp === "boolean" ? /* @__PURE__ */ new Date() : timestamp
|
|
39
45
|
);
|
|
40
46
|
if (color)
|
|
41
47
|
embed.setColor(color);
|
|
@@ -71,16 +77,6 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
71
77
|
}
|
|
72
78
|
return this;
|
|
73
79
|
}
|
|
74
|
-
// public setBorderColor(color: EmbedPlusColorData | null): this {
|
|
75
|
-
// if (color === null){
|
|
76
|
-
// this.setColor(colors.embedbg as ColorResolvable);
|
|
77
|
-
// } else if (typeof color === "number"){
|
|
78
|
-
// this.update({ color });
|
|
79
|
-
// } else {
|
|
80
|
-
// this.setColor(color as ColorResolvable);
|
|
81
|
-
// }
|
|
82
|
-
// return this;
|
|
83
|
-
// }
|
|
84
80
|
setAsset(asset, source) {
|
|
85
81
|
this.update({ [asset]: source });
|
|
86
82
|
return this;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { brBuilder } from '@magicyan/core';
|
|
1
2
|
import { EmbedBuilder, AttachmentBuilder } from 'discord.js';
|
|
3
|
+
import { chars } from '../../constants/chars.mjs';
|
|
4
|
+
import { colors } from '../../constants/colors.mjs';
|
|
2
5
|
import { createEmbedAsset } from './assets.mjs';
|
|
3
6
|
import { EmbedPlusFields } from './fields.mjs';
|
|
4
7
|
import { createEmbedFooter } from './footer.mjs';
|
|
5
|
-
import { chars } from '../../constants/chars.mjs';
|
|
6
|
-
import { colors } from '../../constants/colors.mjs';
|
|
7
8
|
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
9
10
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -23,17 +24,22 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
23
24
|
const builderData = Object.assign({}, extendsData, embedData, { fields });
|
|
24
25
|
if (builderData.url)
|
|
25
26
|
builderData.url = builderData.url.toString();
|
|
26
|
-
const { color, footer, image, thumbnail, timestamp } = embedData;
|
|
27
|
-
if (footer)
|
|
27
|
+
const { color, footer, image, thumbnail, timestamp, description } = embedData;
|
|
28
|
+
if (!footer)
|
|
29
|
+
delete builderData.footer;
|
|
30
|
+
if (footer) {
|
|
28
31
|
Object.assign(builderData, { footer: createEmbedFooter(footer) });
|
|
32
|
+
}
|
|
29
33
|
if (image)
|
|
30
34
|
Object.assign(builderData, { image: createEmbedAsset(image) });
|
|
31
35
|
if (thumbnail)
|
|
32
36
|
Object.assign(builderData, { thumbnail: createEmbedAsset(thumbnail) });
|
|
37
|
+
if (description)
|
|
38
|
+
builderData.description = brBuilder(description);
|
|
33
39
|
const embed = new EmbedBuilder(builderData);
|
|
34
40
|
if (timestamp)
|
|
35
41
|
embed.setTimestamp(
|
|
36
|
-
typeof timestamp === "string" ? new Date(timestamp) : timestamp
|
|
42
|
+
typeof timestamp === "string" ? new Date(timestamp) : typeof timestamp === "boolean" ? /* @__PURE__ */ new Date() : timestamp
|
|
37
43
|
);
|
|
38
44
|
if (color)
|
|
39
45
|
embed.setColor(color);
|
|
@@ -69,16 +75,6 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
69
75
|
}
|
|
70
76
|
return this;
|
|
71
77
|
}
|
|
72
|
-
// public setBorderColor(color: EmbedPlusColorData | null): this {
|
|
73
|
-
// if (color === null){
|
|
74
|
-
// this.setColor(colors.embedbg as ColorResolvable);
|
|
75
|
-
// } else if (typeof color === "number"){
|
|
76
|
-
// this.update({ color });
|
|
77
|
-
// } else {
|
|
78
|
-
// this.setColor(color as ColorResolvable);
|
|
79
|
-
// }
|
|
80
|
-
// return this;
|
|
81
|
-
// }
|
|
82
78
|
setAsset(asset, source) {
|
|
83
79
|
this.update({ [asset]: source });
|
|
84
80
|
return this;
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
const chars = require('../../constants/chars.cjs');
|
|
4
4
|
|
|
5
5
|
function createEmbedFooter(options) {
|
|
6
|
+
if (typeof options === "string") {
|
|
7
|
+
return { text: options };
|
|
8
|
+
}
|
|
6
9
|
const { text, iconURL } = options;
|
|
7
10
|
return !text && !iconURL ? void 0 : { text: text || chars.chars.invisible, iconURL: iconURL || void 0 };
|
|
8
11
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { chars } from '../../constants/chars.mjs';
|
|
2
2
|
|
|
3
3
|
function createEmbedFooter(options) {
|
|
4
|
+
if (typeof options === "string") {
|
|
5
|
+
return { text: options };
|
|
6
|
+
}
|
|
4
7
|
const { text, iconURL } = options;
|
|
5
8
|
return !text && !iconURL ? void 0 : { text: text || chars.invisible, iconURL: iconURL || void 0 };
|
|
6
9
|
}
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const discord_js = require('discord.js');
|
|
4
|
-
const
|
|
4
|
+
const row = require('./components/row.cjs');
|
|
5
5
|
|
|
6
6
|
function createModalInput(data) {
|
|
7
7
|
data.style ?? (data.style = discord_js.TextInputStyle.Short);
|
|
8
|
-
return
|
|
8
|
+
return row.createRow(new discord_js.TextInputBuilder(data));
|
|
9
9
|
}
|
|
10
10
|
function createModalFields(data) {
|
|
11
11
|
return Object.entries(data).map(
|
|
12
|
-
([customId, data2]) => createModalInput(
|
|
12
|
+
([customId, data2]) => createModalInput({ customId, ...data2 })
|
|
13
13
|
);
|
|
14
14
|
}
|
|
15
15
|
function modalFieldsToRecord(fields) {
|
|
16
|
-
const reduceFunction = (data, { customId, value }) =>
|
|
17
|
-
data,
|
|
18
|
-
{ [customId]: value }
|
|
19
|
-
);
|
|
16
|
+
const reduceFunction = (data, { customId, value }) => ({ ...data, [customId]: value });
|
|
20
17
|
const modalFields = fields instanceof discord_js.ModalSubmitInteraction ? fields.fields.fields : "fields" in fields ? fields.fields : fields;
|
|
21
18
|
return modalFields.reduce(reduceFunction, {});
|
|
22
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextInputStyle, TextInputBuilder, ModalSubmitInteraction } from 'discord.js';
|
|
2
|
-
import { createRow } from './components.mjs';
|
|
2
|
+
import { createRow } from './components/row.mjs';
|
|
3
3
|
|
|
4
4
|
function createModalInput(data) {
|
|
5
5
|
data.style ?? (data.style = TextInputStyle.Short);
|
|
@@ -7,14 +7,11 @@ function createModalInput(data) {
|
|
|
7
7
|
}
|
|
8
8
|
function createModalFields(data) {
|
|
9
9
|
return Object.entries(data).map(
|
|
10
|
-
([customId, data2]) => createModalInput(
|
|
10
|
+
([customId, data2]) => createModalInput({ customId, ...data2 })
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
13
|
function modalFieldsToRecord(fields) {
|
|
14
|
-
const reduceFunction = (data, { customId, value }) =>
|
|
15
|
-
data,
|
|
16
|
-
{ [customId]: value }
|
|
17
|
-
);
|
|
14
|
+
const reduceFunction = (data, { customId, value }) => ({ ...data, [customId]: value });
|
|
18
15
|
const modalFields = fields instanceof ModalSubmitInteraction ? fields.fields.fields : "fields" in fields ? fields.fields : fields;
|
|
19
16
|
return modalFields.reduce(reduceFunction, {});
|
|
20
17
|
}
|