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