@magicyan/discord 1.0.34 → 1.1.0

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.
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const colors = {
4
+ embedbg: "#2B2D31"
5
+ };
6
+
7
+ exports.colors = colors;
@@ -0,0 +1,5 @@
1
+ const colors = {
2
+ embedbg: "#2B2D31"
3
+ };
4
+
5
+ export { colors };
@@ -16,28 +16,16 @@ 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
- });
19
+ function commandMention(command, a, b) {
20
+ const args = [command.name, command.id];
21
+ if (a && b) {
22
+ args.splice(1, 0, a, b);
23
+ }
24
+ if (a && !b) {
25
+ args.splice(1, 0, a);
26
+ }
27
+ return discord_js.chatInputApplicationCommandMention(...args);
38
28
  }
39
29
 
40
- exports.createCommandOptions = createCommandOptions;
41
- exports.createSubCommands = createSubCommands;
42
- exports.createSubCommandsGroups = createSubCommandsGroups;
30
+ exports.commandMention = commandMention;
43
31
  exports.findCommand = findCommand;
@@ -1,4 +1,4 @@
1
- import { Client, ApplicationCommandOptionType } from 'discord.js';
1
+ import { Client, chatInputApplicationCommandMention } 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,25 +14,15 @@ 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
- });
17
+ function commandMention(command, a, b) {
18
+ const args = [command.name, command.id];
19
+ if (a && b) {
20
+ args.splice(1, 0, a, b);
21
+ }
22
+ if (a && !b) {
23
+ args.splice(1, 0, a);
24
+ }
25
+ return chatInputApplicationCommandMention(...args);
36
26
  }
37
27
 
38
- export { createCommandOptions, createSubCommands, createSubCommandsGroups, findCommand };
28
+ export { commandMention, findCommand };
@@ -5,6 +5,7 @@ const assets = require('./assets.cjs');
5
5
  const fields = require('./fields.cjs');
6
6
  const footer = require('./footer.cjs');
7
7
  const chars = require('../../constants/chars.cjs');
8
+ const colors = require('../../constants/colors.cjs');
8
9
 
9
10
  var __defProp = Object.defineProperty;
10
11
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -36,8 +37,7 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
36
37
  embed.setTimestamp(
37
38
  typeof timestamp === "string" ? new Date(timestamp) : timestamp
38
39
  );
39
- if (color)
40
- embed.setColor(color);
40
+ embed.setColor(color || colors.colors.embedbg);
41
41
  super(embed.data);
42
42
  __publicField(this, "fields");
43
43
  this.fields = new fields.EmbedPlusFields(this);
@@ -62,7 +62,7 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
62
62
  }
63
63
  setBorderColor(color) {
64
64
  if (color === null) {
65
- this.setColor("#2B2D31");
65
+ this.setColor(colors.colors.embedbg);
66
66
  } else if (typeof color === "number") {
67
67
  this.update({ color });
68
68
  } else {
@@ -100,17 +100,11 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
100
100
  }
101
101
  return this;
102
102
  }
103
- static fromInteraction(interaction, index = 0, data = {}) {
104
- return EmbedPlusBuilder.fromMessage(interaction.message, index, data);
105
- }
106
- static fromMessage(message, index = 0, data = {}) {
107
- return new EmbedPlusBuilder(Object.assign({ extends: message.embeds[index] }, data));
108
- }
109
103
  }
110
104
  function createEmbed(options) {
111
105
  const { array = false, from, fromIndex = 0, ...data } = options;
112
- const embed = from ? "message" in from ? EmbedPlusBuilder.fromInteraction(from, fromIndex, data) : EmbedPlusBuilder.fromMessage(from, fromIndex, data) : new EmbedPlusBuilder(data);
113
- return array ? [embed] : embed;
106
+ const fromEmbeds = from ? "message" in from ? from.message.embeds : from.embeds : [];
107
+ return array ? from && fromEmbeds.length > 0 ? fromEmbeds.map((embed) => new EmbedPlusBuilder({ extends: embed })) : [new EmbedPlusBuilder(data)] : from && fromEmbeds.length > 0 ? new EmbedPlusBuilder({ extends: fromEmbeds[fromIndex], ...data }) : new EmbedPlusBuilder(data);
114
108
  }
