@magicyan/discord 1.0.11 → 1.0.13

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/README.md CHANGED
@@ -1,4 +1,12 @@
1
- # Magicyan Discord
1
+ <div align="center">
2
+ <img src="../../assets/images/icon.png" alt="Icon" width="100" height="100">
3
+ <div style="margin-left: 20px;">
4
+
5
+ # Magicyan Discord
6
+
7
+ </div>
8
+ </div>
9
+
2
10
 
3
11
  Simple functions to facilitate discord bot development
4
12
  > Also exports all [@magicyan/core](https://github.com/rinckodev/magicyan/tree/main/packages/core) functions
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";const discord_js=require("discord.js"),core=require("@magicyan/core"),a=[discord_js.IntentsBitField.Flags.MessageContent,discord_js.IntentsBitField.Flags.GuildMessages,discord_js.IntentsBitField.Flags.GuildMessageReactions,discord_js.IntentsBitField.Flags.GuildMessageTyping,discord_js.IntentsBitField.Flags.DirectMessages,discord_js.IntentsBitField.Flags.DirectMessageReactions,discord_js.IntentsBitField.Flags.DirectMessageTyping],l=[discord_js.IntentsBitField.Flags.GuildEmojisAndStickers,discord_js.IntentsBitField.Flags.GuildIntegrations,discord_js.IntentsBitField.Flags.GuildInvites,discord_js.IntentsBitField.Flags.GuildMembers,discord_js.IntentsBitField.Flags.GuildMessageReactions,discord_js.IntentsBitField.Flags.GuildMessageTyping,discord_js.IntentsBitField.Flags.GuildMessages,discord_js.IntentsBitField.Flags.GuildModeration,discord_js.IntentsBitField.Flags.GuildPresences,discord_js.IntentsBitField.Flags.GuildScheduledEvents,discord_js.IntentsBitField.Flags.GuildVoiceStates,discord_js.IntentsBitField.Flags.GuildWebhooks,discord_js.IntentsBitField.Flags.Guilds],t=[discord_js.IntentsBitField.Flags.AutoModerationConfiguration,discord_js.IntentsBitField.Flags.AutoModerationExecution],CustomItents={Messages:a,Guild:l,Other:t,All:Object.values(discord_js.IntentsBitField.Flags)},CustomPartials={All:[discord_js.Partials.Channel,discord_js.Partials.GuildMember,discord_js.Partials.GuildScheduledEvent,discord_js.Partials.Message,discord_js.Partials.Reaction,discord_js.Partials.ThreadMember,discord_js.Partials.User]};function findChannel(e,n){const i=n||discord_js.ChannelType.GuildText;return{byName(r){return e.channels.cache.find(s=>s.name===r&&s.type===i)},byId(r){return e.channels.cache.find(s=>s.id===r&&s.type===i)}}}function createEmbedAuthor(e){const{user:n,property:i="displayName",imageSize:r=512,iconURL:s,url:u,prefix:d="",suffix:c=""}=e;return{name:`${d}${n[i]}${c}`,url:u,iconURL:s||n.displayAvatarURL({size:r})}}function createEmbedAsset(e,n){return e instanceof discord_js.Attachment||e instanceof discord_js.AttachmentBuilder?{url:`attachment://${e.name}`,...n}:e?{url:e,...n}:void 0}function createEmbed(e){const{extend:n={},...i}=e,{color:r,modify:s,...u}=i,{color:d,...c}=n,F={...c,...u},o=new discord_js.EmbedBuilder(F);if(d&&o.setColor(d),r&&o.setColor(r),s?.fields&&typeof s.fields=="function"){const g=s.fields(o.data.fields||[]);o.setFields(g)}return o}function findRole(e){return{byName(n){return e.roles.cache.find(i=>i.name==n)},byId(n){return e.roles.cache.get(n)}}}function createRow(...e){return new discord_js.ActionRowBuilder({components:e})}function createModalInput(e){return createRow(new discord_js.TextInputBuilder(e))}function createLinkButton(e){return e.label||(e.label=e.url),new discord_js.ButtonBuilder({style:discord_js.ButtonStyle.Link,...e})}exports.CustomItents=CustomItents,exports.CustomPartials=CustomPartials,exports.createEmbed=createEmbed,exports.createEmbedAsset=createEmbedAsset,exports.createEmbedAuthor=createEmbedAuthor,exports.createLinkButton=createLinkButton,exports.createModalInput=createModalInput,exports.createRow=createRow,exports.findChannel=findChannel,exports.findRole=findRole,Object.keys(core).forEach(function(e){e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&(exports[e]=core[e])});
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/constants/client.ts","../src/functions/channels.ts","../src/functions/embeds.ts","../src/functions/roles.ts","../src/functions/utils.ts"],"sourcesContent":["import { GatewayIntentBits, IntentsBitField, Partials } from \"discord.js\";\r\n\r\nconst Messages = [\r\n IntentsBitField.Flags.MessageContent,\r\n IntentsBitField.Flags.GuildMessages,\r\n IntentsBitField.Flags.GuildMessageReactions,\r\n IntentsBitField.Flags.GuildMessageTyping,\r\n IntentsBitField.Flags.DirectMessages,\r\n IntentsBitField.Flags.DirectMessageReactions,\r\n IntentsBitField.Flags.DirectMessageTyping,\r\n];\r\nconst Guild = [\r\n IntentsBitField.Flags.GuildEmojisAndStickers,\r\n IntentsBitField.Flags.GuildIntegrations,\r\n IntentsBitField.Flags.GuildInvites,\r\n IntentsBitField.Flags.GuildMembers,\r\n IntentsBitField.Flags.GuildMessageReactions,\r\n IntentsBitField.Flags.GuildMessageTyping,\r\n IntentsBitField.Flags.GuildMessages,\r\n IntentsBitField.Flags.GuildModeration,\r\n IntentsBitField.Flags.GuildPresences,\r\n IntentsBitField.Flags.GuildScheduledEvents,\r\n IntentsBitField.Flags.GuildVoiceStates,\r\n IntentsBitField.Flags.GuildWebhooks,\r\n IntentsBitField.Flags.Guilds,\r\n];\r\n\r\nconst Other = [\r\n IntentsBitField.Flags.AutoModerationConfiguration,\r\n IntentsBitField.Flags.AutoModerationExecution,\r\n];\r\n\r\n\r\nexport const CustomItents = {\r\n Messages,\r\n Guild,\r\n Other,\r\n All: Object.values(IntentsBitField.Flags) as GatewayIntentBits[]\r\n} as const;\r\n\r\nexport const CustomPartials = {\r\n All: [\r\n Partials.Channel,\r\n Partials.GuildMember,\r\n Partials.GuildScheduledEvent,\r\n Partials.Message,\r\n Partials.Reaction,\r\n Partials.ThreadMember,\r\n Partials.User,\r\n ]\r\n} as const","import type { CommandInteractionOption, Guild } from \"discord.js\";\r\nimport { ChannelType } from \"discord.js\";\r\n\r\ntype GetChannelType<Type extends ChannelType> = Extract<NonNullable<CommandInteractionOption<\"cached\">[\"channel\"]>, {\r\n type: Type extends ChannelType.PublicThread | ChannelType.AnnouncementThread\r\n ? ChannelType.PublicThread | ChannelType.AnnouncementThread\r\n : Type;\r\n}>\r\nexport function findChannel<Type extends Exclude<ChannelType, ChannelType.DM> = ChannelType.GuildText>(guild: Guild, type?: Type){\r\n const channelType = type || ChannelType.GuildText;\r\n return {\r\n byName(name: string): GetChannelType<Type> | undefined {\r\n return guild.channels.cache.find(channel => channel.name === name && channel.type === channelType) as GetChannelType<Type>;\r\n },\r\n byId(id: string): GetChannelType<Type> | undefined {\r\n return guild.channels.cache.find(channel => channel.id === id && channel.type === channelType) as GetChannelType<Type>;\r\n }\r\n }\r\n}","import { Attachment, AttachmentBuilder, ColorResolvable, EmbedAssetData, EmbedAuthorData, EmbedBuilder, EmbedFooterData, ImageURLOptions, User } from \"discord.js\";\r\n\r\ninterface CreateEmbedAuthorOptions {\r\n user: User,\r\n property?: \"username\" | \"displayName\" | \"id\" | \"globalName\"\r\n imageSize?: ImageURLOptions[\"size\"],\r\n iconURL?: string, url?: string, prefix?: string, suffix?: string,\r\n}\r\nexport function createEmbedAuthor(options: CreateEmbedAuthorOptions): EmbedAuthorData {\r\n const { user, property=\"displayName\", imageSize: size=512, \r\n iconURL, url, prefix=\"\", suffix=\"\"\r\n } = options;\r\n return {\r\n name: `${prefix}${user[property]}${suffix}`, url, \r\n iconURL: iconURL || user.displayAvatarURL({ size }) \r\n };\r\n}\r\ntype EmbedAssetOptions = Omit<EmbedAssetData, \"url\">\r\ntype AssetSource = string | null | Attachment | AttachmentBuilder;\r\n\r\nexport function createEmbedAsset(source?: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined {\r\n if (source instanceof Attachment || source instanceof AttachmentBuilder){\r\n return { url: `attachment://${source.name}`, ...options }\r\n }\r\n return source ? { url: source, ...options } : undefined;\r\n}\r\n\r\ntype EmbedColor = ColorResolvable | (string & {});\r\ntype BaseEmbedField = {\r\n name: string;\r\n value: string;\r\n inline?: boolean\r\n}\r\ntype BaseEmbedData = { \r\n title?: string;\r\n color?: EmbedColor;\r\n description?: string;\r\n url?: string;\r\n timestamp?: string | number | Date;\r\n footer?: EmbedFooterData;\r\n image?: EmbedAssetData;\r\n thumbnail?: EmbedAssetData;\r\n author?: EmbedAuthorData;\r\n fields?: BaseEmbedField[];\r\n}\r\ntype CreateEmbedOptions = BaseEmbedData & {\r\n extend?: BaseEmbedData;\r\n modify?: {\r\n fields?(fields: BaseEmbedField[]): BaseEmbedField[];\r\n }\r\n}\r\nexport function createEmbed(options: CreateEmbedOptions){\r\n const { extend: extendRaw = {}, ...embedRaw } = options;\r\n\r\n const { color: embedColor, modify, ...embedData } = embedRaw;\r\n const { color: extendColor, ...extendData } = extendRaw;\r\n\r\n const data = { ...extendData, ...embedData };\r\n const builder = new EmbedBuilder(data);\r\n \r\n if (extendColor) builder.setColor(extendColor as ColorResolvable);\r\n if (embedColor) builder.setColor(embedColor as ColorResolvable);\r\n\r\n if (modify?.fields && typeof modify.fields == \"function\"){\r\n const fields = modify.fields(builder.data.fields || []);\r\n builder.setFields(fields);\r\n }\r\n return builder;\r\n}","import type { Guild } from \"discord.js\";\r\n\r\nexport function findRole(guild: Guild){\r\n return {\r\n byName(name: string){\r\n return guild.roles.cache.find(role => role.name == name);\r\n },\r\n byId(id: string){\r\n return guild.roles.cache.get(id); \r\n }\r\n }\r\n}","import type { AnyComponentBuilder, LinkButtonComponentData, TextInputComponentData } from \"discord.js\";\r\nimport { ActionRowBuilder, ButtonBuilder, ButtonStyle, TextInputBuilder, } from \"discord.js\";\r\n\r\nexport function createRow<Component extends AnyComponentBuilder>(...components: Component[]){\r\n return new ActionRowBuilder<Component>({components});\r\n}\r\ntype CreateModalInputData = Omit<TextInputComponentData, \"type\">;\r\n\r\nexport function createModalInput(data: CreateModalInputData){\r\n return createRow(new TextInputBuilder(data));\r\n}\r\n\r\ntype CreateLinkButtonData = Omit<LinkButtonComponentData, \"style\" | \"type\">\r\n\r\nexport function createLinkButton(data: CreateLinkButtonData){\r\n if (!data.label) data.label = data.url;\r\n return new ButtonBuilder({style: ButtonStyle.Link, ...data});\r\n}"],"names":["Messages","IntentsBitField","Guild","Other","Partials","guild","type","channelType","ChannelType","name","channel","id","options","user","property","size","iconURL","url","prefix","suffix","source","Attachment","AttachmentBuilder","extendRaw","embedRaw","embedColor","modify","embedData","extendColor","extendData","data","builder","EmbedBuilder","fields","role","components","ActionRowBuilder","TextInputBuilder","ButtonBuilder","ButtonStyle"],"mappings":"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"}
@@ -0,0 +1,73 @@
1
+ import * as discord_js from 'discord.js';
2
+ import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, EmbedAuthorData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, EmbedFooterData, ColorResolvable, AnyComponentBuilder, ActionRowBuilder, TextInputBuilder, ButtonBuilder, TextInputComponentData, LinkButtonComponentData } from 'discord.js';
3
+ export * from '@magicyan/core';
4
+
5
+ declare const CustomItents: {
6
+ readonly Messages: GatewayIntentBits[];
7
+ readonly Guild: GatewayIntentBits[];
8
+ readonly Other: GatewayIntentBits[];
9
+ readonly All: GatewayIntentBits[];
10
+ };
11
+ declare const CustomPartials: {
12
+ readonly All: readonly [Partials.Channel, Partials.GuildMember, Partials.GuildScheduledEvent, Partials.Message, Partials.Reaction, Partials.ThreadMember, Partials.User];
13
+ };
14
+
15
+ type GetChannelType<Type extends ChannelType> = Extract<NonNullable<CommandInteractionOption<"cached">["channel"]>, {
16
+ type: Type extends ChannelType.PublicThread | ChannelType.AnnouncementThread ? ChannelType.PublicThread | ChannelType.AnnouncementThread : Type;
17
+ }>;
18
+ declare function findChannel<Type extends Exclude<ChannelType, ChannelType.DM> = ChannelType.GuildText>(guild: Guild, type?: Type): {
19
+ byName(name: string): GetChannelType<Type> | undefined;
20
+ byId(id: string): GetChannelType<Type> | undefined;
21
+ };
22
+
23
+ interface CreateEmbedAuthorOptions {
24
+ user: User;
25
+ property?: "username" | "displayName" | "id" | "globalName";
26
+ imageSize?: ImageURLOptions["size"];
27
+ iconURL?: string;
28
+ url?: string;
29
+ prefix?: string;
30
+ suffix?: string;
31
+ }
32
+ declare function createEmbedAuthor(options: CreateEmbedAuthorOptions): EmbedAuthorData;
33
+ type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
34
+ type AssetSource = string | null | Attachment | AttachmentBuilder;
35
+ declare function createEmbedAsset(source?: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined;
36
+ type EmbedColor = ColorResolvable | (string & {});
37
+ type BaseEmbedField = {
38
+ name: string;
39
+ value: string;
40
+ inline?: boolean;
41
+ };
42
+ type BaseEmbedData = {
43
+ title?: string;
44
+ color?: EmbedColor;
45
+ description?: string;
46
+ url?: string;
47
+ timestamp?: string | number | Date;
48
+ footer?: EmbedFooterData;
49
+ image?: EmbedAssetData;
50
+ thumbnail?: EmbedAssetData;
51
+ author?: EmbedAuthorData;
52
+ fields?: BaseEmbedField[];
53
+ };
54
+ type CreateEmbedOptions = BaseEmbedData & {
55
+ extend?: BaseEmbedData;
56
+ modify?: {
57
+ fields?(fields: BaseEmbedField[]): BaseEmbedField[];
58
+ };
59
+ };
60
+ declare function createEmbed(options: CreateEmbedOptions): EmbedBuilder;
61
+
62
+ declare function findRole(guild: Guild): {
63
+ byName(name: string): discord_js.Role | undefined;
64
+ byId(id: string): discord_js.Role | undefined;
65
+ };
66
+
67
+ declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
68
+ type CreateModalInputData = Omit<TextInputComponentData, "type">;
69
+ declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<TextInputBuilder>;
70
+ type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
71
+ declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
72
+
73
+ export { CustomItents, CustomPartials, createEmbed, createEmbedAsset, createEmbedAuthor, createLinkButton, createModalInput, createRow, findChannel, findRole };
@@ -0,0 +1,73 @@
1
+ import * as discord_js from 'discord.js';
2
+ import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, EmbedAuthorData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, EmbedFooterData, ColorResolvable, AnyComponentBuilder, ActionRowBuilder, TextInputBuilder, ButtonBuilder, TextInputComponentData, LinkButtonComponentData } from 'discord.js';
3
+ export * from '@magicyan/core';
4
+
5
+ declare const CustomItents: {
6
+ readonly Messages: GatewayIntentBits[];
7
+ readonly Guild: GatewayIntentBits[];
8
+ readonly Other: GatewayIntentBits[];
9
+ readonly All: GatewayIntentBits[];
10
+ };
11
+ declare const CustomPartials: {
12
+ readonly All: readonly [Partials.Channel, Partials.GuildMember, Partials.GuildScheduledEvent, Partials.Message, Partials.Reaction, Partials.ThreadMember, Partials.User];
13
+ };
14
+
15
+ type GetChannelType<Type extends ChannelType> = Extract<NonNullable<CommandInteractionOption<"cached">["channel"]>, {
16
+ type: Type extends ChannelType.PublicThread | ChannelType.AnnouncementThread ? ChannelType.PublicThread | ChannelType.AnnouncementThread : Type;
17
+ }>;
18
+ declare function findChannel<Type extends Exclude<ChannelType, ChannelType.DM> = ChannelType.GuildText>(guild: Guild, type?: Type): {
19
+ byName(name: string): GetChannelType<Type> | undefined;
20
+ byId(id: string): GetChannelType<Type> | undefined;
21
+ };
22
+
23
+ interface CreateEmbedAuthorOptions {
24
+ user: User;
25
+ property?: "username" | "displayName" | "id" | "globalName";
26
+ imageSize?: ImageURLOptions["size"];
27
+ iconURL?: string;
28
+ url?: string;
29
+ prefix?: string;
30
+ suffix?: string;
31
+ }
32
+ declare function createEmbedAuthor(options: CreateEmbedAuthorOptions): EmbedAuthorData;
33
+ type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
34
+ type AssetSource = string | null | Attachment | AttachmentBuilder;
35
+ declare function createEmbedAsset(source?: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined;
36
+ type EmbedColor = ColorResolvable | (string & {});
37
+ type BaseEmbedField = {
38
+ name: string;
39
+ value: string;
40
+ inline?: boolean;
41
+ };
42
+ type BaseEmbedData = {
43
+ title?: string;
44
+ color?: EmbedColor;
45
+ description?: string;
46
+ url?: string;
47
+ timestamp?: string | number | Date;
48
+ footer?: EmbedFooterData;
49
+ image?: EmbedAssetData;
50
+ thumbnail?: EmbedAssetData;
51
+ author?: EmbedAuthorData;
52
+ fields?: BaseEmbedField[];
53
+ };
54
+ type CreateEmbedOptions = BaseEmbedData & {
55
+ extend?: BaseEmbedData;
56
+ modify?: {
57
+ fields?(fields: BaseEmbedField[]): BaseEmbedField[];
58
+ };
59
+ };
60
+ declare function createEmbed(options: CreateEmbedOptions): EmbedBuilder;
61
+
62
+ declare function findRole(guild: Guild): {
63
+ byName(name: string): discord_js.Role | undefined;
64
+ byId(id: string): discord_js.Role | undefined;
65
+ };
66
+
67
+ declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
68
+ type CreateModalInputData = Omit<TextInputComponentData, "type">;
69
+ declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<TextInputBuilder>;
70
+ type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
71
+ declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
72
+
73
+ export { CustomItents, CustomPartials, createEmbed, createEmbedAsset, createEmbedAuthor, createLinkButton, createModalInput, createRow, findChannel, findRole };
@@ -0,0 +1,73 @@
1
+ import * as discord_js from 'discord.js';
2
+ import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, EmbedAuthorData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, EmbedFooterData, ColorResolvable, AnyComponentBuilder, ActionRowBuilder, TextInputBuilder, ButtonBuilder, TextInputComponentData, LinkButtonComponentData } from 'discord.js';
3
+ export * from '@magicyan/core';
4
+
5
+ declare const CustomItents: {
6
+ readonly Messages: GatewayIntentBits[];
7
+ readonly Guild: GatewayIntentBits[];
8
+ readonly Other: GatewayIntentBits[];
9
+ readonly All: GatewayIntentBits[];
10
+ };
11
+ declare const CustomPartials: {
12
+ readonly All: readonly [Partials.Channel, Partials.GuildMember, Partials.GuildScheduledEvent, Partials.Message, Partials.Reaction, Partials.ThreadMember, Partials.User];
13
+ };
14
+
15
+ type GetChannelType<Type extends ChannelType> = Extract<NonNullable<CommandInteractionOption<"cached">["channel"]>, {
16
+ type: Type extends ChannelType.PublicThread | ChannelType.AnnouncementThread ? ChannelType.PublicThread | ChannelType.AnnouncementThread : Type;
17
+ }>;
18
+ declare function findChannel<Type extends Exclude<ChannelType, ChannelType.DM> = ChannelType.GuildText>(guild: Guild, type?: Type): {
19
+ byName(name: string): GetChannelType<Type> | undefined;
20
+ byId(id: string): GetChannelType<Type> | undefined;
21
+ };
22
+
23
+ interface CreateEmbedAuthorOptions {
24
+ user: User;
25
+ property?: "username" | "displayName" | "id" | "globalName";
26
+ imageSize?: ImageURLOptions["size"];
27
+ iconURL?: string;
28
+ url?: string;
29
+ prefix?: string;
30
+ suffix?: string;
31
+ }
32
+ declare function createEmbedAuthor(options: CreateEmbedAuthorOptions): EmbedAuthorData;
33
+ type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
34
+ type AssetSource = string | null | Attachment | AttachmentBuilder;
35
+ declare function createEmbedAsset(source?: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined;
36
+ type EmbedColor = ColorResolvable | (string & {});
37
+ type BaseEmbedField = {
38
+ name: string;
39
+ value: string;
40
+ inline?: boolean;
41
+ };
42
+ type BaseEmbedData = {
43
+ title?: string;
44
+ color?: EmbedColor;
45
+ description?: string;
46
+ url?: string;
47
+ timestamp?: string | number | Date;
48
+ footer?: EmbedFooterData;
49
+ image?: EmbedAssetData;
50
+ thumbnail?: EmbedAssetData;
51
+ author?: EmbedAuthorData;
52
+ fields?: BaseEmbedField[];
53
+ };
54
+ type CreateEmbedOptions = BaseEmbedData & {
55
+ extend?: BaseEmbedData;
56
+ modify?: {
57
+ fields?(fields: BaseEmbedField[]): BaseEmbedField[];
58
+ };
59
+ };
60
+ declare function createEmbed(options: CreateEmbedOptions): EmbedBuilder;
61
+
62
+ declare function findRole(guild: Guild): {
63
+ byName(name: string): discord_js.Role | undefined;
64
+ byId(id: string): discord_js.Role | undefined;
65
+ };
66
+
67
+ declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
68
+ type CreateModalInputData = Omit<TextInputComponentData, "type">;
69
+ declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<TextInputBuilder>;
70
+ type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
71
+ declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
72
+
73
+ export { CustomItents, CustomPartials, createEmbed, createEmbedAsset, createEmbedAuthor, createLinkButton, createModalInput, createRow, findChannel, findRole };
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import{IntentsBitField as t,Partials as i,ChannelType as m,Attachment as F,AttachmentBuilder as G,EmbedBuilder as M,ActionRowBuilder as h,TextInputBuilder as p,ButtonBuilder as y,ButtonStyle as b}from"discord.js";export*from"@magicyan/core";const A=[t.Flags.MessageContent,t.Flags.GuildMessages,t.Flags.GuildMessageReactions,t.Flags.GuildMessageTyping,t.Flags.DirectMessages,t.Flags.DirectMessageReactions,t.Flags.DirectMessageTyping],R=[t.Flags.GuildEmojisAndStickers,t.Flags.GuildIntegrations,t.Flags.GuildInvites,t.Flags.GuildMembers,t.Flags.GuildMessageReactions,t.Flags.GuildMessageTyping,t.Flags.GuildMessages,t.Flags.GuildModeration,t.Flags.GuildPresences,t.Flags.GuildScheduledEvents,t.Flags.GuildVoiceStates,t.Flags.GuildWebhooks,t.Flags.Guilds],B=[t.Flags.AutoModerationConfiguration,t.Flags.AutoModerationExecution],C={Messages:A,Guild:R,Other:B,All:Object.values(t.Flags)},x={All:[i.Channel,i.GuildMember,i.GuildScheduledEvent,i.Message,i.Reaction,i.ThreadMember,i.User]};function E(e,n){const a=n||m.GuildText;return{byName(l){return e.channels.cache.find(s=>s.name===l&&s.type===a)},byId(l){return e.channels.cache.find(s=>s.id===l&&s.type===a)}}}function I(e){const{user:n,property:a="displayName",imageSize:l=512,iconURL:s,url:u,prefix:o="",suffix:d=""}=e;return{name:`${o}${n[a]}${d}`,url:u,iconURL:s||n.displayAvatarURL({size:l})}}function T(e,n){return e instanceof F||e instanceof G?{url:`attachment://${e.name}`,...n}:e?{url:e,...n}:void 0}function v(e){const{extend:n={},...a}=e,{color:l,modify:s,...u}=a,{color:o,...d}=n,g={...d,...u},r=new M(g);if(o&&r.setColor(o),l&&r.setColor(l),s?.fields&&typeof s.fields=="function"){const f=s.fields(r.data.fields||[]);r.setFields(f)}return r}function w(e){return{byName(n){return e.roles.cache.find(a=>a.name==n)},byId(n){return e.roles.cache.get(n)}}}function c(...e){return new h({components:e})}function S(e){return c(new p(e))}function L(e){return e.label||(e.label=e.url),new y({style:b.Link,...e})}export{C as CustomItents,x as CustomPartials,v as createEmbed,T as createEmbedAsset,I as createEmbedAuthor,L as createLinkButton,S as createModalInput,c as createRow,E as findChannel,w as findRole};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/constants/client.ts","../src/functions/channels.ts","../src/functions/embeds.ts","../src/functions/roles.ts","../src/functions/utils.ts"],"sourcesContent":["import { GatewayIntentBits, IntentsBitField, Partials } from \"discord.js\";\r\n\r\nconst Messages = [\r\n IntentsBitField.Flags.MessageContent,\r\n IntentsBitField.Flags.GuildMessages,\r\n IntentsBitField.Flags.GuildMessageReactions,\r\n IntentsBitField.Flags.GuildMessageTyping,\r\n IntentsBitField.Flags.DirectMessages,\r\n IntentsBitField.Flags.DirectMessageReactions,\r\n IntentsBitField.Flags.DirectMessageTyping,\r\n];\r\nconst Guild = [\r\n IntentsBitField.Flags.GuildEmojisAndStickers,\r\n IntentsBitField.Flags.GuildIntegrations,\r\n IntentsBitField.Flags.GuildInvites,\r\n IntentsBitField.Flags.GuildMembers,\r\n IntentsBitField.Flags.GuildMessageReactions,\r\n IntentsBitField.Flags.GuildMessageTyping,\r\n IntentsBitField.Flags.GuildMessages,\r\n IntentsBitField.Flags.GuildModeration,\r\n IntentsBitField.Flags.GuildPresences,\r\n IntentsBitField.Flags.GuildScheduledEvents,\r\n IntentsBitField.Flags.GuildVoiceStates,\r\n IntentsBitField.Flags.GuildWebhooks,\r\n IntentsBitField.Flags.Guilds,\r\n];\r\n\r\nconst Other = [\r\n IntentsBitField.Flags.AutoModerationConfiguration,\r\n IntentsBitField.Flags.AutoModerationExecution,\r\n];\r\n\r\n\r\nexport const CustomItents = {\r\n Messages,\r\n Guild,\r\n Other,\r\n All: Object.values(IntentsBitField.Flags) as GatewayIntentBits[]\r\n} as const;\r\n\r\nexport const CustomPartials = {\r\n All: [\r\n Partials.Channel,\r\n Partials.GuildMember,\r\n Partials.GuildScheduledEvent,\r\n Partials.Message,\r\n Partials.Reaction,\r\n Partials.ThreadMember,\r\n Partials.User,\r\n ]\r\n} as const","import type { CommandInteractionOption, Guild } from \"discord.js\";\r\nimport { ChannelType } from \"discord.js\";\r\n\r\ntype GetChannelType<Type extends ChannelType> = Extract<NonNullable<CommandInteractionOption<\"cached\">[\"channel\"]>, {\r\n type: Type extends ChannelType.PublicThread | ChannelType.AnnouncementThread\r\n ? ChannelType.PublicThread | ChannelType.AnnouncementThread\r\n : Type;\r\n}>\r\nexport function findChannel<Type extends Exclude<ChannelType, ChannelType.DM> = ChannelType.GuildText>(guild: Guild, type?: Type){\r\n const channelType = type || ChannelType.GuildText;\r\n return {\r\n byName(name: string): GetChannelType<Type> | undefined {\r\n return guild.channels.cache.find(channel => channel.name === name && channel.type === channelType) as GetChannelType<Type>;\r\n },\r\n byId(id: string): GetChannelType<Type> | undefined {\r\n return guild.channels.cache.find(channel => channel.id === id && channel.type === channelType) as GetChannelType<Type>;\r\n }\r\n }\r\n}","import { Attachment, AttachmentBuilder, ColorResolvable, EmbedAssetData, EmbedAuthorData, EmbedBuilder, EmbedFooterData, ImageURLOptions, User } from \"discord.js\";\r\n\r\ninterface CreateEmbedAuthorOptions {\r\n user: User,\r\n property?: \"username\" | \"displayName\" | \"id\" | \"globalName\"\r\n imageSize?: ImageURLOptions[\"size\"],\r\n iconURL?: string, url?: string, prefix?: string, suffix?: string,\r\n}\r\nexport function createEmbedAuthor(options: CreateEmbedAuthorOptions): EmbedAuthorData {\r\n const { user, property=\"displayName\", imageSize: size=512, \r\n iconURL, url, prefix=\"\", suffix=\"\"\r\n } = options;\r\n return {\r\n name: `${prefix}${user[property]}${suffix}`, url, \r\n iconURL: iconURL || user.displayAvatarURL({ size }) \r\n };\r\n}\r\ntype EmbedAssetOptions = Omit<EmbedAssetData, \"url\">\r\ntype AssetSource = string | null | Attachment | AttachmentBuilder;\r\n\r\nexport function createEmbedAsset(source?: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined {\r\n if (source instanceof Attachment || source instanceof AttachmentBuilder){\r\n return { url: `attachment://${source.name}`, ...options }\r\n }\r\n return source ? { url: source, ...options } : undefined;\r\n}\r\n\r\ntype EmbedColor = ColorResolvable | (string & {});\r\ntype BaseEmbedField = {\r\n name: string;\r\n value: string;\r\n inline?: boolean\r\n}\r\ntype BaseEmbedData = { \r\n title?: string;\r\n color?: EmbedColor;\r\n description?: string;\r\n url?: string;\r\n timestamp?: string | number | Date;\r\n footer?: EmbedFooterData;\r\n image?: EmbedAssetData;\r\n thumbnail?: EmbedAssetData;\r\n author?: EmbedAuthorData;\r\n fields?: BaseEmbedField[];\r\n}\r\ntype CreateEmbedOptions = BaseEmbedData & {\r\n extend?: BaseEmbedData;\r\n modify?: {\r\n fields?(fields: BaseEmbedField[]): BaseEmbedField[];\r\n }\r\n}\r\nexport function createEmbed(options: CreateEmbedOptions){\r\n const { extend: extendRaw = {}, ...embedRaw } = options;\r\n\r\n const { color: embedColor, modify, ...embedData } = embedRaw;\r\n const { color: extendColor, ...extendData } = extendRaw;\r\n\r\n const data = { ...extendData, ...embedData };\r\n const builder = new EmbedBuilder(data);\r\n \r\n if (extendColor) builder.setColor(extendColor as ColorResolvable);\r\n if (embedColor) builder.setColor(embedColor as ColorResolvable);\r\n\r\n if (modify?.fields && typeof modify.fields == \"function\"){\r\n const fields = modify.fields(builder.data.fields || []);\r\n builder.setFields(fields);\r\n }\r\n return builder;\r\n}","import type { Guild } from \"discord.js\";\r\n\r\nexport function findRole(guild: Guild){\r\n return {\r\n byName(name: string){\r\n return guild.roles.cache.find(role => role.name == name);\r\n },\r\n byId(id: string){\r\n return guild.roles.cache.get(id); \r\n }\r\n }\r\n}","import type { AnyComponentBuilder, LinkButtonComponentData, TextInputComponentData } from \"discord.js\";\r\nimport { ActionRowBuilder, ButtonBuilder, ButtonStyle, TextInputBuilder, } from \"discord.js\";\r\n\r\nexport function createRow<Component extends AnyComponentBuilder>(...components: Component[]){\r\n return new ActionRowBuilder<Component>({components});\r\n}\r\ntype CreateModalInputData = Omit<TextInputComponentData, \"type\">;\r\n\r\nexport function createModalInput(data: CreateModalInputData){\r\n return createRow(new TextInputBuilder(data));\r\n}\r\n\r\ntype CreateLinkButtonData = Omit<LinkButtonComponentData, \"style\" | \"type\">\r\n\r\nexport function createLinkButton(data: CreateLinkButtonData){\r\n if (!data.label) data.label = data.url;\r\n return new ButtonBuilder({style: ButtonStyle.Link, ...data});\r\n}"],"names":["Messages","IntentsBitField","Guild","Other","CustomItents","CustomPartials","Partials","findChannel","guild","type","channelType","ChannelType","name","channel","id","createEmbedAuthor","options","user","property","size","iconURL","url","prefix","suffix","createEmbedAsset","source","Attachment","AttachmentBuilder","createEmbed","extendRaw","embedRaw","embedColor","modify","embedData","extendColor","extendData","data","builder","EmbedBuilder","fields","findRole","role","createRow","components","ActionRowBuilder","createModalInput","TextInputBuilder","createLinkButton","ButtonBuilder","ButtonStyle"],"mappings":"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"}
package/package.json CHANGED
@@ -1,36 +1,47 @@
1
- {
2
- "name": "@magicyan/discord",
3
- "version": "1.0.11",
4
- "publishConfig": {
5
- "access": "public"
6
- },
7
- "main": "dist/index.js",
8
- "scripts": {
9
- "dev": "ts-node src/index.ts",
10
- "build": "tsc"
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/rinckodev/magicyan",
15
- "directory": "packages/discord"
16
- },
17
- "types": "./types/index.d.ts",
18
- "keywords": [],
19
- "author": "Rincko Dev (https://github.com/rinckodev)",
20
- "license": "ISC",
21
- "devDependencies": {
22
- "ts-node": "^10.9.1",
23
- "typescript": "^5.2.2"
24
- },
25
- "bugs": {
26
- "url": "https://github.com/rinckodev/magicyan/issues"
27
- },
28
- "homepage": "https://github.com/rinckodev/magicyan/tree/main/packages/discord#readme",
29
- "description": "Simple functions to facilitate discord bot development",
30
- "dependencies": {
31
- "@magicyan/core": "^1.0.9"
32
- },
33
- "peerDependencies": {
34
- "discord.js": "^14.14.1"
35
- }
36
- }
1
+ {
2
+ "name": "@magicyan/discord",
3
+ "version": "1.0.13",
4
+ "description": "Simple functions to facilitate discord bot development",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/rinckodev/magicyan",
13
+ "directory": "packages/core"
14
+ },
15
+ "author": "Rincko Dev (https://github.com/rinckodev)",
16
+ "bugs": {
17
+ "url": "https://github.com/rinckodev/magicyan/issues"
18
+ },
19
+ "homepage": "https://github.com/rinckodev/magicyan/tree/main/packages/discord#readme",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.mjs",
24
+ "require": "./dist/index.cjs"
25
+ }
26
+ },
27
+ "main": "./dist/index.cjs",
28
+ "module": "./dist/index.mjs",
29
+ "types": "./dist/index.d.ts",
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "scripts": {
34
+ "build": "unbuild",
35
+ "dev": "tsx playground/index.ts"
36
+ },
37
+ "devDependencies": {
38
+ "tsx": "^4.7.0",
39
+ "unbuild": "^2.0.0"
40
+ },
41
+ "dependencies": {
42
+ "@magicyan/core": "^1.0.13"
43
+ },
44
+ "peerDependencies": {
45
+ "discord.js": "^14.14.1"
46
+ }
47
+ }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomItents = void 0;
4
- const discord_js_1 = require("discord.js");
5
- const Messages = [
6
- discord_js_1.IntentsBitField.Flags.MessageContent,
7
- discord_js_1.IntentsBitField.Flags.GuildMessages,
8
- discord_js_1.IntentsBitField.Flags.GuildMessageReactions,
9
- discord_js_1.IntentsBitField.Flags.GuildMessageTyping,
10
- discord_js_1.IntentsBitField.Flags.DirectMessages,
11
- discord_js_1.IntentsBitField.Flags.DirectMessageReactions,
12
- discord_js_1.IntentsBitField.Flags.DirectMessageTyping,
13
- ];
14
- const Guild = [
15
- discord_js_1.IntentsBitField.Flags.GuildEmojisAndStickers,
16
- discord_js_1.IntentsBitField.Flags.GuildIntegrations,
17
- discord_js_1.IntentsBitField.Flags.GuildInvites,
18
- discord_js_1.IntentsBitField.Flags.GuildMembers,
19
- discord_js_1.IntentsBitField.Flags.GuildMessageReactions,
20
- discord_js_1.IntentsBitField.Flags.GuildMessageTyping,
21
- discord_js_1.IntentsBitField.Flags.GuildMessages,
22
- discord_js_1.IntentsBitField.Flags.GuildModeration,
23
- discord_js_1.IntentsBitField.Flags.GuildPresences,
24
- discord_js_1.IntentsBitField.Flags.GuildScheduledEvents,
25
- discord_js_1.IntentsBitField.Flags.GuildVoiceStates,
26
- discord_js_1.IntentsBitField.Flags.GuildWebhooks,
27
- discord_js_1.IntentsBitField.Flags.Guilds,
28
- ];
29
- const Other = [
30
- discord_js_1.IntentsBitField.Flags.AutoModerationConfiguration,
31
- discord_js_1.IntentsBitField.Flags.AutoModerationExecution,
32
- ];
33
- exports.CustomItents = {
34
- Messages,
35
- Guild,
36
- Other,
37
- All: [
38
- ...Messages,
39
- ...Guild,
40
- ...Other,
41
- ],
42
- };
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findChannel = void 0;
4
- const discord_js_1 = require("discord.js");
5
- function findChannel(guild, type) {
6
- const channelType = type || discord_js_1.ChannelType.GuildText;
7
- return {
8
- byName(name) {
9
- return guild.channels.cache.find(channel => channel.name === name && channel.type === channelType);
10
- },
11
- byId(id) {
12
- return guild.channels.cache.find(channel => channel.id === id && channel.type === channelType);
13
- }
14
- };
15
- }
16
- exports.findChannel = findChannel;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createEmbed = exports.createEmbedAsset = exports.createEmbedAuthor = void 0;
4
- const discord_js_1 = require("discord.js");
5
- function createEmbedAuthor(options) {
6
- const { user, property = "displayName", imageSize: size = 512, iconURL, url, prefix = "", suffix = "" } = options;
7
- return {
8
- name: `${prefix}${user[property]}${suffix}`, url,
9
- iconURL: iconURL || user.displayAvatarURL({ size })
10
- };
11
- }
12
- exports.createEmbedAuthor = createEmbedAuthor;
13
- function createEmbedAsset(source, options) {
14
- if (source instanceof discord_js_1.Attachment || source instanceof discord_js_1.AttachmentBuilder) {
15
- return { url: `attachment://${source.name}`, ...options };
16
- }
17
- return source ? { url: source, ...options } : undefined;
18
- }
19
- exports.createEmbedAsset = createEmbedAsset;
20
- function createEmbed(options) {
21
- const { extend: extendRaw = {}, ...embedRaw } = options;
22
- const { color: embedColor, modify, ...embedData } = embedRaw;
23
- const { color: extendColor, ...extendData } = extendRaw;
24
- const data = { ...extendData, ...embedData };
25
- const builder = new discord_js_1.EmbedBuilder(data);
26
- if (extendColor)
27
- builder.setColor(extendColor);
28
- if (embedColor)
29
- builder.setColor(embedColor);
30
- if (modify?.fields && typeof modify.fields == "function") {
31
- const fields = modify.fields(builder.data.fields || []);
32
- builder.setFields(fields);
33
- }
34
- return builder;
35
- }
36
- exports.createEmbed = createEmbed;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findRole = void 0;
4
- function findRole(guild) {
5
- return {
6
- byName(name) {
7
- return guild.roles.cache.find(role => role.name == name);
8
- },
9
- byId(id) {
10
- return guild.roles.cache.get(id);
11
- }
12
- };
13
- }
14
- exports.findRole = findRole;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createLinkButton = exports.createModalInput = exports.createRow = void 0;
4
- const discord_js_1 = require("discord.js");
5
- function createRow(...components) {
6
- return new discord_js_1.ActionRowBuilder({ components });
7
- }
8
- exports.createRow = createRow;
9
- function createModalInput(data) {
10
- return createRow(new discord_js_1.TextInputBuilder(data));
11
- }
12
- exports.createModalInput = createModalInput;
13
- function createLinkButton(data) {
14
- if (!data.label)
15
- data.label = data.url;
16
- return new discord_js_1.ButtonBuilder({ style: discord_js_1.ButtonStyle.Link, ...data });
17
- }
18
- exports.createLinkButton = createLinkButton;
package/dist/index.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./constants/client"), exports);
18
- __exportStar(require("./functions/channels"), exports);
19
- __exportStar(require("./functions/embeds"), exports);
20
- __exportStar(require("./functions/roles"), exports);
21
- __exportStar(require("./functions/utils"), exports);
22
- __exportStar(require("@magicyan/core"), exports);
@@ -1,6 +0,0 @@
1
- export declare const CustomItents: {
2
- Messages: import("discord.js").GatewayIntentBits[];
3
- Guild: import("discord.js").GatewayIntentBits[];
4
- Other: import("discord.js").GatewayIntentBits[];
5
- All: import("discord.js").GatewayIntentBits[];
6
- };
@@ -1,10 +0,0 @@
1
- import type { CommandInteractionOption, Guild } from "discord.js";
2
- import { ChannelType } from "discord.js";
3
- type GetChannelType<Type extends ChannelType> = Extract<NonNullable<CommandInteractionOption<"cached">["channel"]>, {
4
- type: Type extends ChannelType.PublicThread | ChannelType.AnnouncementThread ? ChannelType.PublicThread | ChannelType.AnnouncementThread : Type;
5
- }>;
6
- export declare function findChannel<Type extends Exclude<ChannelType, ChannelType.DM> = ChannelType.GuildText>(guild: Guild, type?: Type): {
7
- byName(name: string): GetChannelType<Type> | undefined;
8
- byId(id: string): GetChannelType<Type> | undefined;
9
- };
10
- export {};
@@ -1,40 +0,0 @@
1
- import { EmbedAuthorData, EmbedBuilder, ImageURLOptions, User, EmbedAssetData, Attachment, AttachmentBuilder, ColorResolvable, EmbedFooterData } from "discord.js";
2
- interface CreateEmbedAuthorOptions {
3
- user: User;
4
- property?: "username" | "displayName" | "id" | "globalName";
5
- imageSize?: ImageURLOptions["size"];
6
- iconURL?: string;
7
- url?: string;
8
- prefix?: string;
9
- suffix?: string;
10
- }
11
- export declare function createEmbedAuthor(options: CreateEmbedAuthorOptions): EmbedAuthorData;
12
- type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
13
- type AssetSource = string | null | Attachment | AttachmentBuilder;
14
- export declare function createEmbedAsset(source?: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined;
15
- type EmbedColor = ColorResolvable | (string & {});
16
- type BaseEmbedField = {
17
- name: string;
18
- value: string;
19
- inline?: boolean;
20
- };
21
- type BaseEmbedData = {
22
- title?: string;
23
- color?: EmbedColor;
24
- description?: string;
25
- url?: string;
26
- timestamp?: string | number | Date;
27
- footer?: EmbedFooterData;
28
- image?: EmbedAssetData;
29
- thumbnail?: EmbedAssetData;
30
- author?: EmbedAuthorData;
31
- fields?: BaseEmbedField[];
32
- };
33
- type CreateEmbedOptions = BaseEmbedData & {
34
- extend?: BaseEmbedData;
35
- modify?: {
36
- fields?(fields: BaseEmbedField[]): BaseEmbedField[];
37
- };
38
- };
39
- export declare function createEmbed(options: CreateEmbedOptions): EmbedBuilder;
40
- export {};
@@ -1,5 +0,0 @@
1
- import type { Guild } from "discord.js";
2
- export declare function findRole(guild: Guild): {
3
- byName(name: string): import("discord.js").Role | undefined;
4
- byId(id: string): import("discord.js").Role | undefined;
5
- };
@@ -1,7 +0,0 @@
1
- import type { AnyComponentBuilder, LinkButtonComponentData, TextInputComponentData } from "discord.js";
2
- import { ActionRowBuilder, ButtonBuilder, TextInputBuilder } from "discord.js";
3
- export declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
4
- export declare function createModalInput(data: Omit<TextInputComponentData, "type">): ActionRowBuilder<TextInputBuilder>;
5
- type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
6
- export declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
7
- export {};
package/types/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from "./constants/client";
2
- export * from "./functions/channels";
3
- export * from "./functions/embeds";
4
- export * from "./functions/roles";
5
- export * from "./functions/utils";
6
- export * from "@magicyan/core";