@magicyan/discord 1.0.31 → 1.0.33
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 +2 -0
- package/dist/functions/embeds/embedplus.mjs +2 -0
- package/dist/functions/embeds/fields.cjs +10 -6
- package/dist/functions/embeds/fields.mjs +10 -6
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +37 -5
- package/dist/index.d.mts +37 -5
- package/dist/index.d.ts +37 -5
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
|
@@ -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 };
|
|
@@ -22,6 +22,8 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
22
22
|
field.inline !== void 0 ? { inline: field.inline } : {}
|
|
23
23
|
));
|
|
24
24
|
const builderData = Object.assign({}, extendsData, embedData, { fields: fields$1 });
|
|
25
|
+
if (builderData.url)
|
|
26
|
+
builderData.url = builderData.url.toString();
|
|
25
27
|
const { color, footer: footer$1, image, thumbnail, timestamp } = embedData;
|
|
26
28
|
if (footer$1)
|
|
27
29
|
Object.assign(builderData, { footer: footer.createEmbedFooter(footer$1) });
|
|
@@ -20,6 +20,8 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
20
20
|
field.inline !== void 0 ? { inline: field.inline } : {}
|
|
21
21
|
));
|
|
22
22
|
const builderData = Object.assign({}, extendsData, embedData, { fields });
|
|
23
|
+
if (builderData.url)
|
|
24
|
+
builderData.url = builderData.url.toString();
|
|
23
25
|
const { color, footer, image, thumbnail, timestamp } = embedData;
|
|
24
26
|
if (footer)
|
|
25
27
|
Object.assign(builderData, { footer: createEmbedFooter(footer) });
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const chars = require('../../constants/chars.cjs');
|
|
4
|
+
|
|
3
5
|
var __defProp = Object.defineProperty;
|
|
4
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
7
|
var __publicField = (obj, key, value) => {
|
|
@@ -9,10 +11,6 @@ var __publicField = (obj, key, value) => {
|
|
|
9
11
|
class EmbedPlusFields {
|
|
10
12
|
constructor(embed) {
|
|
11
13
|
__publicField(this, "embed");
|
|
12
|
-
Object.defineProperty(this, "embed", {
|
|
13
|
-
enumerable: false,
|
|
14
|
-
value: embed
|
|
15
|
-
});
|
|
16
14
|
this.embed = embed;
|
|
17
15
|
}
|
|
18
16
|
set fields(fields) {
|
|
@@ -52,10 +50,10 @@ class EmbedPlusFields {
|
|
|
52
50
|
return this.fields.find(predicate);
|
|
53
51
|
}
|
|
54
52
|
push(...fields) {
|
|
55
|
-
this.embed.addFields(fields);
|
|
53
|
+
this.embed.addFields(fields.map(this.fieldFormat));
|
|
56
54
|
}
|
|
57
55
|
set(...fields) {
|
|
58
|
-
this.embed.setFields(fields);
|
|
56
|
+
this.embed.setFields(fields.map(this.fieldFormat));
|
|
59
57
|
}
|
|
60
58
|
map(callback) {
|
|
61
59
|
return this.toArray().map(callback);
|
|
@@ -102,6 +100,12 @@ class EmbedPlusFields {
|
|
|
102
100
|
return -1;
|
|
103
101
|
}
|
|
104
102
|
}
|
|
103
|
+
fieldFormat(field) {
|
|
104
|
+
return Object.assign(
|
|
105
|
+
{ name: field.name ?? chars.chars.invisible, value: field.value ?? chars.chars.invisible },
|
|
106
|
+
field.inline !== void 0 ? { inline: field.inline } : {}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
105
109
|
}
|
|
106
110
|
|
|
107
111
|
exports.EmbedPlusFields = EmbedPlusFields;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { chars } from '../../constants/chars.mjs';
|
|
2
|
+
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
2
4
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
5
|
var __publicField = (obj, key, value) => {
|
|
@@ -7,10 +9,6 @@ var __publicField = (obj, key, value) => {
|
|
|
7
9
|
class EmbedPlusFields {
|
|
8
10
|
constructor(embed) {
|
|
9
11
|
__publicField(this, "embed");
|
|
10
|
-
Object.defineProperty(this, "embed", {
|
|
11
|
-
enumerable: false,
|
|
12
|
-
value: embed
|
|
13
|
-
});
|
|
14
12
|
this.embed = embed;
|
|
15
13
|
}
|
|
16
14
|
set fields(fields) {
|
|
@@ -50,10 +48,10 @@ class EmbedPlusFields {
|
|
|
50
48
|
return this.fields.find(predicate);
|
|
51
49
|
}
|
|
52
50
|
push(...fields) {
|
|
53
|
-
this.embed.addFields(fields);
|
|
51
|
+
this.embed.addFields(fields.map(this.fieldFormat));
|
|
54
52
|
}
|
|
55
53
|
set(...fields) {
|
|
56
|
-
this.embed.setFields(fields);
|
|
54
|
+
this.embed.setFields(fields.map(this.fieldFormat));
|
|
57
55
|
}
|
|
58
56
|
map(callback) {
|
|
59
57
|
return this.toArray().map(callback);
|
|
@@ -100,6 +98,12 @@ class EmbedPlusFields {
|
|
|
100
98
|
return -1;
|
|
101
99
|
}
|
|
102
100
|
}
|
|
101
|
+
fieldFormat(field) {
|
|
102
|
+
return Object.assign(
|
|
103
|
+
{ name: field.name ?? chars.invisible, value: field.value ?? chars.invisible },
|
|
104
|
+
field.inline !== void 0 ? { inline: field.inline } : {}
|
|
105
|
+
);
|
|
106
|
+
}
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
export { EmbedPlusFields };
|
package/dist/index.cjs
CHANGED
|
@@ -35,6 +35,9 @@ exports.createLinkButton = components.createLinkButton;
|
|
|
35
35
|
exports.createRow = components.createRow;
|
|
36
36
|
exports.findChannel = channels.findChannel;
|
|
37
37
|
exports.getChannelUrlInfo = channels.getChannelUrlInfo;
|
|
38
|
+
exports.createCommandOptions = commands.createCommandOptions;
|
|
39
|
+
exports.createSubCommands = commands.createSubCommands;
|
|
40
|
+
exports.createSubCommandsGroups = commands.createSubCommandsGroups;
|
|
38
41
|
exports.findCommand = commands.findCommand;
|
|
39
42
|
exports.createModalFields = modals.createModalFields;
|
|
40
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, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, LinkButtonComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, TextInputBuilder, ModalSubmitFields, Collection, TextInputComponent, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role } from 'discord.js';
|
|
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: {
|
|
@@ -77,8 +77,8 @@ declare class EmbedPlusFields {
|
|
|
77
77
|
*/
|
|
78
78
|
get(index: number): EmbedPlusFieldData | undefined;
|
|
79
79
|
find(predicate: FieldPredicate): EmbedPlusFieldData | undefined;
|
|
80
|
-
push(...fields: EmbedPlusFieldData[]): void;
|
|
81
|
-
set(...fields: EmbedPlusFieldData[]): void;
|
|
80
|
+
push(...fields: Partial<EmbedPlusFieldData>[]): void;
|
|
81
|
+
set(...fields: Partial<EmbedPlusFieldData>[]): void;
|
|
82
82
|
map<U>(callback: (value: EmbedPlusFieldData, index: number, array: EmbedPlusFieldData[]) => U): U[];
|
|
83
83
|
update(predicate: string | number | FieldPredicate, field: Partial<EmbedPlusFieldData>): boolean;
|
|
84
84
|
delete(predicate: string | number | FieldPredicate): boolean;
|
|
@@ -88,6 +88,7 @@ declare class EmbedPlusFields {
|
|
|
88
88
|
clear(): this;
|
|
89
89
|
toArray(): EmbedPlusFieldData[];
|
|
90
90
|
private getPredicateIndex;
|
|
91
|
+
private fieldFormat;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
type EmbedPlusFooterData = {
|
|
@@ -106,7 +107,9 @@ interface EmbedPlusData {
|
|
|
106
107
|
title?: string | null;
|
|
107
108
|
color?: EmbedPlusColorData | null;
|
|
108
109
|
description?: string | null;
|
|
109
|
-
url?: string | null
|
|
110
|
+
url?: string | null | {
|
|
111
|
+
toString(): string;
|
|
112
|
+
};
|
|
110
113
|
thumbnail?: EmbedPlusAssetData;
|
|
111
114
|
image?: EmbedPlusAssetData;
|
|
112
115
|
fields?: Partial<EmbedPlusFieldData>[] | null;
|
|
@@ -202,6 +205,35 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
|
|
|
202
205
|
guild: discord_js.GuildResolvable;
|
|
203
206
|
}> | undefined;
|
|
204
207
|
};
|
|
208
|
+
type OmitCommandDataProps = "name" | "options" | "autocomplete" | "type";
|
|
209
|
+
type CommandOption = Exclude<Omit<ApplicationCommandOptionData, "name">, ApplicationCommandSubGroupData | ApplicationCommandSubCommandData>;
|
|
210
|
+
type CommandOptions = Record<string, CommandOption>;
|
|
211
|
+
/**
|
|
212
|
+
* 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
|
|
213
|
+
* @param groups
|
|
214
|
+
* @returns
|
|
215
|
+
*/
|
|
216
|
+
declare function createCommandOptions(options: CommandOptions): ApplicationCommandOptionData[];
|
|
217
|
+
type SubCommand = Omit<ApplicationCommandSubCommandData, OmitCommandDataProps> & {
|
|
218
|
+
options?: Record<string, CommandOption>;
|
|
219
|
+
};
|
|
220
|
+
type SubCommands = Record<string, SubCommand>;
|
|
221
|
+
/**
|
|
222
|
+
* 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
|
|
223
|
+
* @param groups
|
|
224
|
+
* @returns
|
|
225
|
+
*/
|
|
226
|
+
declare function createSubCommands(subcommands: SubCommands): ApplicationCommandSubCommandData[];
|
|
227
|
+
type SubCommandGroup = Omit<ApplicationCommandSubGroupData, OmitCommandDataProps> & {
|
|
228
|
+
subcommands: SubCommands;
|
|
229
|
+
};
|
|
230
|
+
type SubCommandGroups = Record<string, SubCommandGroup>;
|
|
231
|
+
/**
|
|
232
|
+
* 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
|
|
233
|
+
* @param groups
|
|
234
|
+
* @returns
|
|
235
|
+
*/
|
|
236
|
+
declare function createSubCommandsGroups(groups: SubCommandGroups): ApplicationCommandSubGroupData[];
|
|
205
237
|
|
|
206
238
|
type TextInputData = Omit<TextInputComponentData, "type">;
|
|
207
239
|
type CreateModalInputData = TextInputData;
|
|
@@ -281,4 +313,4 @@ declare function findRole(guild: Guild): {
|
|
|
281
313
|
*/
|
|
282
314
|
declare function extractMentionId(mention: string): string | null;
|
|
283
315
|
|
|
284
|
-
export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
|
|
316
|
+
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, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, LinkButtonComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, TextInputBuilder, ModalSubmitFields, Collection, TextInputComponent, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role } from 'discord.js';
|
|
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: {
|
|
@@ -77,8 +77,8 @@ declare class EmbedPlusFields {
|
|
|
77
77
|
*/
|
|
78
78
|
get(index: number): EmbedPlusFieldData | undefined;
|
|
79
79
|
find(predicate: FieldPredicate): EmbedPlusFieldData | undefined;
|
|
80
|
-
push(...fields: EmbedPlusFieldData[]): void;
|
|
81
|
-
set(...fields: EmbedPlusFieldData[]): void;
|
|
80
|
+
push(...fields: Partial<EmbedPlusFieldData>[]): void;
|
|
81
|
+
set(...fields: Partial<EmbedPlusFieldData>[]): void;
|
|
82
82
|
map<U>(callback: (value: EmbedPlusFieldData, index: number, array: EmbedPlusFieldData[]) => U): U[];
|
|
83
83
|
update(predicate: string | number | FieldPredicate, field: Partial<EmbedPlusFieldData>): boolean;
|
|
84
84
|
delete(predicate: string | number | FieldPredicate): boolean;
|
|
@@ -88,6 +88,7 @@ declare class EmbedPlusFields {
|
|
|
88
88
|
clear(): this;
|
|
89
89
|
toArray(): EmbedPlusFieldData[];
|
|
90
90
|
private getPredicateIndex;
|
|
91
|
+
private fieldFormat;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
type EmbedPlusFooterData = {
|
|
@@ -106,7 +107,9 @@ interface EmbedPlusData {
|
|
|
106
107
|
title?: string | null;
|
|
107
108
|
color?: EmbedPlusColorData | null;
|
|
108
109
|
description?: string | null;
|
|
109
|
-
url?: string | null
|
|
110
|
+
url?: string | null | {
|
|
111
|
+
toString(): string;
|
|
112
|
+
};
|
|
110
113
|
thumbnail?: EmbedPlusAssetData;
|
|
111
114
|
image?: EmbedPlusAssetData;
|
|
112
115
|
fields?: Partial<EmbedPlusFieldData>[] | null;
|
|
@@ -202,6 +205,35 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
|
|
|
202
205
|
guild: discord_js.GuildResolvable;
|
|
203
206
|
}> | undefined;
|
|
204
207
|
};
|
|
208
|
+
type OmitCommandDataProps = "name" | "options" | "autocomplete" | "type";
|
|
209
|
+
type CommandOption = Exclude<Omit<ApplicationCommandOptionData, "name">, ApplicationCommandSubGroupData | ApplicationCommandSubCommandData>;
|
|
210
|
+
type CommandOptions = Record<string, CommandOption>;
|
|
211
|
+
/**
|
|
212
|
+
* 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
|
|
213
|
+
* @param groups
|
|
214
|
+
* @returns
|
|
215
|
+
*/
|
|
216
|
+
declare function createCommandOptions(options: CommandOptions): ApplicationCommandOptionData[];
|
|
217
|
+
type SubCommand = Omit<ApplicationCommandSubCommandData, OmitCommandDataProps> & {
|
|
218
|
+
options?: Record<string, CommandOption>;
|
|
219
|
+
};
|
|
220
|
+
type SubCommands = Record<string, SubCommand>;
|
|
221
|
+
/**
|
|
222
|
+
* 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
|
|
223
|
+
* @param groups
|
|
224
|
+
* @returns
|
|
225
|
+
*/
|
|
226
|
+
declare function createSubCommands(subcommands: SubCommands): ApplicationCommandSubCommandData[];
|
|
227
|
+
type SubCommandGroup = Omit<ApplicationCommandSubGroupData, OmitCommandDataProps> & {
|
|
228
|
+
subcommands: SubCommands;
|
|
229
|
+
};
|
|
230
|
+
type SubCommandGroups = Record<string, SubCommandGroup>;
|
|
231
|
+
/**
|
|
232
|
+
* 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
|
|
233
|
+
* @param groups
|
|
234
|
+
* @returns
|
|
235
|
+
*/
|
|
236
|
+
declare function createSubCommandsGroups(groups: SubCommandGroups): ApplicationCommandSubGroupData[];
|
|
205
237
|
|
|
206
238
|
type TextInputData = Omit<TextInputComponentData, "type">;
|
|
207
239
|
type CreateModalInputData = TextInputData;
|
|
@@ -281,4 +313,4 @@ declare function findRole(guild: Guild): {
|
|
|
281
313
|
*/
|
|
282
314
|
declare function extractMentionId(mention: string): string | null;
|
|
283
315
|
|
|
284
|
-
export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
|
|
316
|
+
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, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, LinkButtonComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, TextInputBuilder, ModalSubmitFields, Collection, TextInputComponent, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role } from 'discord.js';
|
|
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: {
|
|
@@ -77,8 +77,8 @@ declare class EmbedPlusFields {
|
|
|
77
77
|
*/
|
|
78
78
|
get(index: number): EmbedPlusFieldData | undefined;
|
|
79
79
|
find(predicate: FieldPredicate): EmbedPlusFieldData | undefined;
|
|
80
|
-
push(...fields: EmbedPlusFieldData[]): void;
|
|
81
|
-
set(...fields: EmbedPlusFieldData[]): void;
|
|
80
|
+
push(...fields: Partial<EmbedPlusFieldData>[]): void;
|
|
81
|
+
set(...fields: Partial<EmbedPlusFieldData>[]): void;
|
|
82
82
|
map<U>(callback: (value: EmbedPlusFieldData, index: number, array: EmbedPlusFieldData[]) => U): U[];
|
|
83
83
|
update(predicate: string | number | FieldPredicate, field: Partial<EmbedPlusFieldData>): boolean;
|
|
84
84
|
delete(predicate: string | number | FieldPredicate): boolean;
|
|
@@ -88,6 +88,7 @@ declare class EmbedPlusFields {
|
|
|
88
88
|
clear(): this;
|
|
89
89
|
toArray(): EmbedPlusFieldData[];
|
|
90
90
|
private getPredicateIndex;
|
|
91
|
+
private fieldFormat;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
type EmbedPlusFooterData = {
|
|
@@ -106,7 +107,9 @@ interface EmbedPlusData {
|
|
|
106
107
|
title?: string | null;
|
|
107
108
|
color?: EmbedPlusColorData | null;
|
|
108
109
|
description?: string | null;
|
|
109
|
-
url?: string | null
|
|
110
|
+
url?: string | null | {
|
|
111
|
+
toString(): string;
|
|
112
|
+
};
|
|
110
113
|
thumbnail?: EmbedPlusAssetData;
|
|
111
114
|
image?: EmbedPlusAssetData;
|
|
112
115
|
fields?: Partial<EmbedPlusFieldData>[] | null;
|
|
@@ -202,6 +205,35 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
|
|
|
202
205
|
guild: discord_js.GuildResolvable;
|
|
203
206
|
}> | undefined;
|
|
204
207
|
};
|
|
208
|
+
type OmitCommandDataProps = "name" | "options" | "autocomplete" | "type";
|
|
209
|
+
type CommandOption = Exclude<Omit<ApplicationCommandOptionData, "name">, ApplicationCommandSubGroupData | ApplicationCommandSubCommandData>;
|
|
210
|
+
type CommandOptions = Record<string, CommandOption>;
|
|
211
|
+
/**
|
|
212
|
+
* 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
|
|
213
|
+
* @param groups
|
|
214
|
+
* @returns
|
|
215
|
+
*/
|
|
216
|
+
declare function createCommandOptions(options: CommandOptions): ApplicationCommandOptionData[];
|
|
217
|
+
type SubCommand = Omit<ApplicationCommandSubCommandData, OmitCommandDataProps> & {
|
|
218
|
+
options?: Record<string, CommandOption>;
|
|
219
|
+
};
|
|
220
|
+
type SubCommands = Record<string, SubCommand>;
|
|
221
|
+
/**
|
|
222
|
+
* 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
|
|
223
|
+
* @param groups
|
|
224
|
+
* @returns
|
|
225
|
+
*/
|
|
226
|
+
declare function createSubCommands(subcommands: SubCommands): ApplicationCommandSubCommandData[];
|
|
227
|
+
type SubCommandGroup = Omit<ApplicationCommandSubGroupData, OmitCommandDataProps> & {
|
|
228
|
+
subcommands: SubCommands;
|
|
229
|
+
};
|
|
230
|
+
type SubCommandGroups = Record<string, SubCommandGroup>;
|
|
231
|
+
/**
|
|
232
|
+
* 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
|
|
233
|
+
* @param groups
|
|
234
|
+
* @returns
|
|
235
|
+
*/
|
|
236
|
+
declare function createSubCommandsGroups(groups: SubCommandGroups): ApplicationCommandSubGroupData[];
|
|
205
237
|
|
|
206
238
|
type TextInputData = Omit<TextInputComponentData, "type">;
|
|
207
239
|
type CreateModalInputData = TextInputData;
|
|
@@ -281,4 +313,4 @@ declare function findRole(guild: Guild): {
|
|
|
281
313
|
*/
|
|
282
314
|
declare function extractMentionId(mention: string): string | null;
|
|
283
315
|
|
|
284
|
-
export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
|
|
316
|
+
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
|
@@ -8,7 +8,7 @@ export { createEmbedFooter } from './functions/embeds/footer.mjs';
|
|
|
8
8
|
export { createEmbedFiles } from './functions/embeds/files.mjs';
|
|
9
9
|
export { createLinkButton, createRow } from './functions/components.mjs';
|
|
10
10
|
export { findChannel, getChannelUrlInfo } from './functions/channels.mjs';
|
|
11
|
-
export { findCommand } from './functions/commands.mjs';
|
|
11
|
+
export { createCommandOptions, createSubCommands, createSubCommandsGroups, findCommand } from './functions/commands.mjs';
|
|
12
12
|
export { createModalFields, createModalInput, modalFieldsToRecord } from './functions/modals.mjs';
|
|
13
13
|
export { findEmoji } from './functions/emojis.mjs';
|
|
14
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.33",
|
|
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
|
}
|