@magicyan/discord 1.4.11 → 1.5.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/components.cjs +2 -2
- package/dist/functions/components/components.mjs +2 -2
- package/dist/functions/components/container.cjs +71 -61
- package/dist/functions/components/container.mjs +72 -63
- package/dist/functions/components/file.cjs +3 -5
- package/dist/functions/components/file.mjs +4 -6
- package/dist/functions/embeds/assets.cjs +4 -4
- package/dist/functions/embeds/assets.mjs +4 -4
- package/dist/guards/attachment.cjs +7 -1
- package/dist/guards/attachment.mjs +7 -1
- package/dist/guards/components/button.cjs +10 -0
- package/dist/guards/components/button.mjs +8 -0
- package/dist/guards/components/container.cjs +10 -0
- package/dist/guards/components/container.mjs +8 -0
- package/dist/guards/components/gallery.cjs +14 -0
- package/dist/guards/components/gallery.mjs +11 -0
- package/dist/guards/components/modal.cjs +10 -0
- package/dist/guards/components/modal.mjs +8 -0
- package/dist/guards/components/row.cjs +18 -0
- package/dist/guards/components/row.mjs +16 -0
- package/dist/guards/components/section.cjs +10 -0
- package/dist/guards/components/section.mjs +8 -0
- package/dist/guards/components/selectmenu.cjs +30 -0
- package/dist/guards/components/selectmenu.mjs +23 -0
- package/dist/guards/components/separator.cjs +10 -0
- package/dist/guards/components/separator.mjs +8 -0
- package/dist/guards/components/textdisplay.cjs +10 -0
- package/dist/guards/components/textdisplay.mjs +8 -0
- package/dist/guards/components/textinput.cjs +10 -0
- package/dist/guards/components/textinput.mjs +8 -0
- package/dist/guards/message.cjs +17 -0
- package/dist/guards/message.mjs +15 -0
- package/dist/guards/utils.cjs +9 -0
- package/dist/guards/utils.mjs +7 -0
- package/dist/index.cjs +70 -45
- package/dist/index.d.cts +812 -481
- package/dist/index.d.mts +812 -481
- package/dist/index.d.ts +812 -481
- package/dist/index.mjs +29 -20
- package/package.json +1 -1
- package/dist/guards/button.cjs +0 -9
- package/dist/guards/button.mjs +0 -7
- package/dist/guards/selectmenu.cjs +0 -9
- package/dist/guards/selectmenu.mjs +0 -7
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const core = require('@magicyan/core');
|
|
4
4
|
const attachment = require('../../guards/attachment.cjs');
|
|
5
|
-
const button = require('../../guards/button.cjs');
|
|
6
|
-
const selectmenu = require('../../guards/selectmenu.cjs');
|
|
5
|
+
const button = require('../../guards/components/button.cjs');
|
|
6
|
+
const selectmenu = require('../../guards/components/selectmenu.cjs');
|
|
7
7
|
const gallery = require('./gallery.cjs');
|
|
8
8
|
const row = require('./row.cjs');
|
|
9
9
|
const text = require('./text.cjs');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isDefined } from '@magicyan/core';
|
|
2
2
|
import { isAttachment } from '../../guards/attachment.mjs';
|
|
3
|
-
import { isButtonBuilder } from '../../guards/button.mjs';
|
|
4
|
-
import { isAnySelectMenuBuilder } from '../../guards/selectmenu.mjs';
|
|
3
|
+
import { isButtonBuilder } from '../../guards/components/button.mjs';
|
|
4
|
+
import { isAnySelectMenuBuilder } from '../../guards/components/selectmenu.mjs';
|
|
5
5
|
import { createMediaGallery } from './gallery.mjs';
|
|
6
6
|
import { createRow } from './row.mjs';
|
|
7
7
|
import { createTextDisplay } from './text.mjs';
|
|
@@ -1,74 +1,84 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const core = require('@magicyan/core');
|
|
3
4
|
const discord_js = require('discord.js');
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const gallery = require('./gallery.cjs');
|
|
7
|
-
const row = require('./row.cjs');
|
|
8
|
-
const text = require('./text.cjs');
|
|
5
|
+
const components = require('./components.cjs');
|
|
6
|
+
const message = require('../../guards/message.cjs');
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
container.addTextDisplayComponents(
|
|
17
|
-
text.createTextDisplay(component)
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
if (component instanceof discord_js.TextDisplayBuilder) {
|
|
21
|
-
container.addTextDisplayComponents(
|
|
22
|
-
component
|
|
8
|
+
class ContainerPlusBuilder extends discord_js.ContainerBuilder {
|
|
9
|
+
constructor(data) {
|
|
10
|
+
const constructorData = core.isDefined(data?.from) ? message.isMessage(data.from) ? data.from.components.filter((v) => v.type === discord_js.ComponentType.Container).at(data.fromIndex ?? 0)?.toJSON() ?? {} : data.from.toJSON() : {};
|
|
11
|
+
if (core.isDefined(data?.accentColor)) {
|
|
12
|
+
constructorData.accent_color = discord_js.resolveColor(
|
|
13
|
+
data.accentColor
|
|
23
14
|
);
|
|
24
15
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
if (component instanceof discord_js.SectionBuilder) {
|
|
34
|
-
container.addSectionComponents(component);
|
|
35
|
-
}
|
|
36
|
-
if (component instanceof discord_js.FileBuilder) {
|
|
37
|
-
container.addFileComponents(component);
|
|
38
|
-
}
|
|
39
|
-
if (component instanceof discord_js.MediaGalleryBuilder) {
|
|
40
|
-
container.addMediaGalleryComponents(component);
|
|
41
|
-
}
|
|
42
|
-
if (attachment.isAttachment(component)) {
|
|
43
|
-
container.addMediaGalleryComponents(
|
|
44
|
-
gallery.createMediaGallery(component)
|
|
16
|
+
super(constructorData);
|
|
17
|
+
if (core.isDefined(data?.components) && data.components.length >= 1) {
|
|
18
|
+
this.spliceComponents(
|
|
19
|
+
0,
|
|
20
|
+
0,
|
|
21
|
+
...components.createComponents(data.components)
|
|
45
22
|
);
|
|
46
23
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Sets the accent color of the container.
|
|
27
|
+
*
|
|
28
|
+
* If a color is provided, it resolves and sets the accent color accordingly.
|
|
29
|
+
* If no color or `null` is provided, it clears the accent color.
|
|
30
|
+
*
|
|
31
|
+
* @param color - The color to set as the accent color, or `null` to clear it.
|
|
32
|
+
* @returns The current instance for chaining.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* container.setColor("#ff0000"); // Sets the accent color to red.
|
|
36
|
+
* container.setColor(null); // Clears the accent color.
|
|
37
|
+
*/
|
|
38
|
+
setColor(color) {
|
|
39
|
+
return core.isDefined(color) ? this.setAccentColor(discord_js.resolveColor(color)) : this.setAccentColor();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Replaces or removes a component at the specified index in the container.
|
|
43
|
+
*
|
|
44
|
+
* If `data` is provided, it replaces the component at the given index with the new component(s).
|
|
45
|
+
* If `null` is provided, it removes the component at that index.
|
|
46
|
+
*
|
|
47
|
+
* @param index - The index of the component to replace or remove.
|
|
48
|
+
* @param data - The new component data to set, or `null` to remove the component.
|
|
49
|
+
* @returns The current instance for chaining.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* container.setComponent(0, new ButtonBuilder({ label: "Click" }));
|
|
53
|
+
* container.setComponent(1, null); // Removes the component at index 1.
|
|
54
|
+
*/
|
|
55
|
+
setComponent(index, data) {
|
|
56
|
+
const args = [index, 1];
|
|
57
|
+
if (core.isDefined(data))
|
|
58
|
+
args.push(...components.createComponents(data));
|
|
59
|
+
return this.spliceComponents(...args);
|
|
60
|
+
}
|
|
61
|
+
componentAt(index, type) {
|
|
62
|
+
return core.isDefined(type) ? this.components.filter((builder) => builder.data.type === type).at(index) : this.components.at(index);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function createContainer(data, ...items) {
|
|
66
|
+
const isContainerData = (value) => typeof value === "object" && core.isDefined(value) && !Array.isArray(value);
|
|
57
67
|
if (isContainerData(data)) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return container;
|
|
68
|
+
const { array, from } = data;
|
|
69
|
+
if (array) {
|
|
70
|
+
if (message.isMessage(from)) {
|
|
71
|
+
return from.components.filter((c) => c.type === discord_js.ComponentType.Container).map((component) => new ContainerPlusBuilder({ from: component }));
|
|
72
|
+
}
|
|
73
|
+
return [new ContainerPlusBuilder(data)];
|
|
74
|
+
}
|
|
75
|
+
return new ContainerPlusBuilder(data);
|
|
67
76
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
return new ContainerPlusBuilder({
|
|
78
|
+
accentColor: data,
|
|
79
|
+
components: items.flat()
|
|
80
|
+
});
|
|
72
81
|
}
|
|
73
82
|
|
|
83
|
+
exports.ContainerPlusBuilder = ContainerPlusBuilder;
|
|
74
84
|
exports.createContainer = createContainer;
|
|
@@ -1,72 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { createRow } from './row.mjs';
|
|
6
|
-
import { createTextDisplay } from './text.mjs';
|
|
1
|
+
import { isDefined } from '@magicyan/core';
|
|
2
|
+
import { ContainerBuilder, ComponentType, resolveColor } from 'discord.js';
|
|
3
|
+
import { createComponents } from './components.mjs';
|
|
4
|
+
import { isMessage } from '../../guards/message.mjs';
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
container.addTextDisplayComponents(
|
|
15
|
-
createTextDisplay(component)
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
if (component instanceof TextDisplayBuilder) {
|
|
19
|
-
container.addTextDisplayComponents(
|
|
20
|
-
component
|
|
6
|
+
class ContainerPlusBuilder extends ContainerBuilder {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
const constructorData = isDefined(data?.from) ? isMessage(data.from) ? data.from.components.filter((v) => v.type === ComponentType.Container).at(data.fromIndex ?? 0)?.toJSON() ?? {} : data.from.toJSON() : {};
|
|
9
|
+
if (isDefined(data?.accentColor)) {
|
|
10
|
+
constructorData.accent_color = resolveColor(
|
|
11
|
+
data.accentColor
|
|
21
12
|
);
|
|
22
13
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
if (component instanceof SectionBuilder) {
|
|
32
|
-
container.addSectionComponents(component);
|
|
33
|
-
}
|
|
34
|
-
if (component instanceof FileBuilder) {
|
|
35
|
-
container.addFileComponents(component);
|
|
36
|
-
}
|
|
37
|
-
if (component instanceof MediaGalleryBuilder) {
|
|
38
|
-
container.addMediaGalleryComponents(component);
|
|
39
|
-
}
|
|
40
|
-
if (isAttachment(component)) {
|
|
41
|
-
container.addMediaGalleryComponents(
|
|
42
|
-
createMediaGallery(component)
|
|
14
|
+
super(constructorData);
|
|
15
|
+
if (isDefined(data?.components) && data.components.length >= 1) {
|
|
16
|
+
this.spliceComponents(
|
|
17
|
+
0,
|
|
18
|
+
0,
|
|
19
|
+
...createComponents(data.components)
|
|
43
20
|
);
|
|
44
21
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Sets the accent color of the container.
|
|
25
|
+
*
|
|
26
|
+
* If a color is provided, it resolves and sets the accent color accordingly.
|
|
27
|
+
* If no color or `null` is provided, it clears the accent color.
|
|
28
|
+
*
|
|
29
|
+
* @param color - The color to set as the accent color, or `null` to clear it.
|
|
30
|
+
* @returns The current instance for chaining.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* container.setColor("#ff0000"); // Sets the accent color to red.
|
|
34
|
+
* container.setColor(null); // Clears the accent color.
|
|
35
|
+
*/
|
|
36
|
+
setColor(color) {
|
|
37
|
+
return isDefined(color) ? this.setAccentColor(resolveColor(color)) : this.setAccentColor();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Replaces or removes a component at the specified index in the container.
|
|
41
|
+
*
|
|
42
|
+
* If `data` is provided, it replaces the component at the given index with the new component(s).
|
|
43
|
+
* If `null` is provided, it removes the component at that index.
|
|
44
|
+
*
|
|
45
|
+
* @param index - The index of the component to replace or remove.
|
|
46
|
+
* @param data - The new component data to set, or `null` to remove the component.
|
|
47
|
+
* @returns The current instance for chaining.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* container.setComponent(0, new ButtonBuilder({ label: "Click" }));
|
|
51
|
+
* container.setComponent(1, null); // Removes the component at index 1.
|
|
52
|
+
*/
|
|
53
|
+
setComponent(index, data) {
|
|
54
|
+
const args = [index, 1];
|
|
55
|
+
if (isDefined(data))
|
|
56
|
+
args.push(...createComponents(data));
|
|
57
|
+
return this.spliceComponents(...args);
|
|
58
|
+
}
|
|
59
|
+
componentAt(index, type) {
|
|
60
|
+
return isDefined(type) ? this.components.filter((builder) => builder.data.type === type).at(index) : this.components.at(index);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function createContainer(data, ...items) {
|
|
64
|
+
const isContainerData = (value) => typeof value === "object" && isDefined(value) && !Array.isArray(value);
|
|
55
65
|
if (isContainerData(data)) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return container;
|
|
66
|
+
const { array, from } = data;
|
|
67
|
+
if (array) {
|
|
68
|
+
if (isMessage(from)) {
|
|
69
|
+
return from.components.filter((c) => c.type === ComponentType.Container).map((component) => new ContainerPlusBuilder({ from: component }));
|
|
70
|
+
}
|
|
71
|
+
return [new ContainerPlusBuilder(data)];
|
|
72
|
+
}
|
|
73
|
+
return new ContainerPlusBuilder(data);
|
|
65
74
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
return new ContainerPlusBuilder({
|
|
76
|
+
accentColor: data,
|
|
77
|
+
components: items.flat()
|
|
78
|
+
});
|
|
70
79
|
}
|
|
71
80
|
|
|
72
|
-
export { createContainer };
|
|
81
|
+
export { ContainerPlusBuilder, createContainer };
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const discord_js = require('discord.js');
|
|
4
|
+
const attachment = require('../../guards/attachment.cjs');
|
|
4
5
|
|
|
5
6
|
function createFile(source, options = {}) {
|
|
6
7
|
const prefix = "attachment://";
|
|
7
|
-
const url =
|
|
8
|
+
const url = attachment.isAttachment(source) ? `${prefix}${source.name}` : source;
|
|
8
9
|
return new discord_js.FileBuilder({
|
|
9
10
|
spoiler: options.spoiler,
|
|
10
|
-
file: {
|
|
11
|
-
...options,
|
|
12
|
-
url
|
|
13
|
-
}
|
|
11
|
+
file: { ...options, url }
|
|
14
12
|
});
|
|
15
13
|
}
|
|
16
14
|
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileBuilder } from 'discord.js';
|
|
2
|
+
import { isAttachment } from '../../guards/attachment.mjs';
|
|
2
3
|
|
|
3
4
|
function createFile(source, options = {}) {
|
|
4
5
|
const prefix = "attachment://";
|
|
5
|
-
const url = source
|
|
6
|
+
const url = isAttachment(source) ? `${prefix}${source.name}` : source;
|
|
6
7
|
return new FileBuilder({
|
|
7
8
|
spoiler: options.spoiler,
|
|
8
|
-
file: {
|
|
9
|
-
...options,
|
|
10
|
-
url
|
|
11
|
-
}
|
|
9
|
+
file: { ...options, url }
|
|
12
10
|
});
|
|
13
11
|
}
|
|
14
12
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const attachment = require('../../guards/attachment.cjs');
|
|
4
4
|
|
|
5
5
|
function createEmbedAsset(source, options = {}) {
|
|
6
|
-
if (
|
|
6
|
+
if (attachment.isAttachment(source)) {
|
|
7
7
|
return { url: `attachment://${source.name}`, ...options };
|
|
8
8
|
}
|
|
9
9
|
if (source && typeof source === "object" && "url" in source) {
|
|
10
|
-
return
|
|
10
|
+
return { ...source, ...options };
|
|
11
11
|
}
|
|
12
|
-
return source ?
|
|
12
|
+
return source ? { url: source, ...options } : void 0;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
exports.createEmbedAsset = createEmbedAsset;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isAttachment } from '../../guards/attachment.mjs';
|
|
2
2
|
|
|
3
3
|
function createEmbedAsset(source, options = {}) {
|
|
4
|
-
if (source
|
|
4
|
+
if (isAttachment(source)) {
|
|
5
5
|
return { url: `attachment://${source.name}`, ...options };
|
|
6
6
|
}
|
|
7
7
|
if (source && typeof source === "object" && "url" in source) {
|
|
8
|
-
return
|
|
8
|
+
return { ...source, ...options };
|
|
9
9
|
}
|
|
10
|
-
return source ?
|
|
10
|
+
return source ? { url: source, ...options } : void 0;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export { createEmbedAsset };
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const discord_js = require('discord.js');
|
|
4
|
+
const utils = require('./utils.cjs');
|
|
4
5
|
|
|
5
6
|
function isAttachment(value) {
|
|
6
|
-
return value instanceof discord_js.Attachment || value instanceof discord_js.AttachmentBuilder
|
|
7
|
+
return value instanceof discord_js.Attachment || value instanceof discord_js.AttachmentBuilder || utils.hasConstructor(value) && [
|
|
8
|
+
discord_js.Attachment.name,
|
|
9
|
+
discord_js.AttachmentBuilder.name
|
|
10
|
+
].some(
|
|
11
|
+
(name) => name === value.constructor.name
|
|
12
|
+
);
|
|
7
13
|
}
|
|
8
14
|
|
|
9
15
|
exports.isAttachment = isAttachment;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Attachment, AttachmentBuilder } from 'discord.js';
|
|
2
|
+
import { hasConstructor } from './utils.mjs';
|
|
2
3
|
|
|
3
4
|
function isAttachment(value) {
|
|
4
|
-
return value instanceof Attachment || value instanceof AttachmentBuilder
|
|
5
|
+
return value instanceof Attachment || value instanceof AttachmentBuilder || hasConstructor(value) && [
|
|
6
|
+
Attachment.name,
|
|
7
|
+
AttachmentBuilder.name
|
|
8
|
+
].some(
|
|
9
|
+
(name) => name === value.constructor.name
|
|
10
|
+
);
|
|
5
11
|
}
|
|
6
12
|
|
|
7
13
|
export { isAttachment };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
const utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
function isButtonBuilder(value) {
|
|
7
|
+
return value instanceof discord_js.ButtonBuilder || utils.hasConstructor(value) && value.constructor.name === discord_js.ButtonBuilder.name;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.isButtonBuilder = isButtonBuilder;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ButtonBuilder } from 'discord.js';
|
|
2
|
+
import { hasConstructor } from '../utils.mjs';
|
|
3
|
+
|
|
4
|
+
function isButtonBuilder(value) {
|
|
5
|
+
return value instanceof ButtonBuilder || hasConstructor(value) && value.constructor.name === ButtonBuilder.name;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { isButtonBuilder };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
const utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
function isContainerBuilder(value) {
|
|
7
|
+
return value instanceof discord_js.ContainerBuilder || utils.hasConstructor(value) && value.constructor.name === discord_js.ContainerBuilder.name;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.isContainerBuilder = isContainerBuilder;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ContainerBuilder } from 'discord.js';
|
|
2
|
+
import { hasConstructor } from '../utils.mjs';
|
|
3
|
+
|
|
4
|
+
function isContainerBuilder(value) {
|
|
5
|
+
return value instanceof ContainerBuilder || hasConstructor(value) && value.constructor.name === ContainerBuilder.name;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { isContainerBuilder };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
const utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
function isMediaGalleryBuilder(value) {
|
|
7
|
+
return value instanceof discord_js.MediaGalleryBuilder || utils.hasConstructor(value) && value.constructor.name === discord_js.MediaGalleryBuilder.name;
|
|
8
|
+
}
|
|
9
|
+
function isMediaGalleryItemBuilder(value) {
|
|
10
|
+
return value instanceof discord_js.MediaGalleryItemBuilder || utils.hasConstructor(value) && value.constructor.name === discord_js.MediaGalleryItemBuilder.name;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.isMediaGalleryBuilder = isMediaGalleryBuilder;
|
|
14
|
+
exports.isMediaGalleryItemBuilder = isMediaGalleryItemBuilder;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MediaGalleryBuilder, MediaGalleryItemBuilder } from 'discord.js';
|
|
2
|
+
import { hasConstructor } from '../utils.mjs';
|
|
3
|
+
|
|
4
|
+
function isMediaGalleryBuilder(value) {
|
|
5
|
+
return value instanceof MediaGalleryBuilder || hasConstructor(value) && value.constructor.name === MediaGalleryBuilder.name;
|
|
6
|
+
}
|
|
7
|
+
function isMediaGalleryItemBuilder(value) {
|
|
8
|
+
return value instanceof MediaGalleryItemBuilder || hasConstructor(value) && value.constructor.name === MediaGalleryItemBuilder.name;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { isMediaGalleryBuilder, isMediaGalleryItemBuilder };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
const utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
function isModalBuilder(value) {
|
|
7
|
+
return value instanceof discord_js.ModalBuilder || utils.hasConstructor(value) && value.constructor.name === discord_js.ModalBuilder.name;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.isModalBuilder = isModalBuilder;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ModalBuilder } from 'discord.js';
|
|
2
|
+
import { hasConstructor } from '../utils.mjs';
|
|
3
|
+
|
|
4
|
+
function isModalBuilder(value) {
|
|
5
|
+
return value instanceof ModalBuilder || hasConstructor(value) && value.constructor.name === ModalBuilder.name;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { isModalBuilder };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
const selectmenu = require('./selectmenu.cjs');
|
|
5
|
+
const button = require('./button.cjs');
|
|
6
|
+
const utils = require('../utils.cjs');
|
|
7
|
+
const textinput = require('./textinput.cjs');
|
|
8
|
+
|
|
9
|
+
function isActionRowBuilder(value, withComponent) {
|
|
10
|
+
const isActionRow = utils.hasConstructor(value) && value.constructor.name === discord_js.ActionRowBuilder.name && "components" in value && Array.isArray(value.components);
|
|
11
|
+
if (isActionRow && withComponent) {
|
|
12
|
+
const guard = withComponent === "selects" ? selectmenu.isAnySelectMenuBuilder : withComponent === "buttons" ? button.isButtonBuilder : textinput.isTextInputBuilder;
|
|
13
|
+
return value.components.some(guard);
|
|
14
|
+
}
|
|
15
|
+
return isActionRow;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.isActionRowBuilder = isActionRowBuilder;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ActionRowBuilder } from 'discord.js';
|
|
2
|
+
import { isAnySelectMenuBuilder } from './selectmenu.mjs';
|
|
3
|
+
import { isButtonBuilder } from './button.mjs';
|
|
4
|
+
import { hasConstructor } from '../utils.mjs';
|
|
5
|
+
import { isTextInputBuilder } from './textinput.mjs';
|
|
6
|
+
|
|
7
|
+
function isActionRowBuilder(value, withComponent) {
|
|
8
|
+
const isActionRow = hasConstructor(value) && value.constructor.name === ActionRowBuilder.name && "components" in value && Array.isArray(value.components);
|
|
9
|
+
if (isActionRow && withComponent) {
|
|
10
|
+
const guard = withComponent === "selects" ? isAnySelectMenuBuilder : withComponent === "buttons" ? isButtonBuilder : isTextInputBuilder;
|
|
11
|
+
return value.components.some(guard);
|
|
12
|
+
}
|
|
13
|
+
return isActionRow;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { isActionRowBuilder };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
const utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
function isSectionBuilder(value) {
|
|
7
|
+
return value instanceof discord_js.SectionBuilder || utils.hasConstructor(value) && value.constructor.name === discord_js.SectionBuilder.name;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.isSectionBuilder = isSectionBuilder;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SectionBuilder } from 'discord.js';
|
|
2
|
+
import { hasConstructor } from '../utils.mjs';
|
|
3
|
+
|
|
4
|
+
function isSectionBuilder(value) {
|
|
5
|
+
return value instanceof SectionBuilder || hasConstructor(value) && value.constructor.name === SectionBuilder.name;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { isSectionBuilder };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
const utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
function isStringSelectMenuBuilder(value) {
|
|
7
|
+
return value instanceof discord_js.StringSelectMenuBuilder || utils.hasConstructor(value) && value.constructor.name === discord_js.StringSelectMenuBuilder.name;
|
|
8
|
+
}
|
|
9
|
+
function isUserSelectMenuBuilder(value) {
|
|
10
|
+
return value instanceof discord_js.UserSelectMenuBuilder || utils.hasConstructor(value) && value.constructor.name === discord_js.UserSelectMenuBuilder.name;
|
|
11
|
+
}
|
|
12
|
+
function isRoleSelectMenuBuilder(value) {
|
|
13
|
+
return value instanceof discord_js.RoleSelectMenuBuilder || utils.hasConstructor(value) && value.constructor.name === discord_js.RoleSelectMenuBuilder.name;
|
|
14
|
+
}
|
|
15
|
+
function isChannelSelectMenuBuilder(value) {
|
|
16
|
+
return value instanceof discord_js.ChannelSelectMenuBuilder || utils.hasConstructor(value) && value.constructor.name === discord_js.ChannelSelectMenuBuilder.name;
|
|
17
|
+
}
|
|
18
|
+
function isMentionableSelectMenuBuilder(value) {
|
|
19
|
+
return value instanceof discord_js.MentionableSelectMenuBuilder || utils.hasConstructor(value) && value.constructor.name === discord_js.MentionableSelectMenuBuilder.name;
|
|
20
|
+
}
|
|
21
|
+
function isAnySelectMenuBuilder(value) {
|
|
22
|
+
return isStringSelectMenuBuilder(value) || isUserSelectMenuBuilder(value) || isRoleSelectMenuBuilder(value) || isChannelSelectMenuBuilder(value) || isMentionableSelectMenuBuilder(value);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.isAnySelectMenuBuilder = isAnySelectMenuBuilder;
|
|
26
|
+
exports.isChannelSelectMenuBuilder = isChannelSelectMenuBuilder;
|
|
27
|
+
exports.isMentionableSelectMenuBuilder = isMentionableSelectMenuBuilder;
|
|
28
|
+
exports.isRoleSelectMenuBuilder = isRoleSelectMenuBuilder;
|
|
29
|
+
exports.isStringSelectMenuBuilder = isStringSelectMenuBuilder;
|
|
30
|
+
exports.isUserSelectMenuBuilder = isUserSelectMenuBuilder;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, ChannelSelectMenuBuilder, MentionableSelectMenuBuilder } from 'discord.js';
|
|
2
|
+
import { hasConstructor } from '../utils.mjs';
|
|
3
|
+
|
|
4
|
+
function isStringSelectMenuBuilder(value) {
|
|
5
|
+
return value instanceof StringSelectMenuBuilder || hasConstructor(value) && value.constructor.name === StringSelectMenuBuilder.name;
|
|
6
|
+
}
|
|
7
|
+
function isUserSelectMenuBuilder(value) {
|
|
8
|
+
return value instanceof UserSelectMenuBuilder || hasConstructor(value) && value.constructor.name === UserSelectMenuBuilder.name;
|
|
9
|
+
}
|
|
10
|
+
function isRoleSelectMenuBuilder(value) {
|
|
11
|
+
return value instanceof RoleSelectMenuBuilder || hasConstructor(value) && value.constructor.name === RoleSelectMenuBuilder.name;
|
|
12
|
+
}
|
|
13
|
+
function isChannelSelectMenuBuilder(value) {
|
|
14
|
+
return value instanceof ChannelSelectMenuBuilder || hasConstructor(value) && value.constructor.name === ChannelSelectMenuBuilder.name;
|
|
15
|
+
}
|
|
16
|
+
function isMentionableSelectMenuBuilder(value) {
|
|
17
|
+
return value instanceof MentionableSelectMenuBuilder || hasConstructor(value) && value.constructor.name === MentionableSelectMenuBuilder.name;
|
|
18
|
+
}
|
|
19
|
+
function isAnySelectMenuBuilder(value) {
|
|
20
|
+
return isStringSelectMenuBuilder(value) || isUserSelectMenuBuilder(value) || isRoleSelectMenuBuilder(value) || isChannelSelectMenuBuilder(value) || isMentionableSelectMenuBuilder(value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { isAnySelectMenuBuilder, isChannelSelectMenuBuilder, isMentionableSelectMenuBuilder, isRoleSelectMenuBuilder, isStringSelectMenuBuilder, isUserSelectMenuBuilder };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
const utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
function isSeparatorBuilder(value) {
|
|
7
|
+
return value instanceof discord_js.SeparatorBuilder || utils.hasConstructor(value) && value.constructor.name === discord_js.SeparatorBuilder.name;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.isSeparatorBuilder = isSeparatorBuilder;
|