xernerx 4.17.7 → 4.17.9

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 (68) hide show
  1. package/dist/build/XernerxContextCommand.d.ts +47 -75
  2. package/dist/build/XernerxContextCommand.js +115 -119
  3. package/dist/build/XernerxEvent.d.ts +10 -10
  4. package/dist/build/XernerxEvent.js +17 -17
  5. package/dist/build/XernerxInhibitor.d.ts +15 -39
  6. package/dist/build/XernerxInhibitor.js +18 -18
  7. package/dist/build/XernerxMessageCommand.d.ts +52 -78
  8. package/dist/build/XernerxMessageCommand.js +114 -118
  9. package/dist/build/XernerxSlashCommand.d.ts +63 -97
  10. package/dist/build/XernerxSlashCommand.js +173 -177
  11. package/dist/client/XernerxClient.d.ts +55 -61
  12. package/dist/client/XernerxClient.js +94 -91
  13. package/dist/client/XernerxShardClient.d.ts +14 -14
  14. package/dist/client/XernerxShardClient.js +48 -61
  15. package/dist/functions/deploy.js +52 -45
  16. package/dist/functions/load.js +29 -28
  17. package/dist/functions/reload.js +24 -23
  18. package/dist/functions/setPresence.d.ts +1 -1
  19. package/dist/functions/setPresence.js +16 -17
  20. package/dist/handlers/CommandHandler.d.ts +10 -10
  21. package/dist/handlers/CommandHandler.js +337 -312
  22. package/dist/handlers/EventHandler.d.ts +5 -3
  23. package/dist/handlers/EventHandler.js +76 -48
  24. package/dist/handlers/ExtensionHandler.d.ts +3 -3
  25. package/dist/handlers/ExtensionHandler.js +23 -23
  26. package/dist/handlers/Handler.d.ts +17 -22
  27. package/dist/handlers/Handler.js +57 -45
  28. package/dist/handlers/InhibitorHandler.d.ts +3 -3
  29. package/dist/handlers/InhibitorHandler.js +23 -25
  30. package/dist/handlers/IntegrationHandler.d.ts +6 -6
  31. package/dist/handlers/IntegrationHandler.js +20 -20
  32. package/dist/main.d.ts +22 -29
  33. package/dist/main.js +22 -29
  34. package/dist/models/Arguments.d.ts +1 -4
  35. package/dist/models/Arguments.js +149 -134
  36. package/dist/models/Cooldowns.d.ts +6 -6
  37. package/dist/models/Cooldowns.js +29 -25
  38. package/dist/models/XernerxEntitlement.d.ts +45 -0
  39. package/dist/models/XernerxEntitlement.js +57 -0
  40. package/dist/models/XernerxUser.d.ts +14 -0
  41. package/dist/models/XernerxUser.js +13 -0
  42. package/dist/tools/XernerxError.d.ts +4 -4
  43. package/dist/tools/XernerxError.js +8 -8
  44. package/dist/tools/XernerxIntents.d.ts +2 -2
  45. package/dist/tools/XernerxIntents.js +21 -21
  46. package/dist/tools/XernerxLog.d.ts +25 -25
  47. package/dist/tools/XernerxLog.js +131 -140
  48. package/dist/tools/XernerxText.d.ts +23 -23
  49. package/dist/tools/XernerxText.js +89 -79
  50. package/dist/types/extenders.d.ts +47 -55
  51. package/dist/types/interfaces.d.ts +190 -195
  52. package/dist/types/types.d.ts +5 -104
  53. package/dist/utils/ClientUtil.d.ts +10 -12
  54. package/dist/utils/ClientUtil.js +117 -96
  55. package/dist/utils/InteractionUtil.d.ts +13 -13
  56. package/dist/utils/InteractionUtil.js +147 -148
  57. package/dist/utils/MessageUtil.d.ts +14 -14
  58. package/dist/utils/MessageUtil.js +161 -162
  59. package/dist/utils/Util.d.ts +7 -7
  60. package/dist/utils/Util.js +7 -7
  61. package/dist/validators/commandValidation.d.ts +1 -4
  62. package/dist/validators/commandValidation.js +114 -157
  63. package/dist/validators/inhibitorValidations.d.ts +2 -21
  64. package/dist/validators/inhibitorValidations.js +39 -39
  65. package/package.json +6 -5
  66. package/tsup.config.ts +19 -0
  67. package/dist/functions/xernerxUser.d.ts +0 -4
  68. package/dist/functions/xernerxUser.js +0 -10
