xernerx 4.5.22 → 4.5.26
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 +3 -0
- package/dist/build/XernerxContextCommand.d.ts +42 -50
- package/dist/build/XernerxContextCommand.js +71 -71
- package/dist/build/XernerxEvent.d.ts +15 -15
- package/dist/build/XernerxEvent.js +22 -22
- package/dist/build/XernerxInhibitor.d.ts +14 -25
- package/dist/build/XernerxInhibitor.js +20 -20
- package/dist/build/XernerxMessageCommand.d.ts +47 -53
- package/dist/build/XernerxMessageCommand.js +70 -70
- package/dist/build/XernerxSlashCommand.d.ts +57 -71
- package/dist/build/XernerxSlashCommand.js +128 -128
- package/dist/client/XernerxClient.d.ts +40 -48
- package/dist/client/XernerxClient.js +77 -77
- package/dist/client/XernerxShardClient.d.ts +12 -12
- package/dist/client/XernerxShardClient.js +39 -47
- package/dist/functions/deploy.d.ts +1 -1
- package/dist/functions/deploy.js +36 -31
- package/dist/functions/load.d.ts +1 -1
- package/dist/functions/load.js +29 -28
- package/dist/functions/reload.d.ts +1 -1
- package/dist/functions/reload.js +38 -35
- package/dist/functions/sendWebhook.d.ts +1 -1
- package/dist/functions/sendWebhook.js +12 -11
- package/dist/functions/setPresence.d.ts +2 -2
- package/dist/functions/setPresence.js +17 -18
- package/dist/functions/xernerxUser.d.ts +1 -1
- package/dist/functions/xernerxUser.js +6 -6
- package/dist/handlers/CommandHandler.d.ts +9 -9
- package/dist/handlers/CommandHandler.d.ts.map +1 -1
- package/dist/handlers/CommandHandler.js +281 -249
- package/dist/handlers/CommandHandler.js.map +1 -1
- package/dist/handlers/EventHandler.d.ts +3 -3
- package/dist/handlers/EventHandler.js +19 -19
- package/dist/handlers/ExtensionHandler.d.ts +3 -3
- package/dist/handlers/ExtensionHandler.js +20 -18
- package/dist/handlers/Handler.d.ts +8 -8
- package/dist/handlers/Handler.js +42 -32
- package/dist/handlers/InhibitorHandler.d.ts +3 -3
- package/dist/handlers/InhibitorHandler.js +19 -19
- package/dist/handlers/WebhookHandler.d.ts +6 -4
- package/dist/handlers/WebhookHandler.js +44 -47
- package/dist/main.d.ts +22 -29
- package/dist/main.js +22 -29
- package/dist/models/Arguments.d.ts +2 -5
- package/dist/models/Arguments.js +150 -135
- package/dist/tools/XernerxError.d.ts +5 -5
- package/dist/tools/XernerxError.js +9 -9
- package/dist/tools/XernerxLog.d.ts +13 -13
- package/dist/tools/XernerxLog.js +69 -74
- package/dist/tools/XernerxText.d.ts +23 -23
- package/dist/tools/XernerxText.js +85 -76
- package/dist/types/extenders.d.ts +36 -44
- package/dist/types/extenders.js +1 -1
- package/dist/types/interfaces.d.ts +182 -185
- package/dist/types/interfaces.js +1 -1
- package/dist/types/types.d.ts +7 -179
- package/dist/types/types.js +1 -1
- package/dist/utils/ClientUtil.d.ts +9 -11
- package/dist/utils/ClientUtil.js +73 -57
- package/dist/utils/InteractionUtil.d.ts +7 -7
- package/dist/utils/InteractionUtil.js +98 -96
- package/dist/utils/MessageUtil.d.ts +11 -11
- package/dist/utils/MessageUtil.js +135 -130
- package/dist/utils/Util.d.ts +5 -5
- package/dist/utils/Util.js +8 -8
- package/dist/validators/commandValidation.d.ts +2 -5
- package/dist/validators/commandValidation.js +53 -43
- package/dist/validators/inhibitorValidations.d.ts +3 -19
- package/dist/validators/inhibitorValidations.js +31 -31
- package/package.json +16 -13
package/dist/utils/ClientUtil.js
CHANGED
|
@@ -3,61 +3,77 @@ import setPresence from '../functions/setPresence.js';
|
|
|
3
3
|
import Util from './Util.js';
|
|
4
4
|
import { Collection } from 'discord.js';
|
|
5
5
|
export default class ClientUtil extends Util {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
6
|
+
constructor(client) {
|
|
7
|
+
super(client);
|
|
8
|
+
}
|
|
9
|
+
setPresence(options) {
|
|
10
|
+
return setPresence(this.client, options);
|
|
11
|
+
}
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
resolveCooldown() { }
|
|
14
|
+
resolveCommand(options) {
|
|
15
|
+
const commands = [], collection = new Collection();
|
|
16
|
+
if (options?.type == 'MessageCommand' || !options?.type)
|
|
17
|
+
commands.push(...this.client.commands.message);
|
|
18
|
+
if (options?.type == 'Interaction' || options?.type == 'SlashCommand' || !options?.type)
|
|
19
|
+
commands.push(...this.client.commands.slash);
|
|
20
|
+
if (options?.type == 'Interaction' || options?.type == 'ContextCommand' || !options?.type)
|
|
21
|
+
commands.push(...this.client.commands.context);
|
|
22
|
+
commands.map(([name, command]) => collection.set(name, command));
|
|
23
|
+
if (options?.name) {
|
|
24
|
+
return collection.get(options.name) || null;
|
|
25
|
+
}
|
|
26
|
+
else
|
|
27
|
+
return collection;
|
|
28
|
+
}
|
|
29
|
+
async resolveChannel(query) {
|
|
30
|
+
if (typeof query == 'object')
|
|
31
|
+
query = query.id;
|
|
32
|
+
try {
|
|
33
|
+
let channel = this.client.channels.cache.find((channel) => channel.name == query.toLowerCase() || channel.id == query.toLowerCase() ? channel : null) || null;
|
|
34
|
+
if (!channel)
|
|
35
|
+
channel = (await this.client.channels.fetch(query)) || null;
|
|
36
|
+
return channel;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async resolveGuild(query) {
|
|
43
|
+
if (typeof query == 'object')
|
|
44
|
+
query = query.id;
|
|
45
|
+
try {
|
|
46
|
+
let guild = this.client.guilds.cache.find((guild) => guild.name.toLowerCase() == query.toLowerCase()) || null;
|
|
47
|
+
if (!guild)
|
|
48
|
+
guild = (await this.client.guilds.fetch(query)) || null;
|
|
49
|
+
return guild;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
uptime(timestamp) {
|
|
56
|
+
if (!timestamp)
|
|
57
|
+
timestamp = this.client.uptime || 0;
|
|
58
|
+
let totalSeconds = timestamp / 1000;
|
|
59
|
+
let years = Math.floor(totalSeconds / 31536000);
|
|
60
|
+
totalSeconds %= 31536000;
|
|
61
|
+
let days = Math.floor(totalSeconds / 86400);
|
|
62
|
+
totalSeconds %= 86400;
|
|
63
|
+
let hours = Math.floor(totalSeconds / 3600);
|
|
64
|
+
totalSeconds %= 3600;
|
|
65
|
+
let minutes = Math.floor(totalSeconds / 60);
|
|
66
|
+
let seconds = Math.floor(totalSeconds % 60);
|
|
67
|
+
if (years >= 1)
|
|
68
|
+
return `${years}y ${days}d ${hours}h ${minutes}m`;
|
|
69
|
+
else if (days >= 1)
|
|
70
|
+
return `${days}d ${hours}h ${minutes}m`;
|
|
71
|
+
else if (hours >= 1)
|
|
72
|
+
return `${hours}h ${minutes}m`;
|
|
73
|
+
else if (minutes >= 1)
|
|
74
|
+
return `${minutes}m ${seconds}s`;
|
|
75
|
+
else
|
|
76
|
+
return `${seconds}s`;
|
|
77
|
+
}
|
|
62
78
|
}
|
|
63
|
-
//# sourceMappingURL=ClientUtil.js.map
|
|
79
|
+
//# sourceMappingURL=ClientUtil.js.map
|
|
@@ -6,11 +6,11 @@ import { XernerxInteraction } from '../types/types.js';
|
|
|
6
6
|
import Util from './Util.js';
|
|
7
7
|
import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
8
8
|
export default class InteractionUtil extends Util {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
private interaction;
|
|
10
|
+
constructor(client: XernerxClient, interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>);
|
|
11
|
+
send(content: any): Promise<import("discord.js").Message<false> | import("discord.js").Message<true> | undefined>;
|
|
12
|
+
reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions): Promise<import("discord.js").InteractionResponse<boolean> | import("discord.js").Message<boolean>>;
|
|
13
|
+
private commandName;
|
|
14
|
+
paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<void | import("discord.js").Message<false> | import("discord.js").Message<true>>;
|
|
15
15
|
}
|
|
16
|
-
//# sourceMappingURL=InteractionUtil.d.ts.map
|
|
16
|
+
//# sourceMappingURL=InteractionUtil.d.ts.map
|
|
@@ -3,100 +3,102 @@ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder }
|
|
|
3
3
|
import Util from './Util.js';
|
|
4
4
|
import XernerxError from '../tools/XernerxError.js';
|
|
5
5
|
export default class InteractionUtil extends Util {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
6
|
+
interaction;
|
|
7
|
+
constructor(client, interaction) {
|
|
8
|
+
super(client);
|
|
9
|
+
this.interaction = interaction;
|
|
10
|
+
}
|
|
11
|
+
async send(content) {
|
|
12
|
+
if (!content)
|
|
13
|
+
throw new XernerxError(`Can't send a message without content.`);
|
|
14
|
+
return await this.interaction.channel?.send(content);
|
|
15
|
+
}
|
|
16
|
+
async reply(content) {
|
|
17
|
+
if (!content)
|
|
18
|
+
throw new XernerxError(`Can't send a message without content.`);
|
|
19
|
+
return await (this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content));
|
|
20
|
+
}
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
commandName() { }
|
|
23
|
+
async paginator(embeds, options = {}) {
|
|
24
|
+
let buttonRow, menuRow;
|
|
25
|
+
if (embeds.length <= 0)
|
|
26
|
+
throw new XernerxError(`Can't make a paginator without embeds`);
|
|
27
|
+
options = {
|
|
28
|
+
type: options.type ?? 'combined',
|
|
29
|
+
buttons: options.buttons ?? ['⏪', '◀️', '⏹️', '▶️', '⏩'],
|
|
30
|
+
description: options.description ?? false,
|
|
31
|
+
placeholder: options.placeholder ?? 'Change page',
|
|
32
|
+
index: options.index ?? 0,
|
|
33
|
+
send: options.send ?? false,
|
|
34
|
+
filter: options.filter ?? (() => true),
|
|
35
|
+
time: options.time ?? 300000,
|
|
36
|
+
};
|
|
37
|
+
if (options.type == 'button' || options.type == 'combined') {
|
|
38
|
+
if (!options.buttons)
|
|
39
|
+
throw new XernerxError(`¯\\_(ツ)_/¯ Somehow there are no buttons? ¯\\_(ツ)_/¯`);
|
|
40
|
+
buttonRow = new ActionRowBuilder().addComponents(...options.buttons.map((button, i) => new ButtonBuilder().setCustomId(`${this.interaction.id}-${i}`).setEmoji(button).setStyle(ButtonStyle.Primary)));
|
|
41
|
+
}
|
|
42
|
+
if (options.type == 'select-menu' || options.type == 'combined') {
|
|
43
|
+
menuRow = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder()
|
|
44
|
+
.setCustomId(`${this.interaction.id}-select-menu`)
|
|
45
|
+
.setPlaceholder(options.placeholder)
|
|
46
|
+
.addOptions(...embeds.map((embed, i) => ({ label: embed.data.title || 'No Title', description: (options.description ? embed.data.description : undefined) || undefined, value: `${i}` }))));
|
|
47
|
+
}
|
|
48
|
+
let index = options.index || 0;
|
|
49
|
+
return options.send
|
|
50
|
+
? await this.interaction.util.send({
|
|
51
|
+
embeds: [embeds[index]],
|
|
52
|
+
components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
|
|
53
|
+
})
|
|
54
|
+
: await this.interaction.util
|
|
55
|
+
.reply({
|
|
56
|
+
embeds: [embeds[index]],
|
|
57
|
+
components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
|
|
58
|
+
})
|
|
59
|
+
.then(async (msg) => {
|
|
60
|
+
const collector = this.interaction.channel
|
|
61
|
+
?.createMessageComponentCollector({ time: options.time })
|
|
62
|
+
.on('collect', (collect) => {
|
|
63
|
+
if (!collect.customId.startsWith(this.interaction.id))
|
|
64
|
+
return;
|
|
65
|
+
if (collect.customId.endsWith('select-menu')) {
|
|
66
|
+
index = Number(collect.values[0]);
|
|
67
|
+
collect.update({ embeds: [embeds[index]] });
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const option = Number(collect.customId.split(/-/)[1]);
|
|
71
|
+
let embed = embeds[index];
|
|
72
|
+
if (option == 0) {
|
|
73
|
+
index = 0;
|
|
74
|
+
embed = embeds[index];
|
|
75
|
+
collect.update({ embeds: [embed] });
|
|
76
|
+
}
|
|
77
|
+
if (option == 1) {
|
|
78
|
+
index = embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0;
|
|
79
|
+
embed = embeds[index];
|
|
80
|
+
collect.update({ embeds: [embed] });
|
|
81
|
+
}
|
|
82
|
+
if (option == 2) {
|
|
83
|
+
collect.update({ components: [] });
|
|
84
|
+
collector?.stop();
|
|
85
|
+
}
|
|
86
|
+
if (option == 3) {
|
|
87
|
+
index = embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1;
|
|
88
|
+
embed = embeds[index];
|
|
89
|
+
collect.update({ embeds: [embed] });
|
|
90
|
+
}
|
|
91
|
+
if (option == 4) {
|
|
92
|
+
index = embeds.length - 1;
|
|
93
|
+
embed = embeds[index];
|
|
94
|
+
collect.update({ embeds: [embed] });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
.on('end', async () => {
|
|
99
|
+
this.interaction.editReply({ components: [] });
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
101
103
|
}
|
|
102
|
-
//# sourceMappingURL=InteractionUtil.js.map
|
|
104
|
+
//# sourceMappingURL=InteractionUtil.js.map
|
|
@@ -5,15 +5,15 @@ import { XernerxMessage } from '../types/extenders.js';
|
|
|
5
5
|
import Util from './Util.js';
|
|
6
6
|
import { PaginatorOptions } from '../main.js';
|
|
7
7
|
export default class MessageUtil extends Util {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
private readonly message;
|
|
9
|
+
parsed: {
|
|
10
|
+
alias: null | string;
|
|
11
|
+
prefix: null | string;
|
|
12
|
+
};
|
|
13
|
+
constructor(client: XernerxClient, message: XernerxMessage);
|
|
14
|
+
send(content: any): Promise<import("discord.js").Message<false> | import("discord.js").Message<true> | null>;
|
|
15
|
+
reply(content: string | MessagePayload | MessageReplyOptions | MessageEditOptions): Promise<import("discord.js").Message<boolean> | null>;
|
|
16
|
+
webhookReply(content: MessagePayload, url?: URL, user?: User): Promise<void>;
|
|
17
|
+
paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<void | import("discord.js").Message<false> | import("discord.js").Message<true> | null>;
|
|
18
18
|
}
|
|
19
|
-
//# sourceMappingURL=MessageUtil.d.ts.map
|
|
19
|
+
//# sourceMappingURL=MessageUtil.d.ts.map
|