@magicyan/discord 1.0.30 → 1.0.32
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/commands.cjs +23 -0
- package/dist/functions/commands.mjs +22 -2
- package/dist/functions/embeds/embedplus.cjs +33 -7
- package/dist/functions/embeds/embedplus.mjs +34 -8
- package/dist/functions/embeds/fields.cjs +0 -4
- package/dist/functions/embeds/fields.mjs +0 -4
- package/dist/functions/embeds/files.cjs +31 -0
- package/dist/functions/embeds/files.mjs +29 -0
- package/dist/functions/misc.cjs +3 -1
- package/dist/functions/misc.mjs +3 -1
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts +46 -3
- package/dist/index.d.mts +46 -3
- package/dist/index.d.ts +46 -3
- package/dist/index.mjs +2 -1
- package/package.json +5 -5
|
@@ -16,5 +16,28 @@ function findCommand(guildOrClient) {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
+
function createCommandOptions(options) {
|
|
20
|
+
return Object.entries(options).map(
|
|
21
|
+
([name, data]) => Object.assign(data, { name })
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
function createSubCommands(subcommands) {
|
|
25
|
+
return Object.entries(subcommands).map(([name, data]) => {
|
|
26
|
+
if (data.options)
|
|
27
|
+
Object.assign(data, {
|
|
28
|
+
options: createCommandOptions(data.options)
|
|
29
|
+
});
|
|
30
|
+
return Object.assign(data, { name, type: discord_js.ApplicationCommandOptionType.Subcommand });
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function createSubCommandsGroups(groups) {
|
|
34
|
+
return Object.entries(groups).map(([name, data]) => {
|
|
35
|
+
const options = createSubCommands(data.subcommands);
|
|
36
|
+
return Object.assign(data, { name, type: discord_js.ApplicationCommandOptionType.SubcommandGroup, options });
|
|
37
|
+
});
|
|
38
|
+
}
|
|
19
39
|
|
|
40
|
+
exports.createCommandOptions = createCommandOptions;
|
|
41
|
+
exports.createSubCommands = createSubCommands;
|
|
42
|
+
exports.createSubCommandsGroups = createSubCommandsGroups;
|
|
20
43
|
exports.findCommand = findCommand;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client } from 'discord.js';
|
|
1
|
+
import { Client, ApplicationCommandOptionType } from 'discord.js';
|
|
2
2
|
|
|
3
3
|
function findCommand(guildOrClient) {
|
|
4
4
|
const commands = guildOrClient instanceof Client ? guildOrClient.application.commands.cache : guildOrClient.commands.cache;
|
|
@@ -14,5 +14,25 @@ function findCommand(guildOrClient) {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
+
function createCommandOptions(options) {
|
|
18
|
+
return Object.entries(options).map(
|
|
19
|
+
([name, data]) => Object.assign(data, { name })
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
function createSubCommands(subcommands) {
|
|
23
|
+
return Object.entries(subcommands).map(([name, data]) => {
|
|
24
|
+
if (data.options)
|
|
25
|
+
Object.assign(data, {
|
|
26
|
+
options: createCommandOptions(data.options)
|
|
27
|
+
});
|
|
28
|
+
return Object.assign(data, { name, type: ApplicationCommandOptionType.Subcommand });
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function createSubCommandsGroups(groups) {
|
|
32
|
+
return Object.entries(groups).map(([name, data]) => {
|
|
33
|
+
const options = createSubCommands(data.subcommands);
|
|
34
|
+
return Object.assign(data, { name, type: ApplicationCommandOptionType.SubcommandGroup, options });
|
|
35
|
+
});
|
|
36
|
+
}
|
|
17
37
|
|
|
18
|
-
export { findCommand };
|
|
38
|
+
export { createCommandOptions, createSubCommands, createSubCommandsGroups, findCommand };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const discord_js = require('discord.js');
|
|
4
|
-
const chars = require('../../constants/chars.cjs');
|
|
5
4
|
const assets = require('./assets.cjs');
|
|
6
5
|
const fields = require('./fields.cjs');
|
|
7
6
|
const footer = require('./footer.cjs');
|
|
7
|
+
const chars = require('../../constants/chars.cjs');
|
|
8
8
|
|
|
9
9
|
var __defProp = Object.defineProperty;
|
|
10
10
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -54,6 +54,10 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
54
54
|
toString(space = 2) {
|
|
55
55
|
return JSON.stringify(this, null, space);
|
|
56
56
|
}
|
|
57
|
+
toAttachment(data = { name: "embed.png" }, space = 2) {
|
|
58
|
+
const buffer = Buffer.from(this.toString(space), "utf-8");
|
|
59
|
+
return new discord_js.AttachmentBuilder(buffer, data);
|
|
60
|
+
}
|
|
57
61
|
setBorderColor(color) {
|
|
58
62
|
if (color === null) {
|
|
59
63
|
this.setColor("#2B2D31");
|
|
@@ -65,10 +69,32 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
65
69
|
return this;
|
|
66
70
|
}
|
|
67
71
|
setAsset(asset, source) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
this.update({ [asset]: source });
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
setElementImageURL(element, url) {
|
|
76
|
+
switch (element) {
|
|
77
|
+
case "thumbnail":
|
|
78
|
+
case "image": {
|
|
79
|
+
this.setAsset(element, url);
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case "author": {
|
|
83
|
+
const author = this.data.author;
|
|
84
|
+
this.setAuthor({
|
|
85
|
+
name: author?.name ?? chars.chars.invisible,
|
|
86
|
+
iconURL: url ?? void 0
|
|
87
|
+
});
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case "footer": {
|
|
91
|
+
const footer = this.data.footer;
|
|
92
|
+
this.setFooter({
|
|
93
|
+
text: footer?.text ?? chars.chars.invisible,
|
|
94
|
+
iconURL: url ?? void 0
|
|
95
|
+
});
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
72
98
|
}
|
|
73
99
|
return this;
|
|
74
100
|
}
|
|
@@ -80,8 +106,8 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
80
106
|
}
|
|
81
107
|
}
|
|
82
108
|
function createEmbed(options) {
|
|
83
|
-
const { array = false,
|
|
84
|
-
const embed =
|
|
109
|
+
const { array = false, from, fromIndex = 0, ...data } = options;
|
|
110
|
+
const embed = from ? "message" in from ? EmbedPlusBuilder.fromInteraction(from, fromIndex, data) : EmbedPlusBuilder.fromMessage(from, fromIndex, data) : new EmbedPlusBuilder(data);
|
|
85
111
|
return array ? [embed] : embed;
|
|
86
112
|
}
|
|
87
113
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EmbedBuilder } from 'discord.js';
|
|
2
|
-
import { chars } from '../../constants/chars.mjs';
|
|
1
|
+
import { EmbedBuilder, AttachmentBuilder } from 'discord.js';
|
|
3
2
|
import { createEmbedAsset } from './assets.mjs';
|
|
4
3
|
import { EmbedPlusFields } from './fields.mjs';
|
|
5
4
|
import { createEmbedFooter } from './footer.mjs';
|
|
5
|
+
import { chars } from '../../constants/chars.mjs';
|
|
6
6
|
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
8
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -52,6 +52,10 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
52
52
|
toString(space = 2) {
|
|
53
53
|
return JSON.stringify(this, null, space);
|
|
54
54
|
}
|
|
55
|
+
toAttachment(data = { name: "embed.png" }, space = 2) {
|
|
56
|
+
const buffer = Buffer.from(this.toString(space), "utf-8");
|
|
57
|
+
return new AttachmentBuilder(buffer, data);
|
|
58
|
+
}
|
|
55
59
|
setBorderColor(color) {
|
|
56
60
|
if (color === null) {
|
|
57
61
|
this.setColor("#2B2D31");
|
|
@@ -63,10 +67,32 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
63
67
|
return this;
|
|
64
68
|
}
|
|
65
69
|
setAsset(asset, source) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
this.update({ [asset]: source });
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
setElementImageURL(element, url) {
|
|
74
|
+
switch (element) {
|
|
75
|
+
case "thumbnail":
|
|
76
|
+
case "image": {
|
|
77
|
+
this.setAsset(element, url);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case "author": {
|
|
81
|
+
const author = this.data.author;
|
|
82
|
+
this.setAuthor({
|
|
83
|
+
name: author?.name ?? chars.invisible,
|
|
84
|
+
iconURL: url ?? void 0
|
|
85
|
+
});
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "footer": {
|
|
89
|
+
const footer = this.data.footer;
|
|
90
|
+
this.setFooter({
|
|
91
|
+
text: footer?.text ?? chars.invisible,
|
|
92
|
+
iconURL: url ?? void 0
|
|
93
|
+
});
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
70
96
|
}
|
|
71
97
|
return this;
|
|
72
98
|
}
|
|
@@ -78,8 +104,8 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
78
104
|
}
|
|
79
105
|
}
|
|
80
106
|
function createEmbed(options) {
|
|
81
|
-
const { array = false,
|
|
82
|
-
const embed =
|
|
107
|
+
const { array = false, from, fromIndex = 0, ...data } = options;
|
|
108
|
+
const embed = from ? "message" in from ? EmbedPlusBuilder.fromInteraction(from, fromIndex, data) : EmbedPlusBuilder.fromMessage(from, fromIndex, data) : new EmbedPlusBuilder(data);
|
|
83
109
|
return array ? [embed] : embed;
|
|
84
110
|
}
|
|
85
111
|
|
|
@@ -9,10 +9,6 @@ var __publicField = (obj, key, value) => {
|
|
|
9
9
|
class EmbedPlusFields {
|
|
10
10
|
constructor(embed) {
|
|
11
11
|
__publicField(this, "embed");
|
|
12
|
-
Object.defineProperty(this, "embed", {
|
|
13
|
-
enumerable: false,
|
|
14
|
-
value: embed
|
|
15
|
-
});
|
|
16
12
|
this.embed = embed;
|
|
17
13
|
}
|
|
18
14
|
set fields(fields) {
|
|
@@ -7,10 +7,6 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
class EmbedPlusFields {
|
|
8
8
|
constructor(embed) {
|
|
9
9
|
__publicField(this, "embed");
|
|
10
|
-
Object.defineProperty(this, "embed", {
|
|
11
|
-
enumerable: false,
|
|
12
|
-
value: embed
|
|
13
|
-
});
|
|
14
10
|
this.embed = embed;
|
|
15
11
|
}
|
|
16
12
|
set fields(fields) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const discord_js = require('discord.js');
|
|
4
|
+
|
|
5
|
+
function createEmbedFiles(embed, options) {
|
|
6
|
+
const { thumbnail, image, footer, author } = embed.data;
|
|
7
|
+
const files = [];
|
|
8
|
+
const handle = (url, name, ext = "png") => {
|
|
9
|
+
files.push(new discord_js.AttachmentBuilder(url, { name: `${name}.${ext}` }));
|
|
10
|
+
return `attachment://${name}.${ext}`;
|
|
11
|
+
};
|
|
12
|
+
if (thumbnail?.url) {
|
|
13
|
+
const url = handle(thumbnail.url, "thumbnail", options?.extentions?.thumbnail);
|
|
14
|
+
embed.setThumbnail(url);
|
|
15
|
+
}
|
|
16
|
+
if (image?.url) {
|
|
17
|
+
const url = handle(image.url, "image", options?.extentions?.image);
|
|
18
|
+
embed.setImage(url);
|
|
19
|
+
}
|
|
20
|
+
if (author?.icon_url) {
|
|
21
|
+
const url = handle(author?.icon_url, "author", options?.extentions?.author);
|
|
22
|
+
embed.setAuthor({ name: author.name, iconURL: url, url: author.url });
|
|
23
|
+
}
|
|
24
|
+
if (footer?.icon_url) {
|
|
25
|
+
const url = handle(footer.icon_url, "footer", options?.extentions?.footer);
|
|
26
|
+
embed.setFooter({ text: footer.text, iconURL: url });
|
|
27
|
+
}
|
|
28
|
+
return files;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.createEmbedFiles = createEmbedFiles;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AttachmentBuilder } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
function createEmbedFiles(embed, options) {
|
|
4
|
+
const { thumbnail, image, footer, author } = embed.data;
|
|
5
|
+
const files = [];
|
|
6
|
+
const handle = (url, name, ext = "png") => {
|
|
7
|
+
files.push(new AttachmentBuilder(url, { name: `${name}.${ext}` }));
|
|
8
|
+
return `attachment://${name}.${ext}`;
|
|
9
|
+
};
|
|
10
|
+
if (thumbnail?.url) {
|
|
11
|
+
const url = handle(thumbnail.url, "thumbnail", options?.extentions?.thumbnail);
|
|
12
|
+
embed.setThumbnail(url);
|
|
13
|
+
}
|
|
14
|
+
if (image?.url) {
|
|
15
|
+
const url = handle(image.url, "image", options?.extentions?.image);
|
|
16
|
+
embed.setImage(url);
|
|
17
|
+
}
|
|
18
|
+
if (author?.icon_url) {
|
|
19
|
+
const url = handle(author?.icon_url, "author", options?.extentions?.author);
|
|
20
|
+
embed.setAuthor({ name: author.name, iconURL: url, url: author.url });
|
|
21
|
+
}
|
|
22
|
+
if (footer?.icon_url) {
|
|
23
|
+
const url = handle(footer.icon_url, "footer", options?.extentions?.footer);
|
|
24
|
+
embed.setFooter({ text: footer.text, iconURL: url });
|
|
25
|
+
}
|
|
26
|
+
return files;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { createEmbedFiles };
|
package/dist/functions/misc.cjs
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
const discord_js = require('discord.js');
|
|
4
4
|
|
|
5
5
|
function setMobileStatus() {
|
|
6
|
-
discord_js.DefaultWebSocketManagerOptions.identifyProperties
|
|
6
|
+
Object.assign(discord_js.DefaultWebSocketManagerOptions.identifyProperties, {
|
|
7
|
+
browser: "Discord Android"
|
|
8
|
+
});
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
exports.setMobileStatus = setMobileStatus;
|
package/dist/functions/misc.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { DefaultWebSocketManagerOptions } from 'discord.js';
|
|
2
2
|
|
|
3
3
|
function setMobileStatus() {
|
|
4
|
-
DefaultWebSocketManagerOptions.identifyProperties
|
|
4
|
+
Object.assign(DefaultWebSocketManagerOptions.identifyProperties, {
|
|
5
|
+
browser: "Discord Android"
|
|
6
|
+
});
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
export { setMobileStatus };
|
package/dist/index.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const assets = require('./functions/embeds/assets.cjs');
|
|
|
7
7
|
const author = require('./functions/embeds/author.cjs');
|
|
8
8
|
const embedplus = require('./functions/embeds/embedplus.cjs');
|
|
9
9
|
const footer = require('./functions/embeds/footer.cjs');
|
|
10
|
+
const files = require('./functions/embeds/files.cjs');
|
|
10
11
|
const components = require('./functions/components.cjs');
|
|
11
12
|
const channels = require('./functions/channels.cjs');
|
|
12
13
|
const commands = require('./functions/commands.cjs');
|
|
@@ -29,10 +30,14 @@ exports.createEmbedAuthor = author.createEmbedAuthor;
|
|
|
29
30
|
exports.EmbedPlusBuilder = embedplus.EmbedPlusBuilder;
|
|
30
31
|
exports.createEmbed = embedplus.createEmbed;
|
|
31
32
|
exports.createEmbedFooter = footer.createEmbedFooter;
|
|
33
|
+
exports.createEmbedFiles = files.createEmbedFiles;
|
|
32
34
|
exports.createLinkButton = components.createLinkButton;
|
|
33
35
|
exports.createRow = components.createRow;
|
|
34
36
|
exports.findChannel = channels.findChannel;
|
|
35
37
|
exports.getChannelUrlInfo = channels.getChannelUrlInfo;
|
|
38
|
+
exports.createCommandOptions = commands.createCommandOptions;
|
|
39
|
+
exports.createSubCommands = commands.createSubCommands;
|
|
40
|
+
exports.createSubCommandsGroups = commands.createSubCommandsGroups;
|
|
36
41
|
exports.findCommand = commands.findCommand;
|
|
37
42
|
exports.createModalFields = modals.createModalFields;
|
|
38
43
|
exports.createModalInput = modals.createModalInput;
|
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, APIEmbed, Embed, EmbedData, EmbedBuilder,
|
|
2
|
+
import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, LinkButtonComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, ApplicationCommandOptionData, ApplicationCommandSubCommandData, ApplicationCommandSubGroupData, TextInputBuilder, ModalSubmitFields, Collection, TextInputComponent, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const chars: {
|
|
@@ -132,19 +132,33 @@ declare class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
132
132
|
has(property: keyof EmbedPlusData): boolean;
|
|
133
133
|
toArray(): EmbedPlusBuilder[];
|
|
134
134
|
toString(space?: number): string;
|
|
135
|
+
toAttachment(data?: AttachmentData, space?: number): AttachmentBuilder;
|
|
135
136
|
setBorderColor(color: EmbedPlusColorData | null): this;
|
|
136
137
|
setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
|
|
138
|
+
setElementImageURL(element: "thumbnail" | "image" | "author" | "footer", url: string | null): this;
|
|
137
139
|
static fromInteraction(interaction: InteractionWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
138
140
|
static fromMessage(message: MessageWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
139
141
|
}
|
|
140
142
|
type EmbedPlusProperty<P extends keyof EmbedPlusData> = EmbedPlusData[P];
|
|
141
143
|
interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
|
|
142
144
|
array?: B;
|
|
143
|
-
|
|
145
|
+
from?: InteractionWithEmbeds | MessageWithEmbeds;
|
|
146
|
+
fromIndex?: number;
|
|
144
147
|
}
|
|
145
148
|
type CreateEmbedReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
|
|
146
149
|
declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): CreateEmbedReturn<B>;
|
|
147
150
|
|
|
151
|
+
type ImageFileExtention = "png" | "jpg" | "gif" | "webp";
|
|
152
|
+
type ImageElementProperty = "author" | "thumbnail" | "image" | "footer";
|
|
153
|
+
interface CreateEmbedFilesOptions {
|
|
154
|
+
extentions?: Record<ImageElementProperty, ImageFileExtention>;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
*
|
|
158
|
+
* Turns any embed image url into an attachment and returns an attachment array
|
|
159
|
+
*/
|
|
160
|
+
declare function createEmbedFiles(embed: EmbedPlusBuilder, options?: CreateEmbedFilesOptions): AttachmentBuilder[];
|
|
161
|
+
|
|
148
162
|
declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
|
|
149
163
|
interface CreateLinkButtonData extends Omit<LinkButtonComponentData, "style" | "type"> {
|
|
150
164
|
}
|
|
@@ -188,6 +202,35 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
|
|
|
188
202
|
guild: discord_js.GuildResolvable;
|
|
189
203
|
}> | undefined;
|
|
190
204
|
};
|
|
205
|
+
type OmitCommandDataProps = "name" | "options" | "autocomplete" | "type";
|
|
206
|
+
type CommandOption = Exclude<Omit<ApplicationCommandOptionData, "name">, ApplicationCommandSubGroupData | ApplicationCommandSubCommandData>;
|
|
207
|
+
type CommandOptions = Record<string, CommandOption>;
|
|
208
|
+
/**
|
|
209
|
+
* Creates an array of command options, quickly define command options with a record where the key is the option name and the value is the definitions
|
|
210
|
+
* @param groups
|
|
211
|
+
* @returns
|
|
212
|
+
*/
|
|
213
|
+
declare function createCommandOptions(options: CommandOptions): ApplicationCommandOptionData[];
|
|
214
|
+
type SubCommand = Omit<ApplicationCommandSubCommandData, OmitCommandDataProps> & {
|
|
215
|
+
options?: Record<string, CommandOption>;
|
|
216
|
+
};
|
|
217
|
+
type SubCommands = Record<string, SubCommand>;
|
|
218
|
+
/**
|
|
219
|
+
* Create an array of command options, quickly define subcommands with a record where the key is the subcommand name and the value is the definitions
|
|
220
|
+
* @param groups
|
|
221
|
+
* @returns
|
|
222
|
+
*/
|
|
223
|
+
declare function createSubCommands(subcommands: SubCommands): ApplicationCommandSubCommandData[];
|
|
224
|
+
type SubCommandGroup = Omit<ApplicationCommandSubGroupData, OmitCommandDataProps> & {
|
|
225
|
+
subcommands: SubCommands;
|
|
226
|
+
};
|
|
227
|
+
type SubCommandGroups = Record<string, SubCommandGroup>;
|
|
228
|
+
/**
|
|
229
|
+
* Create an array of command options, quickly define groups of subcommands with a record where the key is the group name and the value is the definitions
|
|
230
|
+
* @param groups
|
|
231
|
+
* @returns
|
|
232
|
+
*/
|
|
233
|
+
declare function createSubCommandsGroups(groups: SubCommandGroups): ApplicationCommandSubGroupData[];
|
|
191
234
|
|
|
192
235
|
type TextInputData = Omit<TextInputComponentData, "type">;
|
|
193
236
|
type CreateModalInputData = TextInputData;
|
|
@@ -267,4 +310,4 @@ declare function findRole(guild: Guild): {
|
|
|
267
310
|
*/
|
|
268
311
|
declare function extractMentionId(mention: string): string | null;
|
|
269
312
|
|
|
270
|
-
export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, EmbedPlusBuilder, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
|
|
313
|
+
export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, createCommandOptions, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, createSubCommands, createSubCommandsGroups, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
|
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, APIEmbed, Embed, EmbedData, EmbedBuilder,
|
|
2
|
+
import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, LinkButtonComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, ApplicationCommandOptionData, ApplicationCommandSubCommandData, ApplicationCommandSubGroupData, TextInputBuilder, ModalSubmitFields, Collection, TextInputComponent, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const chars: {
|
|
@@ -132,19 +132,33 @@ declare class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
132
132
|
has(property: keyof EmbedPlusData): boolean;
|
|
133
133
|
toArray(): EmbedPlusBuilder[];
|
|
134
134
|
toString(space?: number): string;
|
|
135
|
+
toAttachment(data?: AttachmentData, space?: number): AttachmentBuilder;
|
|
135
136
|
setBorderColor(color: EmbedPlusColorData | null): this;
|
|
136
137
|
setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
|
|
138
|
+
setElementImageURL(element: "thumbnail" | "image" | "author" | "footer", url: string | null): this;
|
|
137
139
|
static fromInteraction(interaction: InteractionWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
138
140
|
static fromMessage(message: MessageWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
139
141
|
}
|
|
140
142
|
type EmbedPlusProperty<P extends keyof EmbedPlusData> = EmbedPlusData[P];
|
|
141
143
|
interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
|
|
142
144
|
array?: B;
|
|
143
|
-
|
|
145
|
+
from?: InteractionWithEmbeds | MessageWithEmbeds;
|
|
146
|
+
fromIndex?: number;
|
|
144
147
|
}
|
|
145
148
|
type CreateEmbedReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
|
|
146
149
|
declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): CreateEmbedReturn<B>;
|
|
147
150
|
|
|
151
|
+
type ImageFileExtention = "png" | "jpg" | "gif" | "webp";
|
|
152
|
+
type ImageElementProperty = "author" | "thumbnail" | "image" | "footer";
|
|
153
|
+
interface CreateEmbedFilesOptions {
|
|
154
|
+
extentions?: Record<ImageElementProperty, ImageFileExtention>;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
*
|
|
158
|
+
* Turns any embed image url into an attachment and returns an attachment array
|
|
159
|
+
*/
|
|
160
|
+
declare function createEmbedFiles(embed: EmbedPlusBuilder, options?: CreateEmbedFilesOptions): AttachmentBuilder[];
|
|
161
|
+
|
|
148
162
|
declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
|
|
149
163
|
interface CreateLinkButtonData extends Omit<LinkButtonComponentData, "style" | "type"> {
|
|
150
164
|
}
|
|
@@ -188,6 +202,35 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
|
|
|
188
202
|
guild: discord_js.GuildResolvable;
|
|
189
203
|
}> | undefined;
|
|
190
204
|
};
|
|
205
|
+
type OmitCommandDataProps = "name" | "options" | "autocomplete" | "type";
|
|
206
|
+
type CommandOption = Exclude<Omit<ApplicationCommandOptionData, "name">, ApplicationCommandSubGroupData | ApplicationCommandSubCommandData>;
|
|
207
|
+
type CommandOptions = Record<string, CommandOption>;
|
|
208
|
+
/**
|
|
209
|
+
* Creates an array of command options, quickly define command options with a record where the key is the option name and the value is the definitions
|
|
210
|
+
* @param groups
|
|
211
|
+
* @returns
|
|
212
|
+
*/
|
|
213
|
+
declare function createCommandOptions(options: CommandOptions): ApplicationCommandOptionData[];
|
|
214
|
+
type SubCommand = Omit<ApplicationCommandSubCommandData, OmitCommandDataProps> & {
|
|
215
|
+
options?: Record<string, CommandOption>;
|
|
216
|
+
};
|
|
217
|
+
type SubCommands = Record<string, SubCommand>;
|
|
218
|
+
/**
|
|
219
|
+
* Create an array of command options, quickly define subcommands with a record where the key is the subcommand name and the value is the definitions
|
|
220
|
+
* @param groups
|
|
221
|
+
* @returns
|
|
222
|
+
*/
|
|
223
|
+
declare function createSubCommands(subcommands: SubCommands): ApplicationCommandSubCommandData[];
|
|
224
|
+
type SubCommandGroup = Omit<ApplicationCommandSubGroupData, OmitCommandDataProps> & {
|
|
225
|
+
subcommands: SubCommands;
|
|
226
|
+
};
|
|
227
|
+
type SubCommandGroups = Record<string, SubCommandGroup>;
|
|
228
|
+
/**
|
|
229
|
+
* Create an array of command options, quickly define groups of subcommands with a record where the key is the group name and the value is the definitions
|
|
230
|
+
* @param groups
|
|
231
|
+
* @returns
|
|
232
|
+
*/
|
|
233
|
+
declare function createSubCommandsGroups(groups: SubCommandGroups): ApplicationCommandSubGroupData[];
|
|
191
234
|
|
|
192
235
|
type TextInputData = Omit<TextInputComponentData, "type">;
|
|
193
236
|
type CreateModalInputData = TextInputData;
|
|
@@ -267,4 +310,4 @@ declare function findRole(guild: Guild): {
|
|
|
267
310
|
*/
|
|
268
311
|
declare function extractMentionId(mention: string): string | null;
|
|
269
312
|
|
|
270
|
-
export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, EmbedPlusBuilder, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
|
|
313
|
+
export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, createCommandOptions, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, createSubCommands, createSubCommandsGroups, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
|
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, APIEmbed, Embed, EmbedData, EmbedBuilder,
|
|
2
|
+
import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, LinkButtonComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, ApplicationCommandOptionData, ApplicationCommandSubCommandData, ApplicationCommandSubGroupData, TextInputBuilder, ModalSubmitFields, Collection, TextInputComponent, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const chars: {
|
|
@@ -132,19 +132,33 @@ declare class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
132
132
|
has(property: keyof EmbedPlusData): boolean;
|
|
133
133
|
toArray(): EmbedPlusBuilder[];
|
|
134
134
|
toString(space?: number): string;
|
|
135
|
+
toAttachment(data?: AttachmentData, space?: number): AttachmentBuilder;
|
|
135
136
|
setBorderColor(color: EmbedPlusColorData | null): this;
|
|
136
137
|
setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
|
|
138
|
+
setElementImageURL(element: "thumbnail" | "image" | "author" | "footer", url: string | null): this;
|
|
137
139
|
static fromInteraction(interaction: InteractionWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
138
140
|
static fromMessage(message: MessageWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
139
141
|
}
|
|
140
142
|
type EmbedPlusProperty<P extends keyof EmbedPlusData> = EmbedPlusData[P];
|
|
141
143
|
interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
|
|
142
144
|
array?: B;
|
|
143
|
-
|
|
145
|
+
from?: InteractionWithEmbeds | MessageWithEmbeds;
|
|
146
|
+
fromIndex?: number;
|
|
144
147
|
}
|
|
145
148
|
type CreateEmbedReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
|
|
146
149
|
declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): CreateEmbedReturn<B>;
|
|
147
150
|
|
|
151
|
+
type ImageFileExtention = "png" | "jpg" | "gif" | "webp";
|
|
152
|
+
type ImageElementProperty = "author" | "thumbnail" | "image" | "footer";
|
|
153
|
+
interface CreateEmbedFilesOptions {
|
|
154
|
+
extentions?: Record<ImageElementProperty, ImageFileExtention>;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
*
|
|
158
|
+
* Turns any embed image url into an attachment and returns an attachment array
|
|
159
|
+
*/
|
|
160
|
+
declare function createEmbedFiles(embed: EmbedPlusBuilder, options?: CreateEmbedFilesOptions): AttachmentBuilder[];
|
|
161
|
+
|
|
148
162
|
declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
|
|
149
163
|
interface CreateLinkButtonData extends Omit<LinkButtonComponentData, "style" | "type"> {
|
|
150
164
|
}
|
|
@@ -188,6 +202,35 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
|
|
|
188
202
|
guild: discord_js.GuildResolvable;
|
|
189
203
|
}> | undefined;
|
|
190
204
|
};
|
|
205
|
+
type OmitCommandDataProps = "name" | "options" | "autocomplete" | "type";
|
|
206
|
+
type CommandOption = Exclude<Omit<ApplicationCommandOptionData, "name">, ApplicationCommandSubGroupData | ApplicationCommandSubCommandData>;
|
|
207
|
+
type CommandOptions = Record<string, CommandOption>;
|
|
208
|
+
/**
|
|
209
|
+
* Creates an array of command options, quickly define command options with a record where the key is the option name and the value is the definitions
|
|
210
|
+
* @param groups
|
|
211
|
+
* @returns
|
|
212
|
+
*/
|
|
213
|
+
declare function createCommandOptions(options: CommandOptions): ApplicationCommandOptionData[];
|
|
214
|
+
type SubCommand = Omit<ApplicationCommandSubCommandData, OmitCommandDataProps> & {
|
|
215
|
+
options?: Record<string, CommandOption>;
|
|
216
|
+
};
|
|
217
|
+
type SubCommands = Record<string, SubCommand>;
|
|
218
|
+
/**
|
|
219
|
+
* Create an array of command options, quickly define subcommands with a record where the key is the subcommand name and the value is the definitions
|
|
220
|
+
* @param groups
|
|
221
|
+
* @returns
|
|
222
|
+
*/
|
|
223
|
+
declare function createSubCommands(subcommands: SubCommands): ApplicationCommandSubCommandData[];
|
|
224
|
+
type SubCommandGroup = Omit<ApplicationCommandSubGroupData, OmitCommandDataProps> & {
|
|
225
|
+
subcommands: SubCommands;
|
|
226
|
+
};
|
|
227
|
+
type SubCommandGroups = Record<string, SubCommandGroup>;
|
|
228
|
+
/**
|
|
229
|
+
* Create an array of command options, quickly define groups of subcommands with a record where the key is the group name and the value is the definitions
|
|
230
|
+
* @param groups
|
|
231
|
+
* @returns
|
|
232
|
+
*/
|
|
233
|
+
declare function createSubCommandsGroups(groups: SubCommandGroups): ApplicationCommandSubGroupData[];
|
|
191
234
|
|
|
192
235
|
type TextInputData = Omit<TextInputComponentData, "type">;
|
|
193
236
|
type CreateModalInputData = TextInputData;
|
|
@@ -267,4 +310,4 @@ declare function findRole(guild: Guild): {
|
|
|
267
310
|
*/
|
|
268
311
|
declare function extractMentionId(mention: string): string | null;
|
|
269
312
|
|
|
270
|
-
export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, EmbedPlusBuilder, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
|
|
313
|
+
export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, createCommandOptions, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, createSubCommands, createSubCommandsGroups, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
|
package/dist/index.mjs
CHANGED
|
@@ -5,9 +5,10 @@ export { createEmbedAsset } from './functions/embeds/assets.mjs';
|
|
|
5
5
|
export { createEmbedAuthor } from './functions/embeds/author.mjs';
|
|
6
6
|
export { EmbedPlusBuilder, createEmbed } from './functions/embeds/embedplus.mjs';
|
|
7
7
|
export { createEmbedFooter } from './functions/embeds/footer.mjs';
|
|
8
|
+
export { createEmbedFiles } from './functions/embeds/files.mjs';
|
|
8
9
|
export { createLinkButton, createRow } from './functions/components.mjs';
|
|
9
10
|
export { findChannel, getChannelUrlInfo } from './functions/channels.mjs';
|
|
10
|
-
export { findCommand } from './functions/commands.mjs';
|
|
11
|
+
export { createCommandOptions, createSubCommands, createSubCommandsGroups, findCommand } from './functions/commands.mjs';
|
|
11
12
|
export { createModalFields, createModalInput, modalFieldsToRecord } from './functions/modals.mjs';
|
|
12
13
|
export { findEmoji } from './functions/emojis.mjs';
|
|
13
14
|
export { findMember } from './functions/members.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicyan/discord",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"description": "Simple functions to facilitate discord bot development",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"dev": "tsx --env-file .env playground/index.ts"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"tsx": "^4.
|
|
38
|
+
"tsx": "^4.10.0",
|
|
39
39
|
"unbuild": "^2.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@magicyan/core": "^1.0.
|
|
42
|
+
"@magicyan/core": "^1.0.19"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"discord.js": "^14.
|
|
45
|
+
"discord.js": "^14.15.2"
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|