@magicyan/discord 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/functions/components.cjs +14 -0
- package/dist/functions/components.mjs +13 -2
- package/dist/functions/embeds.cjs +2 -2
- package/dist/functions/embeds.mjs +2 -2
- package/dist/functions/format.cjs +4 -11
- package/dist/functions/format.mjs +5 -12
- package/dist/functions/message.cjs +27 -0
- package/dist/functions/message.mjs +25 -0
- package/dist/index.cjs +6 -5
- package/dist/index.d.cts +27 -24
- package/dist/index.d.mts +27 -24
- package/dist/index.d.ts +27 -24
- package/dist/index.mjs +3 -3
- package/package.json +2 -2
- package/dist/functions/utils.cjs +0 -19
- package/dist/functions/utils.mjs +0 -15
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
const discord_js = require('discord.js');
|
|
4
4
|
|
|
5
|
+
function createRow(...components) {
|
|
6
|
+
return new discord_js.ActionRowBuilder({ components });
|
|
7
|
+
}
|
|
8
|
+
function createModalInput(data) {
|
|
9
|
+
return createRow(new discord_js.TextInputBuilder(data));
|
|
10
|
+
}
|
|
11
|
+
function createLinkButton(data) {
|
|
12
|
+
if (!data.label)
|
|
13
|
+
data.label = data.url;
|
|
14
|
+
return new discord_js.ButtonBuilder({ style: discord_js.ButtonStyle.Link, ...data });
|
|
15
|
+
}
|
|
5
16
|
function createComponentsManager(components) {
|
|
6
17
|
const buttons = components.flatMap(
|
|
7
18
|
(row) => row.components.filter((c) => c.type === discord_js.ComponentType.Button)
|
|
@@ -52,3 +63,6 @@ function createComponentsManager(components) {
|
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
exports.createComponentsManager = createComponentsManager;
|
|
66
|
+
exports.createLinkButton = createLinkButton;
|
|
67
|
+
exports.createModalInput = createModalInput;
|
|
68
|
+
exports.createRow = createRow;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import { ComponentType } from 'discord.js';
|
|
1
|
+
import { ActionRowBuilder, TextInputBuilder, ButtonBuilder, ButtonStyle, ComponentType } from 'discord.js';
|
|
2
2
|
|
|
3
|
+
function createRow(...components) {
|
|
4
|
+
return new ActionRowBuilder({ components });
|
|
5
|
+
}
|
|
6
|
+
function createModalInput(data) {
|
|
7
|
+
return createRow(new TextInputBuilder(data));
|
|
8
|
+
}
|
|
9
|
+
function createLinkButton(data) {
|
|
10
|
+
if (!data.label)
|
|
11
|
+
data.label = data.url;
|
|
12
|
+
return new ButtonBuilder({ style: ButtonStyle.Link, ...data });
|
|
13
|
+
}
|
|
3
14
|
function createComponentsManager(components) {
|
|
4
15
|
const buttons = components.flatMap(
|
|
5
16
|
(row) => row.components.filter((c) => c.type === ComponentType.Button)
|
|
@@ -49,4 +60,4 @@ function createComponentsManager(components) {
|
|
|
49
60
|
};
|
|
50
61
|
}
|
|
51
62
|
|
|
52
|
-
export { createComponentsManager };
|
|
63
|
+
export { createComponentsManager, createLinkButton, createModalInput, createRow };
|
|
@@ -21,7 +21,7 @@ function createEmbedAuthor(options) {
|
|
|
21
21
|
}
|
|
22
22
|
function createEmbedFooter(options) {
|
|
23
23
|
const { text, iconURL } = options;
|
|
24
|
-
return { text: text ?? "\u200B", iconURL: core.notFound(iconURL) };
|
|
24
|
+
return !text && !iconURL ? void 0 : { text: text ?? "\u200B", iconURL: core.notFound(iconURL) };
|
|
25
25
|
}
|
|
26
26
|
function createEmbedAsset(source, options) {
|
|
27
27
|
if (source instanceof discord_js.Attachment || source instanceof discord_js.AttachmentBuilder) {
|
|
@@ -39,7 +39,7 @@ function createEmbed(options) {
|
|
|
39
39
|
builder.setColor(extendColor);
|
|
40
40
|
if (embedColor)
|
|
41
41
|
builder.setColor(embedColor);
|
|
42
|
-
if (modify?.fields && typeof modify.fields
|
|
42
|
+
if (modify?.fields && typeof modify.fields === "function") {
|
|
43
43
|
const fields = modify.fields(builder.data.fields || []);
|
|
44
44
|
builder.setFields(fields);
|
|
45
45
|
}
|
|
@@ -19,7 +19,7 @@ function createEmbedAuthor(options) {
|
|
|
19
19
|
}
|
|
20
20
|
function createEmbedFooter(options) {
|
|
21
21
|
const { text, iconURL } = options;
|
|
22
|
-
return { text: text ?? "\u200B", iconURL: notFound(iconURL) };
|
|
22
|
+
return !text && !iconURL ? void 0 : { text: text ?? "\u200B", iconURL: notFound(iconURL) };
|
|
23
23
|
}
|
|
24
24
|
function createEmbedAsset(source, options) {
|
|
25
25
|
if (source instanceof Attachment || source instanceof AttachmentBuilder) {
|
|
@@ -37,7 +37,7 @@ function createEmbed(options) {
|
|
|
37
37
|
builder.setColor(extendColor);
|
|
38
38
|
if (embedColor)
|
|
39
39
|
builder.setColor(embedColor);
|
|
40
|
-
if (modify?.fields && typeof modify.fields
|
|
40
|
+
if (modify?.fields && typeof modify.fields === "function") {
|
|
41
41
|
const fields = modify.fields(builder.data.fields || []);
|
|
42
42
|
builder.setFields(fields);
|
|
43
43
|
}
|
|
@@ -2,15 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const discord_js = require('discord.js');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return {
|
|
9
|
-
channel: id ? discord_js.channelMention(id) : alt,
|
|
10
|
-
user: id ? discord_js.userMention(id) : alt,
|
|
11
|
-
role: id ? discord_js.roleMention(id) : alt
|
|
12
|
-
}[type];
|
|
13
|
-
}
|
|
14
|
-
};
|
|
5
|
+
function formatedMention(ref, alt = "") {
|
|
6
|
+
return ref instanceof discord_js.Role ? discord_js.roleMention(ref.id) : ref instanceof discord_js.User ? discord_js.userMention(ref.id) : ref ? discord_js.channelMention(ref.id) : alt;
|
|
7
|
+
}
|
|
15
8
|
|
|
16
|
-
exports.
|
|
9
|
+
exports.formatedMention = formatedMention;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Role, roleMention, User, userMention, channelMention } from 'discord.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
channel: id ? channelMention(id) : alt,
|
|
8
|
-
user: id ? userMention(id) : alt,
|
|
9
|
-
role: id ? roleMention(id) : alt
|
|
10
|
-
}[type];
|
|
11
|
-
}
|
|
12
|
-
};
|
|
3
|
+
function formatedMention(ref, alt = "") {
|
|
4
|
+
return ref instanceof Role ? roleMention(ref.id) : ref instanceof User ? userMention(ref.id) : ref ? channelMention(ref.id) : alt;
|
|
5
|
+
}
|
|
13
6
|
|
|
14
|
-
export {
|
|
7
|
+
export { formatedMention };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const core = require('@magicyan/core');
|
|
4
|
+
|
|
5
|
+
function findMessage(channel) {
|
|
6
|
+
const messages = channel.messages.cache;
|
|
7
|
+
return {
|
|
8
|
+
byId(id) {
|
|
9
|
+
return messages.get(id);
|
|
10
|
+
},
|
|
11
|
+
byContent() {
|
|
12
|
+
return {
|
|
13
|
+
equals(content, ignoreCase = false) {
|
|
14
|
+
return ignoreCase ? messages.find((m) => m.content === content) : messages.find((m) => core.equalsIgnoreCase(m.content, content));
|
|
15
|
+
},
|
|
16
|
+
include(content, ignoreCase = false) {
|
|
17
|
+
return ignoreCase ? messages.find((m) => m.content.includes(content)) : messages.find((m) => core.includesIgnoreCase(m.content, content));
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
byFilter(filter) {
|
|
22
|
+
return messages.find(filter);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.findMessage = findMessage;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { equalsIgnoreCase, includesIgnoreCase } from '@magicyan/core';
|
|
2
|
+
|
|
3
|
+
function findMessage(channel) {
|
|
4
|
+
const messages = channel.messages.cache;
|
|
5
|
+
return {
|
|
6
|
+
byId(id) {
|
|
7
|
+
return messages.get(id);
|
|
8
|
+
},
|
|
9
|
+
byContent() {
|
|
10
|
+
return {
|
|
11
|
+
equals(content, ignoreCase = false) {
|
|
12
|
+
return ignoreCase ? messages.find((m) => m.content === content) : messages.find((m) => equalsIgnoreCase(m.content, content));
|
|
13
|
+
},
|
|
14
|
+
include(content, ignoreCase = false) {
|
|
15
|
+
return ignoreCase ? messages.find((m) => m.content.includes(content)) : messages.find((m) => includesIgnoreCase(m.content, content));
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
byFilter(filter) {
|
|
20
|
+
return messages.find(filter);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { findMessage };
|
package/dist/index.cjs
CHANGED
|
@@ -8,8 +8,8 @@ const embeds = require('./functions/embeds.cjs');
|
|
|
8
8
|
const emojis = require('./functions/emojis.cjs');
|
|
9
9
|
const format = require('./functions/format.cjs');
|
|
10
10
|
const members = require('./functions/members.cjs');
|
|
11
|
+
const message = require('./functions/message.cjs');
|
|
11
12
|
const roles = require('./functions/roles.cjs');
|
|
12
|
-
const utils = require('./functions/utils.cjs');
|
|
13
13
|
const core = require('@magicyan/core');
|
|
14
14
|
|
|
15
15
|
|
|
@@ -19,17 +19,18 @@ exports.CustomPartials = client.CustomPartials;
|
|
|
19
19
|
exports.findChannel = channels.findChannel;
|
|
20
20
|
exports.findCommand = commands.findCommand;
|
|
21
21
|
exports.createComponentsManager = components.createComponentsManager;
|
|
22
|
+
exports.createLinkButton = components.createLinkButton;
|
|
23
|
+
exports.createModalInput = components.createModalInput;
|
|
24
|
+
exports.createRow = components.createRow;
|
|
22
25
|
exports.createEmbed = embeds.createEmbed;
|
|
23
26
|
exports.createEmbedAsset = embeds.createEmbedAsset;
|
|
24
27
|
exports.createEmbedAuthor = embeds.createEmbedAuthor;
|
|
25
28
|
exports.createEmbedFooter = embeds.createEmbedFooter;
|
|
26
29
|
exports.findEmoji = emojis.findEmoji;
|
|
27
|
-
exports.
|
|
30
|
+
exports.formatedMention = format.formatedMention;
|
|
28
31
|
exports.findMember = members.findMember;
|
|
32
|
+
exports.findMessage = message.findMessage;
|
|
29
33
|
exports.findRole = roles.findRole;
|
|
30
|
-
exports.createLinkButton = utils.createLinkButton;
|
|
31
|
-
exports.createModalInput = utils.createModalInput;
|
|
32
|
-
exports.createRow = utils.createRow;
|
|
33
34
|
Object.keys(core).forEach(function (k) {
|
|
34
35
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = core[k];
|
|
35
36
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, ActionRow, MessageActionRowComponent, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, EmbedAuthorData, EmbedFooterData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, ColorResolvable, GuildEmoji, GuildBasedChannel, Role, GuildMember,
|
|
2
|
+
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, AnyComponentBuilder, ActionRowBuilder, TextInputBuilder, ButtonBuilder, ActionRow, MessageActionRowComponent, TextInputComponentData, LinkButtonComponentData, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, EmbedAuthorData, EmbedFooterData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, ColorResolvable, GuildEmoji, GuildBasedChannel, Role, GuildMember, GuildTextBasedChannel, Message } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const CustomItents: {
|
|
@@ -41,6 +41,13 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
|
|
|
41
41
|
}> | undefined;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
|
|
45
|
+
interface CreateModalInputData extends Omit<TextInputComponentData, "type"> {
|
|
46
|
+
}
|
|
47
|
+
declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<TextInputBuilder>;
|
|
48
|
+
interface CreateLinkButtonData extends Omit<LinkButtonComponentData, "style" | "type"> {
|
|
49
|
+
}
|
|
50
|
+
declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
|
|
44
51
|
interface MessageComponentsManager {
|
|
45
52
|
getButton(customId: string): ButtonComponent | undefined;
|
|
46
53
|
getButton(customId: string, required: true): ButtonComponent;
|
|
@@ -79,17 +86,17 @@ interface CreateEmbedFooterOptions {
|
|
|
79
86
|
text?: string | null;
|
|
80
87
|
iconURL?: string | null;
|
|
81
88
|
}
|
|
82
|
-
declare function createEmbedFooter(options: CreateEmbedFooterOptions): EmbedFooterData;
|
|
89
|
+
declare function createEmbedFooter(options: CreateEmbedFooterOptions): EmbedFooterData | undefined;
|
|
83
90
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
|
84
91
|
type AssetSource = string | null | Attachment | AttachmentBuilder;
|
|
85
92
|
declare function createEmbedAsset(source?: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
86
93
|
type EmbedColor = ColorResolvable | (string & {});
|
|
87
|
-
|
|
94
|
+
interface BaseEmbedField {
|
|
88
95
|
name: string;
|
|
89
96
|
value: string;
|
|
90
97
|
inline?: boolean;
|
|
91
|
-
}
|
|
92
|
-
|
|
98
|
+
}
|
|
99
|
+
interface BaseEmbedData {
|
|
93
100
|
title?: string;
|
|
94
101
|
color?: EmbedColor;
|
|
95
102
|
description?: string;
|
|
@@ -100,13 +107,13 @@ type BaseEmbedData = {
|
|
|
100
107
|
thumbnail?: EmbedAssetData;
|
|
101
108
|
author?: EmbedAuthorData;
|
|
102
109
|
fields?: BaseEmbedField[];
|
|
103
|
-
}
|
|
104
|
-
|
|
110
|
+
}
|
|
111
|
+
interface CreateEmbedOptions extends BaseEmbedData {
|
|
105
112
|
extend?: BaseEmbedData;
|
|
106
113
|
modify?: {
|
|
107
114
|
fields?(fields: BaseEmbedField[]): BaseEmbedField[];
|
|
108
115
|
};
|
|
109
|
-
}
|
|
116
|
+
}
|
|
110
117
|
declare function createEmbed(options: CreateEmbedOptions): EmbedBuilder;
|
|
111
118
|
|
|
112
119
|
type FindEmojiFilter = (emoji: GuildEmoji) => boolean;
|
|
@@ -116,15 +123,7 @@ declare function findEmoji(guildOrClient: Guild | Client): {
|
|
|
116
123
|
byFilter(filter: FindEmojiFilter): GuildEmoji | undefined;
|
|
117
124
|
};
|
|
118
125
|
|
|
119
|
-
|
|
120
|
-
type GetMentionType<T extends MentionType> = string | null | undefined | (T extends "channel" ? GuildBasedChannel : T extends "role" ? Role : T extends "user" ? User : never);
|
|
121
|
-
declare const formated: {
|
|
122
|
-
mention<T extends MentionType>(type: T, ref: GetMentionType<T>, alt?: string): {
|
|
123
|
-
channel: string;
|
|
124
|
-
user: string;
|
|
125
|
-
role: string;
|
|
126
|
-
}[T];
|
|
127
|
-
};
|
|
126
|
+
declare function formatedMention(ref: GuildBasedChannel | Role | User | undefined | null, alt?: string): string;
|
|
128
127
|
|
|
129
128
|
type FindMemberFilter = (member: GuildMember) => boolean;
|
|
130
129
|
declare function findMember(guild: Guild): {
|
|
@@ -136,6 +135,16 @@ declare function findMember(guild: Guild): {
|
|
|
136
135
|
byFilter(filter: FindMemberFilter): GuildMember | undefined;
|
|
137
136
|
};
|
|
138
137
|
|
|
138
|
+
type FindMessageFilter = (role: Message<true>) => boolean;
|
|
139
|
+
declare function findMessage(channel: GuildTextBasedChannel): {
|
|
140
|
+
byId(id: string): Message<true> | undefined;
|
|
141
|
+
byContent(): {
|
|
142
|
+
equals(content: string, ignoreCase?: boolean): Message<true> | undefined;
|
|
143
|
+
include(content: string, ignoreCase?: boolean): Message<true> | undefined;
|
|
144
|
+
};
|
|
145
|
+
byFilter(filter: FindMessageFilter): Message<true> | undefined;
|
|
146
|
+
};
|
|
147
|
+
|
|
139
148
|
type FindRoleFilter = (role: Role) => boolean;
|
|
140
149
|
declare function findRole(guild: Guild): {
|
|
141
150
|
byColor(color: number, and?: FindRoleFilter): Role | undefined;
|
|
@@ -145,10 +154,4 @@ declare function findRole(guild: Guild): {
|
|
|
145
154
|
byFilter(filter: FindRoleFilter): Role | undefined;
|
|
146
155
|
};
|
|
147
156
|
|
|
148
|
-
|
|
149
|
-
type CreateModalInputData = Omit<TextInputComponentData, "type">;
|
|
150
|
-
declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<TextInputBuilder>;
|
|
151
|
-
type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
|
|
152
|
-
declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
|
|
153
|
-
|
|
154
|
-
export { CustomItents, CustomPartials, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalInput, createRow, findChannel, findCommand, findEmoji, findMember, findRole, formated };
|
|
157
|
+
export { type BaseEmbedData, CustomItents, CustomPartials, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalInput, createRow, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, formatedMention };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, ActionRow, MessageActionRowComponent, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, EmbedAuthorData, EmbedFooterData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, ColorResolvable, GuildEmoji, GuildBasedChannel, Role, GuildMember,
|
|
2
|
+
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, AnyComponentBuilder, ActionRowBuilder, TextInputBuilder, ButtonBuilder, ActionRow, MessageActionRowComponent, TextInputComponentData, LinkButtonComponentData, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, EmbedAuthorData, EmbedFooterData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, ColorResolvable, GuildEmoji, GuildBasedChannel, Role, GuildMember, GuildTextBasedChannel, Message } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const CustomItents: {
|
|
@@ -41,6 +41,13 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
|
|
|
41
41
|
}> | undefined;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
|
|
45
|
+
interface CreateModalInputData extends Omit<TextInputComponentData, "type"> {
|
|
46
|
+
}
|
|
47
|
+
declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<TextInputBuilder>;
|
|
48
|
+
interface CreateLinkButtonData extends Omit<LinkButtonComponentData, "style" | "type"> {
|
|
49
|
+
}
|
|
50
|
+
declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
|
|
44
51
|
interface MessageComponentsManager {
|
|
45
52
|
getButton(customId: string): ButtonComponent | undefined;
|
|
46
53
|
getButton(customId: string, required: true): ButtonComponent;
|
|
@@ -79,17 +86,17 @@ interface CreateEmbedFooterOptions {
|
|
|
79
86
|
text?: string | null;
|
|
80
87
|
iconURL?: string | null;
|
|
81
88
|
}
|
|
82
|
-
declare function createEmbedFooter(options: CreateEmbedFooterOptions): EmbedFooterData;
|
|
89
|
+
declare function createEmbedFooter(options: CreateEmbedFooterOptions): EmbedFooterData | undefined;
|
|
83
90
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
|
84
91
|
type AssetSource = string | null | Attachment | AttachmentBuilder;
|
|
85
92
|
declare function createEmbedAsset(source?: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
86
93
|
type EmbedColor = ColorResolvable | (string & {});
|
|
87
|
-
|
|
94
|
+
interface BaseEmbedField {
|
|
88
95
|
name: string;
|
|
89
96
|
value: string;
|
|
90
97
|
inline?: boolean;
|
|
91
|
-
}
|
|
92
|
-
|
|
98
|
+
}
|
|
99
|
+
interface BaseEmbedData {
|
|
93
100
|
title?: string;
|
|
94
101
|
color?: EmbedColor;
|
|
95
102
|
description?: string;
|
|
@@ -100,13 +107,13 @@ type BaseEmbedData = {
|
|
|
100
107
|
thumbnail?: EmbedAssetData;
|
|
101
108
|
author?: EmbedAuthorData;
|
|
102
109
|
fields?: BaseEmbedField[];
|
|
103
|
-
}
|
|
104
|
-
|
|
110
|
+
}
|
|
111
|
+
interface CreateEmbedOptions extends BaseEmbedData {
|
|
105
112
|
extend?: BaseEmbedData;
|
|
106
113
|
modify?: {
|
|
107
114
|
fields?(fields: BaseEmbedField[]): BaseEmbedField[];
|
|
108
115
|
};
|
|
109
|
-
}
|
|
116
|
+
}
|
|
110
117
|
declare function createEmbed(options: CreateEmbedOptions): EmbedBuilder;
|
|
111
118
|
|
|
112
119
|
type FindEmojiFilter = (emoji: GuildEmoji) => boolean;
|
|
@@ -116,15 +123,7 @@ declare function findEmoji(guildOrClient: Guild | Client): {
|
|
|
116
123
|
byFilter(filter: FindEmojiFilter): GuildEmoji | undefined;
|
|
117
124
|
};
|
|
118
125
|
|
|
119
|
-
|
|
120
|
-
type GetMentionType<T extends MentionType> = string | null | undefined | (T extends "channel" ? GuildBasedChannel : T extends "role" ? Role : T extends "user" ? User : never);
|
|
121
|
-
declare const formated: {
|
|
122
|
-
mention<T extends MentionType>(type: T, ref: GetMentionType<T>, alt?: string): {
|
|
123
|
-
channel: string;
|
|
124
|
-
user: string;
|
|
125
|
-
role: string;
|
|
126
|
-
}[T];
|
|
127
|
-
};
|
|
126
|
+
declare function formatedMention(ref: GuildBasedChannel | Role | User | undefined | null, alt?: string): string;
|
|
128
127
|
|
|
129
128
|
type FindMemberFilter = (member: GuildMember) => boolean;
|
|
130
129
|
declare function findMember(guild: Guild): {
|
|
@@ -136,6 +135,16 @@ declare function findMember(guild: Guild): {
|
|
|
136
135
|
byFilter(filter: FindMemberFilter): GuildMember | undefined;
|
|
137
136
|
};
|
|
138
137
|
|
|
138
|
+
type FindMessageFilter = (role: Message<true>) => boolean;
|
|
139
|
+
declare function findMessage(channel: GuildTextBasedChannel): {
|
|
140
|
+
byId(id: string): Message<true> | undefined;
|
|
141
|
+
byContent(): {
|
|
142
|
+
equals(content: string, ignoreCase?: boolean): Message<true> | undefined;
|
|
143
|
+
include(content: string, ignoreCase?: boolean): Message<true> | undefined;
|
|
144
|
+
};
|
|
145
|
+
byFilter(filter: FindMessageFilter): Message<true> | undefined;
|
|
146
|
+
};
|
|
147
|
+
|
|
139
148
|
type FindRoleFilter = (role: Role) => boolean;
|
|
140
149
|
declare function findRole(guild: Guild): {
|
|
141
150
|
byColor(color: number, and?: FindRoleFilter): Role | undefined;
|
|
@@ -145,10 +154,4 @@ declare function findRole(guild: Guild): {
|
|
|
145
154
|
byFilter(filter: FindRoleFilter): Role | undefined;
|
|
146
155
|
};
|
|
147
156
|
|
|
148
|
-
|
|
149
|
-
type CreateModalInputData = Omit<TextInputComponentData, "type">;
|
|
150
|
-
declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<TextInputBuilder>;
|
|
151
|
-
type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
|
|
152
|
-
declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
|
|
153
|
-
|
|
154
|
-
export { CustomItents, CustomPartials, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalInput, createRow, findChannel, findCommand, findEmoji, findMember, findRole, formated };
|
|
157
|
+
export { type BaseEmbedData, CustomItents, CustomPartials, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalInput, createRow, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, formatedMention };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, ActionRow, MessageActionRowComponent, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, EmbedAuthorData, EmbedFooterData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, ColorResolvable, GuildEmoji, GuildBasedChannel, Role, GuildMember,
|
|
2
|
+
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, AnyComponentBuilder, ActionRowBuilder, TextInputBuilder, ButtonBuilder, ActionRow, MessageActionRowComponent, TextInputComponentData, LinkButtonComponentData, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, EmbedAuthorData, EmbedFooterData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, ColorResolvable, GuildEmoji, GuildBasedChannel, Role, GuildMember, GuildTextBasedChannel, Message } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const CustomItents: {
|
|
@@ -41,6 +41,13 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
|
|
|
41
41
|
}> | undefined;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
|
|
45
|
+
interface CreateModalInputData extends Omit<TextInputComponentData, "type"> {
|
|
46
|
+
}
|
|
47
|
+
declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<TextInputBuilder>;
|
|
48
|
+
interface CreateLinkButtonData extends Omit<LinkButtonComponentData, "style" | "type"> {
|
|
49
|
+
}
|
|
50
|
+
declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
|
|
44
51
|
interface MessageComponentsManager {
|
|
45
52
|
getButton(customId: string): ButtonComponent | undefined;
|
|
46
53
|
getButton(customId: string, required: true): ButtonComponent;
|
|
@@ -79,17 +86,17 @@ interface CreateEmbedFooterOptions {
|
|
|
79
86
|
text?: string | null;
|
|
80
87
|
iconURL?: string | null;
|
|
81
88
|
}
|
|
82
|
-
declare function createEmbedFooter(options: CreateEmbedFooterOptions): EmbedFooterData;
|
|
89
|
+
declare function createEmbedFooter(options: CreateEmbedFooterOptions): EmbedFooterData | undefined;
|
|
83
90
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
|
84
91
|
type AssetSource = string | null | Attachment | AttachmentBuilder;
|
|
85
92
|
declare function createEmbedAsset(source?: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
86
93
|
type EmbedColor = ColorResolvable | (string & {});
|
|
87
|
-
|
|
94
|
+
interface BaseEmbedField {
|
|
88
95
|
name: string;
|
|
89
96
|
value: string;
|
|
90
97
|
inline?: boolean;
|
|
91
|
-
}
|
|
92
|
-
|
|
98
|
+
}
|
|
99
|
+
interface BaseEmbedData {
|
|
93
100
|
title?: string;
|
|
94
101
|
color?: EmbedColor;
|
|
95
102
|
description?: string;
|
|
@@ -100,13 +107,13 @@ type BaseEmbedData = {
|
|
|
100
107
|
thumbnail?: EmbedAssetData;
|
|
101
108
|
author?: EmbedAuthorData;
|
|
102
109
|
fields?: BaseEmbedField[];
|
|
103
|
-
}
|
|
104
|
-
|
|
110
|
+
}
|
|
111
|
+
interface CreateEmbedOptions extends BaseEmbedData {
|
|
105
112
|
extend?: BaseEmbedData;
|
|
106
113
|
modify?: {
|
|
107
114
|
fields?(fields: BaseEmbedField[]): BaseEmbedField[];
|
|
108
115
|
};
|
|
109
|
-
}
|
|
116
|
+
}
|
|
110
117
|
declare function createEmbed(options: CreateEmbedOptions): EmbedBuilder;
|
|
111
118
|
|
|
112
119
|
type FindEmojiFilter = (emoji: GuildEmoji) => boolean;
|
|
@@ -116,15 +123,7 @@ declare function findEmoji(guildOrClient: Guild | Client): {
|
|
|
116
123
|
byFilter(filter: FindEmojiFilter): GuildEmoji | undefined;
|
|
117
124
|
};
|
|
118
125
|
|
|
119
|
-
|
|
120
|
-
type GetMentionType<T extends MentionType> = string | null | undefined | (T extends "channel" ? GuildBasedChannel : T extends "role" ? Role : T extends "user" ? User : never);
|
|
121
|
-
declare const formated: {
|
|
122
|
-
mention<T extends MentionType>(type: T, ref: GetMentionType<T>, alt?: string): {
|
|
123
|
-
channel: string;
|
|
124
|
-
user: string;
|
|
125
|
-
role: string;
|
|
126
|
-
}[T];
|
|
127
|
-
};
|
|
126
|
+
declare function formatedMention(ref: GuildBasedChannel | Role | User | undefined | null, alt?: string): string;
|
|
128
127
|
|
|
129
128
|
type FindMemberFilter = (member: GuildMember) => boolean;
|
|
130
129
|
declare function findMember(guild: Guild): {
|
|
@@ -136,6 +135,16 @@ declare function findMember(guild: Guild): {
|
|
|
136
135
|
byFilter(filter: FindMemberFilter): GuildMember | undefined;
|
|
137
136
|
};
|
|
138
137
|
|
|
138
|
+
type FindMessageFilter = (role: Message<true>) => boolean;
|
|
139
|
+
declare function findMessage(channel: GuildTextBasedChannel): {
|
|
140
|
+
byId(id: string): Message<true> | undefined;
|
|
141
|
+
byContent(): {
|
|
142
|
+
equals(content: string, ignoreCase?: boolean): Message<true> | undefined;
|
|
143
|
+
include(content: string, ignoreCase?: boolean): Message<true> | undefined;
|
|
144
|
+
};
|
|
145
|
+
byFilter(filter: FindMessageFilter): Message<true> | undefined;
|
|
146
|
+
};
|
|
147
|
+
|
|
139
148
|
type FindRoleFilter = (role: Role) => boolean;
|
|
140
149
|
declare function findRole(guild: Guild): {
|
|
141
150
|
byColor(color: number, and?: FindRoleFilter): Role | undefined;
|
|
@@ -145,10 +154,4 @@ declare function findRole(guild: Guild): {
|
|
|
145
154
|
byFilter(filter: FindRoleFilter): Role | undefined;
|
|
146
155
|
};
|
|
147
156
|
|
|
148
|
-
|
|
149
|
-
type CreateModalInputData = Omit<TextInputComponentData, "type">;
|
|
150
|
-
declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<TextInputBuilder>;
|
|
151
|
-
type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
|
|
152
|
-
declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
|
|
153
|
-
|
|
154
|
-
export { CustomItents, CustomPartials, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalInput, createRow, findChannel, findCommand, findEmoji, findMember, findRole, formated };
|
|
157
|
+
export { type BaseEmbedData, CustomItents, CustomPartials, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalInput, createRow, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, formatedMention };
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { CustomItents, CustomPartials } from './constants/client.mjs';
|
|
2
2
|
export { findChannel } from './functions/channels.mjs';
|
|
3
3
|
export { findCommand } from './functions/commands.mjs';
|
|
4
|
-
export { createComponentsManager } from './functions/components.mjs';
|
|
4
|
+
export { createComponentsManager, createLinkButton, createModalInput, createRow } from './functions/components.mjs';
|
|
5
5
|
export { createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter } from './functions/embeds.mjs';
|
|
6
6
|
export { findEmoji } from './functions/emojis.mjs';
|
|
7
|
-
export {
|
|
7
|
+
export { formatedMention } from './functions/format.mjs';
|
|
8
8
|
export { findMember } from './functions/members.mjs';
|
|
9
|
+
export { findMessage } from './functions/message.mjs';
|
|
9
10
|
export { findRole } from './functions/roles.mjs';
|
|
10
|
-
export { createLinkButton, createModalInput, createRow } from './functions/utils.mjs';
|
|
11
11
|
export * from '@magicyan/core';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicyan/discord",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Simple functions to facilitate discord bot development",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"unbuild": "^2.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@magicyan/core": "^1.0.
|
|
42
|
+
"@magicyan/core": "^1.0.16"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"discord.js": "^14.14.1"
|
package/dist/functions/utils.cjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const discord_js = require('discord.js');
|
|
4
|
-
|
|
5
|
-
function createRow(...components) {
|
|
6
|
-
return new discord_js.ActionRowBuilder({ components });
|
|
7
|
-
}
|
|
8
|
-
function createModalInput(data) {
|
|
9
|
-
return createRow(new discord_js.TextInputBuilder(data));
|
|
10
|
-
}
|
|
11
|
-
function createLinkButton(data) {
|
|
12
|
-
if (!data.label)
|
|
13
|
-
data.label = data.url;
|
|
14
|
-
return new discord_js.ButtonBuilder({ style: discord_js.ButtonStyle.Link, ...data });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
exports.createLinkButton = createLinkButton;
|
|
18
|
-
exports.createModalInput = createModalInput;
|
|
19
|
-
exports.createRow = createRow;
|
package/dist/functions/utils.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ActionRowBuilder, TextInputBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
|
|
2
|
-
|
|
3
|
-
function createRow(...components) {
|
|
4
|
-
return new ActionRowBuilder({ components });
|
|
5
|
-
}
|
|
6
|
-
function createModalInput(data) {
|
|
7
|
-
return createRow(new TextInputBuilder(data));
|
|
8
|
-
}
|
|
9
|
-
function createLinkButton(data) {
|
|
10
|
-
if (!data.label)
|
|
11
|
-
data.label = data.url;
|
|
12
|
-
return new ButtonBuilder({ style: ButtonStyle.Link, ...data });
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { createLinkButton, createModalInput, createRow };
|