115
109
 
116
110
  exports.EmbedPlusBuilder = EmbedPlusBuilder;
@@ -3,6 +3,7 @@ import { createEmbedAsset } from './assets.mjs';
3
3
  import { EmbedPlusFields } from './fields.mjs';
4
4
  import { createEmbedFooter } from './footer.mjs';
5
5
  import { chars } from '../../constants/chars.mjs';
6
+ import { colors } from '../../constants/colors.mjs';
6
7
 
7
8
  var __defProp = Object.defineProperty;
8
9
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -34,8 +35,7 @@ class EmbedPlusBuilder extends EmbedBuilder {
34
35
  embed.setTimestamp(
35
36
  typeof timestamp === "string" ? new Date(timestamp) : timestamp
36
37
  );
37
- if (color)
38
- embed.setColor(color);
38
+ embed.setColor(color || colors.embedbg);
39
39
  super(embed.data);
40
40
  __publicField(this, "fields");
41
41
  this.fields = new EmbedPlusFields(this);
@@ -60,7 +60,7 @@ class EmbedPlusBuilder extends EmbedBuilder {
60
60
  }
61
61
  setBorderColor(color) {
62
62
  if (color === null) {
63
- this.setColor("#2B2D31");
63
+ this.setColor(colors.embedbg);
64
64
  } else if (typeof color === "number") {
65
65
  this.update({ color });
66
66
  } else {
@@ -98,17 +98,11 @@ class EmbedPlusBuilder extends EmbedBuilder {
98
98
  }
99
99
  return this;
100
100
  }
101
- static fromInteraction(interaction, index = 0, data = {}) {
102
- return EmbedPlusBuilder.fromMessage(interaction.message, index, data);
103
- }
104
- static fromMessage(message, index = 0, data = {}) {
105
- return new EmbedPlusBuilder(Object.assign({ extends: message.embeds[index] }, data));
106
- }
107
101
  }
108
102
  function createEmbed(options) {
109
103
  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);
111
- return array ? [embed] : embed;
104
+ const fromEmbeds = from ? "message" in from ? from.message.embeds : from.embeds : [];
105
+ return array ? from && fromEmbeds.length > 0 ? fromEmbeds.map((embed) => new EmbedPlusBuilder({ extends: embed })) : [new EmbedPlusBuilder(data)] : from && fromEmbeds.length > 0 ? new EmbedPlusBuilder({ extends: fromEmbeds[fromIndex], ...data }) : new EmbedPlusBuilder(data);
112
106
  }
113
107
 
114
108
  export { EmbedPlusBuilder, createEmbed };
@@ -51,9 +51,14 @@ class EmbedPlusFields {
51
51
  }
52
52
  push(...fields) {
53
53
  this.embed.addFields(fields.map(this.fieldFormat));
54
+ return this;
54
55
  }
55
56
  set(...fields) {
56
57
  this.embed.setFields(fields.map(this.fieldFormat));
58
+ return this;
59
+ }
60
+ insert(index, ...fields) {
61
+ this.fields.splice(index, 0, ...fields.map(this.fieldFormat));
57
62
  }