@@ -1,168 +1,167 @@
1
1
  /** @format */
2
- import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder } from 'discord.js';
2
+ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, } from 'discord.js';
3
3
  import Util from './Util.js';
4
4
  import XernerxError from '../tools/XernerxError.js';
5
5
  import { Style } from 'dumfunctions';
6
6
  export default class MessageUtil extends Util {
7
- constructor(client, message) {
8
- super(client);
9
- this.message = message?.message || message;
10
- this.parsed = {
11
- alias: null,
12
- prefix: null,
13
- args: null,
14
- };
15
- }
16
- async send(content) {
17
- if (this.client.cache.messages.has(this.message.id) && this.client.modules.options.message?.handleEdits) {
18
- const id = this.client.cache.messages.get(this.message.id);
19
- if (!id) return null;
20
- const msg = await this.message.channel.messages.fetch(id);
21
- msg.edit(content);
22
- return msg;
23
- }
24
- const msg = await this.message.channel.send(content);
25
- this.client.cache.messages.set(this.message.id, msg.id);
26
- return msg;
27
- }
28
- async reply(content) {
29
- if (this.client.cache.messages.has(this.message.id) && this.client.modules.options.message?.handleEdits) {
30
- const id = this.client.cache.messages.get(this.message.id);
31
- if (!id) return null;
32
- const msg = await this.message.channel.messages.fetch(id);
33
- msg.edit(content);
34
- return msg;
35
- }
36
- const msg = await this.message.reply(content);
37
- this.client.cache.messages.set(this.message.id, msg.id);
38
- return msg;
39
- }
40
- async mimic(user, message, options) {
41
- user = typeof user == 'string' ? await this.client.users.fetch(user) : user;
42
- const webhooks = await this.message.channel.fetchWebhooks();
43
- const webhook =
44
- webhooks.find((wh) => wh.token) ||
45
- (await this.message.channel.createWebhook({
46
- name: `${this.client.user?.username}'s mimic webhook.`,
47
- avatar: user.displayAvatarURL() || this.client.user?.displayAvatarURL(),
48
- }));
49
- await webhook.send({
50
- content: message.content,
51
- username: user.username,
52
- avatarURL: user.displayAvatarURL(),
53
- });
54
- setTimeout(() => {
55
- webhook.delete().catch(() => true);
56
- }, options.timeout);
57
- }
58
- async paginator(embeds, options = {}) {
59
- let buttonRow, menuRow;
60
- if (embeds.length <= 0) throw new XernerxError(`Can't make a paginator without embeds`);
61
- options = {
62
- type: options.type ?? 'combined',
63
- buttons: options.buttons ?? ['⏪', '◀️', '⏹️', '▶️', '⏩'],
64
- description: options.description ?? false,
65
- placeholder: options.placeholder ?? 'Change page',
66
- index: options.index ?? 0,
67
- send: options.send ?? false,
68
- filter: options.filter ?? (() => true),
69
- time: options.time ?? 300000,
70
- };
71
- if (options.type == 'button' || options.type == 'combined') {
72
- if (!options.buttons) throw new XernerxError(`¯\\_(ツ)_/¯ Somehow there are no buttons? ¯\\_(ツ)_/¯`);
73
- buttonRow = new ActionRowBuilder().addComponents(
74
- ...options.buttons.map((button, i) => new ButtonBuilder().setCustomId(`${this.message.id}-${i}`).setEmoji(button).setStyle(ButtonStyle.Primary))
75
- );
76
- }
77
- if (options.type == 'select-menu' || options.type == 'combined') {
78
- menuRow = new ActionRowBuilder().addComponents(
79
- new StringSelectMenuBuilder()
80
- .setCustomId(`${this.message.id}-select-menu`)
81
- .setPlaceholder(options.placeholder)
82
- .addOptions(...embeds.map((embed, i) => ({ label: embed.data.title || 'No Title', description: (options.description ? embed.data.description : undefined) || undefined, value: `${i}` })))
83
- );
84
- }
85
- let index = options.index || 0;
86
- return options.send
87
- ? await this.message.util.send({
88
- embeds: [embeds[index]],
89
- components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
90
- })
91
- : await this.message.util
92
- .reply({
93
- embeds: [embeds[index]],
94
- components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
95
- })
96
- .then(async (msg) => {
97
- const collector = this.message.channel
98
- ?.createMessageComponentCollector({ time: options.time })
99
- .on('collect', (collect) => {
100
- if (!collect.customId.startsWith(this.message.id)) return;
101
- if (collect.customId.endsWith('select-menu')) {
102
- index = Number(collect.values[0]);
103
- collect.update({ embeds: [embeds[index]] });
104
- } else {
105
- const option = Number(collect.customId.split(/-/)[1]);
106
- let embed = embeds[index];
107
- if (option == 0) {
108
- index = 0;
109
- embed = embeds[index];
110
- collect.update({ embeds: [embed] });
111
- }
112
- if (option == 1) {
113
- index = embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0;
114
- embed = embeds[index];
115
- collect.update({ embeds: [embed] });
116
- }
117
- if (option == 2) {
118
- collect.update({ components: [] });
119
- collector?.stop();
120
- }
121
- if (option == 3) {
122
- index = embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1;
123
- embed = embeds[index];
124
- collect.update({ embeds: [embed] });
125
- }
126
- if (option == 4) {
127
- index = embeds.length - 1;
128
- embed = embeds[index];
129
- collect.update({ embeds: [embed] });
130
- }
131
- }
132
- })
133
- .on('end', async () => {
134
- await msg?.edit({ components: [] });
135
- });
136
- });
137
- }
138
- commands() {
139
- return this.client.commands.message;
140
- }
141
- permissionCheck(type, permissions, emit = true) {
142
- const missing = [];
143
- for (const permission of permissions) {
144
- if (type == 'user') {
145
- this.message.member?.permissionsIn(this.message.channel.id).has(Style.pascalCase(permission, true)) ? null : missing.push(permission);
146
- }
147
- if (type == 'client') {
148
- this.message.guild?.members.me?.permissionsIn(this.message.channel.id).has(Style.pascalCase(permission, true)) ? null : missing.push(permission);
149
- }
150
- }
151
- const command = this.commands().find((cmd) => cmd.name == this.parsed.alias || cmd.aliases?.includes(this.parsed.alias));
152
- if (missing.length && emit) {
153
- this.client.emit(
154
- `commandBlock`,
155
- this.message,
156
- {
157
- reason: `missing${Style.pascalCase(type)}Permissions`,
158
- message: `${type == 'user' ? 'You are' : 'I am'} missing the following permissions to run \`${command?.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
159
- required: permissions,
160
- missing,
161
- },
162
- command || null
163
- );
164
- return false;
165
- } else if (missing.length && !emit) return missing;
166
- else return true;
167
- }
7
+ constructor(client, message) {
8
+ super(client);
9
+ this.message = message?.message || message;
10
+ this.parsed = {
11
+ alias: null,
12
+ prefix: null,
13
+ args: null,
14
+ };
15
+ }
16
+ async send(content) {
17
+ if (this.client.cache.messages.has(this.message.id) && this.client.modules.options.message?.handleEdits) {
18
+ const id = this.client.cache.messages.get(this.message.id);
19
+ if (!id)
20
+ return null;
21
+ const msg = await this.message.channel.messages.fetch(id);
22
+ msg.edit(content);
23
+ return msg;
24
+ }
25
+ const msg = await this.message.channel.send(content);
26
+ this.client.cache.messages.set(this.message.id, msg.id);
27
+ return msg;
28
+ }
29
+ async reply(content) {
30
+ if (this.client.cache.messages.has(this.message.id) && this.client.modules.options.message?.handleEdits) {
31
+ const id = this.client.cache.messages.get(this.message.id);
32
+ if (!id)
33
+ return null;
34
+ const msg = await this.message.channel.messages.fetch(id);
35
+ msg.edit(content);
36
+ return msg;
37
+ }
38
+ const msg = await this.message.reply(content);
39
+ this.client.cache.messages.set(this.message.id, msg.id);
40
+ return msg;
41
+ }
42
+ async mimic(user, message, options) {
43
+ user = (typeof user == 'string' ? (await this.client.users.fetch(user)) : user);
44
+ const webhooks = await this.message.channel.fetchWebhooks();
45
+ const webhook = webhooks.find((wh) => wh.token) ||
46
+ (await this.message.channel.createWebhook({
47
+ name: `${this.client.user?.username}'s mimic webhook.`,
48
+ avatar: user.displayAvatarURL() || this.client.user?.displayAvatarURL(),
49
+ }));
50
+ await webhook.send({
51
+ content: message.content,
52
+ username: user.username,
53
+ avatarURL: user.displayAvatarURL(),
54
+ });
55
+ setTimeout(() => {
56
+ webhook.delete().catch(() => true);
57
+ }, options.timeout);
58
+ }
59
+ async paginator(embeds, options = {}) {
60
+ let buttonRow, menuRow;
61
+ if (embeds.length <= 0)
62
+ throw new XernerxError(`Can't make a paginator without embeds`);
63
+ options = {
64
+ type: options.type ?? 'combined',
65
+ buttons: options.buttons ?? ['⏪', '◀️', '⏹️', '▶️', '⏩'],
66
+ description: options.description ?? false,
67
+ placeholder: options.placeholder ?? 'Change page',
68
+ index: options.index ?? 0,
69
+ send: options.send ?? false,
70
+ filter: options.filter ?? (() => true),
71
+ time: options.time ?? 300000,
72
+ };
73
+ if (options.type == 'button' || options.type == 'combined') {
74
+ if (!options.buttons)
75
+ throw new XernerxError(`¯\\_(ツ)_/¯ Somehow there are no buttons? ¯\\_(ツ)_/¯`);
76
+ buttonRow = new ActionRowBuilder().addComponents(...options.buttons.map((button, i) => new ButtonBuilder().setCustomId(`${this.message.id}-${i}`).setEmoji(button).setStyle(ButtonStyle.Primary)));
77
+ }
78
+ if (options.type == 'select-menu' || options.type == 'combined') {
79
+ menuRow = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder()
80
+ .setCustomId(`${this.message.id}-select-menu`)
81
+ .setPlaceholder(options.placeholder)
82
+ .addOptions(...embeds.map((embed, i) => ({ label: embed.data.title || 'No Title', description: (options.description ? embed.data.description : undefined) || undefined, value: `${i}` }))));
83
+ }
84
+ let index = options.index || 0;
85
+ return options.send
86
+ ? await this.message.util.send({
87
+ embeds: [embeds[index]],
88
+ components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
89
+ })
90
+ : await this.message.util
91
+ .reply({
92
+ embeds: [embeds[index]],
93
+ components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
94
+ })
95
+ .then(async (msg) => {
96
+ const collector = this.message.channel
97
+ ?.createMessageComponentCollector({ time: options.time })
98
+ .on('collect', (collect) => {
99
+ if (!collect.customId.startsWith(this.message.id))
100
+ return;
101
+ if (collect.customId.endsWith('select-menu')) {
102
+ index = Number(collect.values[0]);
103
+ collect.update({ embeds: [embeds[index]] });
104
+ }
105
+ else {
106
+ const option = Number(collect.customId.split(/-/)[1]);
107
+ let embed = embeds[index];
108
+ if (option == 0) {
109
+ index = 0;
110
+ embed = embeds[index];
111
+ collect.update({ embeds: [embed] });
112
+ }
113
+ if (option == 1) {
114
+ index = embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0;
115
+ embed = embeds[index];
116
+ collect.update({ embeds: [embed] });
117
+ }
118
+ if (option == 2) {
119
+ collect.update({ components: [] });
120
+ collector?.stop();
121
+ }
122
+ if (option == 3) {
123
+ index = embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1;
124
+ embed = embeds[index];
125
+ collect.update({ embeds: [embed] });
126
+ }
127
+ if (option == 4) {
128
+ index = embeds.length - 1;
129
+ embed = embeds[index];
130
+ collect.update({ embeds: [embed] });
131
+ }
132
+ }
133
+ })
134
+ .on('end', async () => {
135
+ await msg?.edit({ components: [] });
136
+ });
137
+ });
138
+ }
139
+ commands() {
140
+ return this.client.commands.message;
141
+ }
142
+ permissionCheck(type, permissions, emit = true) {
143
+ const missing = [];
144
+ for (const permission of permissions) {
145
+ if (type == 'user') {
146
+ this.message.member?.permissionsIn(this.message.channel.id).has(Style.pascalCase(permission, true)) ? null : missing.push(permission);
147
+ }
148
+ if (type == 'client') {
149
+ this.message.guild?.members.me?.permissionsIn(this.message.channel.id).has(Style.pascalCase(permission, true)) ? null : missing.push(permission);
150
+ }
151
+ }
152
+ const command = this.commands().find((cmd) => cmd.name == this.parsed.alias || cmd.aliases?.includes(this.parsed.alias));
153
+ if (missing.length && emit) {
154
+ this.client.emit(`commandBlock`, this.message, {
155
+ reason: `missing${Style.pascalCase(type)}Permissions`,
156
+ message: `${type == 'user' ? 'You are' : 'I am'} missing the following permissions to run \`${command?.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
157
+ required: permissions,
158
+ missing,
159
+ }, command || null);
160
+ return false;
161
+ }
162
+ else if (missing.length && !emit)
163
+ return missing;
164
+ else
165
+ return true;
166
+ }
168
167
  }
@@ -2,11 +2,11 @@
2
2
  import XernerxClient from '../client/XernerxClient.js';
3
3
  import XernerxText from '../tools/XernerxText.js';
4
4
  export default class Util {
5
- readonly client: XernerxClient<{
6
- [index: string]: any;
7
- [index: number]: any;
8
- }>;
9
- readonly text: XernerxText;
10
- constructor(client: XernerxClient);
11
- delay(time: number): Promise<unknown>;
5
+ readonly client: XernerxClient<{
6
+ [index: string]: any;
7
+ [index: number]: any;
8
+ }>;
9
+ readonly text: XernerxText;
10
+ constructor(client: XernerxClient);
11
+ delay(time: number): Promise<unknown>;
12
12
  }
@@ -1,11 +1,11 @@
1
1
  /** @format */
2
2
  import XernerxText from '../tools/XernerxText.js';
3
3
  export default class Util {
4
- constructor(client) {
5
- this.client = client;
6
- this.text = new XernerxText();
7
- }
8
- async delay(time) {
9
- return await new Promise((resolve) => setTimeout(resolve, time));
10
- }
4
+ constructor(client) {
5
+ this.client = client;
6
+ this.text = new XernerxText();
7
+ }
8
+ async delay(time) {
9
+ return await new Promise((resolve) => setTimeout(resolve, time));
10
+ }
11
11
  }
@@ -4,7 +4,4 @@ import MessageCommandBuilder from '../build/XernerxMessageCommand.js';
4
4
  import XernerxSlashCommand from '../build/XernerxSlashCommand.js';
5
5
  import { XernerxMessage, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
6
6
  import { XernerxInteraction } from '../types/types.js';
7
- export default function commandValidation(
8
- event: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxUserContextInteraction> | XernerxMessage,
9
- command: MessageCommandBuilder | XernerxSlashCommand | XernerxContextCommand
10
- ): Promise<boolean>;
7
+ export default function commandValidation(event: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxUserContextInteraction> | XernerxMessage, command: MessageCommandBuilder | XernerxSlashCommand | XernerxContextCommand): Promise<boolean>;