58
63
  map(callback) {
59
64
  return this.toArray().map(callback);
@@ -49,9 +49,14 @@ class EmbedPlusFields {
49
49
  }
50
50
  push(...fields) {
51
51
  this.embed.addFields(fields.map(this.fieldFormat));
52
+ return this;
52
53
  }
53
54
  set(...fields) {
54
55
  this.embed.setFields(fields.map(this.fieldFormat));
56
+ return this;
57
+ }
58
+ insert(index, ...fields) {
59
+ this.fields.splice(index, 0, ...fields.map(this.fieldFormat));
55
60
  }
56
61
  map(callback) {
57
62
  return this.toArray().map(callback);
package/dist/index.cjs CHANGED
@@ -35,9 +35,7 @@ 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
+ exports.commandMention = commands.commandMention;
41
39
  exports.findCommand = commands.findCommand;
42
40
  exports.createModalFields = modals.createModalFields;
43
41
  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, ApplicationCommandOptionData, ApplicationCommandSubCommandData, ApplicationCommandSubGroupData, TextInputBuilder, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, 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, TextInputBuilder, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role } from 'discord.js';
3
3
  export * from '@magicyan/core';
4
4
 
5
5
  declare const chars: {
@@ -77,8 +77,9 @@ declare class EmbedPlusFields {
77
77
  */
78
78
  get(index: number): EmbedPlusFieldData | undefined;
79
79
  find(predicate: FieldPredicate): EmbedPlusFieldData | undefined;
80
- push(...fields: Partial<EmbedPlusFieldData>[]): void;
81
- set(...fields: Partial<EmbedPlusFieldData>[]): void;
80
+ push(...fields: Partial<EmbedPlusFieldData>[]): this;
81
+ set(...fields: Partial<EmbedPlusFieldData>[]): this;
82
+ insert(index: number, ...fields: Partial<EmbedPlusFieldData>[]): void;
82
83
  map<U>(callback: (value: EmbedPlusFieldData, index: number, array: EmbedPlusFieldData[]) => U): U[];
83
84
  update(predicate: string | number | FieldPredicate, field: Partial<EmbedPlusFieldData>): boolean;
84
85
  delete(predicate: string | number | FieldPredicate): boolean;
@@ -97,6 +98,7 @@ type EmbedPlusFooterData = {
97
98
  };
98
99
  declare function createEmbedFooter(options: EmbedPlusFooterData): EmbedFooterData | undefined;
99
100
 
101
+ type EmbedPlusBuilderReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
100
102
  type EmbedPlusColorData = string & {} | ColorResolvable | null;
101
103
  type EmbedPlusAuthorData = {
102
104
  name: string;
@@ -139,8 +141,6 @@ declare class EmbedPlusBuilder extends EmbedBuilder {
139
141
  setBorderColor(color: EmbedPlusColorData | null): this;
140
142
  setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
141
143
  setElementImageURL(element: "thumbnail" | "image" | "author" | "footer", url: string | null): this;
142
- static fromInteraction(interaction: InteractionWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
143
- static fromMessage(message: MessageWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
144
144
  }
145
145
  type EmbedPlusProperty<P extends keyof EmbedPlusData> = EmbedPlusData[P];
146
146
  interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
@@ -148,8 +148,7 @@ interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
148
148
  from?: InteractionWithEmbeds | MessageWithEmbeds;
149
149
  fromIndex?: number;
150
150
  }
151
- type CreateEmbedReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
152
- declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): CreateEmbedReturn<B>;
151
+ declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): EmbedPlusBuilderReturn<B>;
153
152
 
154
153
  type ImageFileExtention = "png" | "jpg" | "gif" | "webp";
155
154
  type ImageElementProperty = "author" | "thumbnail" | "image" | "footer";
@@ -205,35 +204,12 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
205
204
  guild: discord_js.GuildResolvable;
206
205
  }> | undefined;
207
206
  };
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[];
207
+ interface CommandMentionData {
208
+ id: string;
209
+ name: string;
210
+ }
211
+ declare function commandMention(command: CommandMentionData, group?: string, subcommand?: string): string;
212
+ declare function commandMention(command: CommandMentionData, subcommand?: string): string;
237
213
 
238
214
  type TextInputData = Omit<TextInputComponentData, "type">;
239
215
  interface ModalFieldData extends Omit<TextInputData, "customId" | "style"> {
@@ -317,4 +293,4 @@ declare function findRole(guild: Guild): {
317
293
  */
318
294
  declare function extractMentionId(mention: string): string | null;
319
295
 
320
- 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 };
296
+ export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, commandMention, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, 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, ApplicationCommandOptionData, ApplicationCommandSubCommandData, ApplicationCommandSubGroupData, TextInputBuilder, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, 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, TextInputBuilder, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role } from 'discord.js';
3
3
  export * from '@magicyan/core';
4
4
 
5
5
  declare const chars: {
@@ -77,8 +77,9 @@ declare class EmbedPlusFields {
77
77
  */
78
78
  get(index: number): EmbedPlusFieldData | undefined;
79
79
  find(predicate: FieldPredicate): EmbedPlusFieldData | undefined;
80
- push(...fields: Partial<EmbedPlusFieldData>[]): void;
81
- set(...fields: Partial<EmbedPlusFieldData>[]): void;
80
+ push(...fields: Partial<EmbedPlusFieldData>[]): this;
81
+ set(...fields: Partial<EmbedPlusFieldData>[]): this;
82
+ insert(index: number, ...fields: Partial<EmbedPlusFieldData>[]): void;
82
83
  map<U>(callback: (value: EmbedPlusFieldData, index: number, array: EmbedPlusFieldData[]) => U): U[];
83
84
  update(predicate: string | number | FieldPredicate, field: Partial<EmbedPlusFieldData>): boolean;
84
85
  delete(predicate: string | number | FieldPredicate): boolean;
@@ -97,6 +98,7 @@ type EmbedPlusFooterData = {
97
98
  };
98
99
  declare function createEmbedFooter(options: EmbedPlusFooterData): EmbedFooterData | undefined;
99
100
 
101
+ type EmbedPlusBuilderReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
100
102
  type EmbedPlusColorData = string & {} | ColorResolvable | null;
101
103
  type EmbedPlusAuthorData = {
102
104
  name: string;
@@ -139,8 +141,6 @@ declare class EmbedPlusBuilder extends EmbedBuilder {
139
141
  setBorderColor(color: EmbedPlusColorData | null): this;
140
142
  setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
141
143
  setElementImageURL(element: "thumbnail" | "image" | "author" | "footer", url: string | null): this;
142
- static fromInteraction(interaction: InteractionWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
143
- static fromMessage(message: MessageWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
144
144
  }
145
145
  type EmbedPlusProperty<P extends keyof EmbedPlusData> = EmbedPlusData[P];
146
146
  interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
@@ -148,8 +148,7 @@ interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
148
148
  from?: InteractionWithEmbeds | MessageWithEmbeds;
149
149
  fromIndex?: number;
150
150
  }
151
- type CreateEmbedReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
152
- declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): CreateEmbedReturn<B>;
151
+ declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): EmbedPlusBuilderReturn<B>;
153
152
 
154
153
  type ImageFileExtention = "png" | "jpg" | "gif" | "webp";
155
154
  type ImageElementProperty = "author" | "thumbnail" | "image" | "footer";
@@ -205,35 +204,12 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
205
204
  guild: discord_js.GuildResolvable;
206
205
  }> | undefined;
207
206
  };
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[];
207
+ interface CommandMentionData {
208
+ id: string;
209
+ name: string;
210
+ }
211
+ declare function commandMention(command: CommandMentionData, group?: string, subcommand?: string): string;
212
+ declare function commandMention(command: CommandMentionData, subcommand?: string): string;
237
213
 
238
214
  type TextInputData = Omit<TextInputComponentData, "type">;
239
215
  interface ModalFieldData extends Omit<TextInputData, "customId" | "style"> {
@@ -317,4 +293,4 @@ declare function findRole(guild: Guild): {
317
293
  */
318
294
  declare function extractMentionId(mention: string): string | null;
319
295
 
320
- 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 };
296
+ export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, commandMention, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, 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, ApplicationCommandOptionData, ApplicationCommandSubCommandData, ApplicationCommandSubGroupData, TextInputBuilder, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, 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, TextInputBuilder, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role } from 'discord.js';
3
3
  export * from '@magicyan/core';
4
4
 
5
5
  declare const chars: {
@@ -77,8 +77,9 @@ declare class EmbedPlusFields {
77
77
  */
78
78
  get(index: number): EmbedPlusFieldData | undefined;
79
79
  find(predicate: FieldPredicate): EmbedPlusFieldData | undefined;
80
- push(...fields: Partial<EmbedPlusFieldData>[]): void;
81
- set(...fields: Partial<EmbedPlusFieldData>[]): void;
80
+ push(...fields: Partial<EmbedPlusFieldData>[]): this;
81
+ set(...fields: Partial<EmbedPlusFieldData>[]): this;
82
+ insert(index: number, ...fields: Partial<EmbedPlusFieldData>[]): void;
82
83
  map<U>(callback: (value: EmbedPlusFieldData, index: number, array: EmbedPlusFieldData[]) => U): U[];
83
84
  update(predicate: string | number | FieldPredicate, field: Partial<EmbedPlusFieldData>): boolean;
84
85
  delete(predicate: string | number | FieldPredicate): boolean;
@@ -97,6 +98,7 @@ type EmbedPlusFooterData = {
97
98
  };
98
99
  declare function createEmbedFooter(options: EmbedPlusFooterData): EmbedFooterData | undefined;
99
100
 
101
+ type EmbedPlusBuilderReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
100
102
  type EmbedPlusColorData = string & {} | ColorResolvable | null;
101
103
  type EmbedPlusAuthorData = {
102
104
  name: string;
@@ -139,8 +141,6 @@ declare class EmbedPlusBuilder extends EmbedBuilder {
139
141
  setBorderColor(color: EmbedPlusColorData | null): this;
140
142
  setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
141
143
  setElementImageURL(element: "thumbnail" | "image" | "author" | "footer", url: string | null): this;
142
- static fromInteraction(interaction: InteractionWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
143
- static fromMessage(message: MessageWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
144
144
  }
145
145
  type EmbedPlusProperty<P extends keyof EmbedPlusData> = EmbedPlusData[P];
146
146
  interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
@@ -148,8 +148,7 @@ interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
148
148
  from?: InteractionWithEmbeds | MessageWithEmbeds;
149
149
  fromIndex?: number;
150
150
  }
151
- type CreateEmbedReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
152
- declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): CreateEmbedReturn<B>;
151
+ declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): EmbedPlusBuilderReturn<B>;
153
152
 
154
153
  type ImageFileExtention = "png" | "jpg" | "gif" | "webp";
155
154
  type ImageElementProperty = "author" | "thumbnail" | "image" | "footer";
@@ -205,35 +204,12 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
205
204
  guild: discord_js.GuildResolvable;
206
205
  }> | undefined;
207
206
  };
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[];
207
+ interface CommandMentionData {
208
+ id: string;
209
+ name: string;
210
+ }
211
+ declare function commandMention(command: CommandMentionData, group?: string, subcommand?: string): string;
212
+ declare function commandMention(command: CommandMentionData, subcommand?: string): string;
237
213
 
238
214
  type TextInputData = Omit<TextInputComponentData, "type">;
239
215
  interface ModalFieldData extends Omit<TextInputData, "customId" | "style"> {
@@ -317,4 +293,4 @@ declare function findRole(guild: Guild): {
317
293
  */
318
294
  declare function extractMentionId(mention: string): string | null;
319
295
 
320
- 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 };
296
+ export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, commandMention, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, 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 { createCommandOptions, createSubCommands, createSubCommandsGroups, findCommand } from './functions/commands.mjs';
11
+ export { commandMention, 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.34",
3
+ "version": "1.1.0",
4
4
  "description": "Simple functions to facilitate discord bot development",
5
5
  "license": "MIT",
6
6
  "type": "module",