xernerx 4.17.3 → 4.17.5

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 (62) hide show
  1. package/dist/build/XernerxContextCommand.d.ts +75 -47
  2. package/dist/build/XernerxContextCommand.js +119 -115
  3. package/dist/build/XernerxEvent.d.ts +10 -10
  4. package/dist/build/XernerxEvent.js +17 -17
  5. package/dist/build/XernerxInhibitor.d.ts +39 -15
  6. package/dist/build/XernerxInhibitor.js +18 -18
  7. package/dist/build/XernerxMessageCommand.d.ts +78 -52
  8. package/dist/build/XernerxMessageCommand.js +118 -114
  9. package/dist/build/XernerxSlashCommand.d.ts +96 -62
  10. package/dist/build/XernerxSlashCommand.js +176 -172
  11. package/dist/client/XernerxClient.d.ts +55 -45
  12. package/dist/client/XernerxClient.js +83 -88
  13. package/dist/client/XernerxShardClient.d.ts +14 -14
  14. package/dist/client/XernerxShardClient.js +61 -47
  15. package/dist/functions/deploy.js +45 -52
  16. package/dist/functions/load.js +28 -29
  17. package/dist/functions/reload.js +23 -24
  18. package/dist/functions/setPresence.d.ts +1 -1
  19. package/dist/functions/setPresence.js +17 -16
  20. package/dist/functions/xernerxUser.js +5 -6
  21. package/dist/handlers/CommandHandler.d.ts +10 -10
  22. package/dist/handlers/CommandHandler.js +311 -336
  23. package/dist/handlers/EventHandler.d.ts +3 -3
  24. package/dist/handlers/EventHandler.js +48 -21
  25. package/dist/handlers/ExtensionHandler.d.ts +3 -3
  26. package/dist/handlers/ExtensionHandler.js +23 -23
  27. package/dist/handlers/Handler.d.ts +19 -14
  28. package/dist/handlers/Handler.js +46 -50
  29. package/dist/handlers/InhibitorHandler.d.ts +3 -3
  30. package/dist/handlers/InhibitorHandler.js +25 -23
  31. package/dist/handlers/IntegrationHandler.d.ts +6 -6
  32. package/dist/handlers/IntegrationHandler.js +20 -20
  33. package/dist/main.d.ts +28 -21
  34. package/dist/main.js +28 -21
  35. package/dist/models/Arguments.d.ts +4 -1
  36. package/dist/models/Arguments.js +134 -149
  37. package/dist/models/Cooldowns.d.ts +6 -6
  38. package/dist/models/Cooldowns.js +25 -29
  39. package/dist/tools/XernerxError.d.ts +4 -4
  40. package/dist/tools/XernerxError.js +8 -8
  41. package/dist/tools/XernerxIntents.d.ts +2 -2
  42. package/dist/tools/XernerxIntents.js +21 -21
  43. package/dist/tools/XernerxLog.d.ts +23 -23
  44. package/dist/tools/XernerxLog.js +125 -110
  45. package/dist/tools/XernerxText.d.ts +23 -23
  46. package/dist/tools/XernerxText.js +79 -89
  47. package/dist/types/extenders.d.ts +55 -47
  48. package/dist/types/interfaces.d.ts +192 -189
  49. package/dist/types/types.d.ts +104 -5
  50. package/dist/utils/ClientUtil.d.ts +12 -9
  51. package/dist/utils/ClientUtil.js +96 -79
  52. package/dist/utils/InteractionUtil.d.ts +13 -13
  53. package/dist/utils/InteractionUtil.js +148 -147
  54. package/dist/utils/MessageUtil.d.ts +14 -14
  55. package/dist/utils/MessageUtil.js +162 -161
  56. package/dist/utils/Util.d.ts +4 -4
  57. package/dist/utils/Util.js +7 -7
  58. package/dist/validators/commandValidation.d.ts +4 -1
  59. package/dist/validators/commandValidation.js +157 -114
  60. package/dist/validators/inhibitorValidations.d.ts +21 -2
  61. package/dist/validators/inhibitorValidations.js +39 -39
  62. package/package.json +3 -3
@@ -1,154 +1,139 @@
1
1
  /** @format */
2
2
  export async function messageArguments(message, command, prefix) {
3
- const separator = command.separator || ' ', content = message.content
4
- .replace(new RegExp(`${prefix} +?`), '')
5
- .split(separator)
6
- .slice(1);
7
- let args = {}, flags = {};
8
- if (command.flags)
9
- command.flags.map((flag) => {
10
- if (!flags)
11
- flags = {};
12
- if (content.includes(flag.match))
13
- flags[flag.name] = true;
14
- else
15
- flags[flag.name] = false;
16
- const index = content.indexOf(flag.match);
17
- if (index > 0)
18
- content.splice(index, 1);
19
- });
20
- if (command.args)
21
- for (const argument of command.args) {
22
- const element = content.at(0) || null;
23
- if (!element) {
24
- if (typeof argument.default === 'function')
25
- args[argument.name] = argument.default(message);
26
- args[argument.name] = argument.default || null;
27
- continue;
28
- }
29
- if (argument.type === 'option')
30
- argument.match?.includes(element) ? (args[argument.name] = element) : (args[argument.name] = null);
31
- if (argument.type === 'number')
32
- args[argument.name] = parseInt(element);
33
- if (argument.type === 'integer')
34
- args[argument.name] = parseInt(element);
35
- if (argument.type === 'boolean')
36
- args[argument.name] = element === 'true' ? true : false;
37
- if (argument.type === 'confirm')
38
- args[argument.name] = element === 'yes' ? 'yes' : 'no';
39
- if (argument.type === 'string')
40
- args[argument.name] = element;
41
- if (argument.type === 'channel') {
42
- try {
43
- const channel = await message.client.channels.fetch(element);
44
- args[argument.name] = channel;
45
- }
46
- catch (e) {
47
- args[argument.name] = null;
48
- }
49
- }
50
- if (argument.type === 'guild') {
51
- try {
52
- const guild = await message.client.guilds.fetch(element);
53
- args[argument.name] = guild;
54
- }
55
- catch (e) {
56
- args[argument.name] = null;
57
- }
58
- }
59
- if (argument.type === 'mentionable') {
60
- (await Promise.all([message.guild?.roles, message.client.users, message.client.guilds, message.client.channels, message.guild?.members, message.channel.messages].map((req) => req
61
- ? req
62
- .fetch(element)
63
- .then((r) => r)
64
- .catch(() => null)
65
- : null))).map((mentionable) => {
66
- if (!args)
67
- args = {};
68
- if (mentionable)
69
- return (args[argument.name] = mentionable);
70
- else
71
- return (args[argument.name] = null);
72
- });
73
- }
74
- if (argument.type === 'role') {
75
- try {
76
- const role = await message.guild?.roles.fetch(element);
77
- args[argument.name] = role;
78
- }
79
- catch (e) {
80
- args[argument.name] = null;
81
- }
82
- }
83
- if (argument.type === 'user') {
84
- try {
85
- const user = await message.client.users.fetch(element);
86
- args[argument.name] = user;
87
- }
88
- catch (e) {
89
- args[argument.name] = null;
90
- }
91
- }
92
- if (argument.type === 'member') {
93
- try {
94
- const member = await message.guild?.members.fetch(element);
95
- args[argument.name] = member;
96
- }
97
- catch (e) {
98
- args[argument.name] = null;
99
- }
100
- }
101
- if (argument.type === 'message') {
102
- try {
103
- const msg = await message.channel?.messages.fetch(element);
104
- args[argument.name] = msg;
105
- }
106
- catch (e) {
107
- args[argument.name] = null;
108
- }
109
- }
110
- if (argument.type === 'list') {
111
- let separator = String(argument.separator) || ',';
112
- if (separator.startsWith('/') && separator.endsWith('/'))
113
- separator = separator.replace(/^\/|\/$/gim, '');
114
- const items = content.join(' ').split(new RegExp(' *' + separator + ' *', 'gi'));
115
- if (!argument.content)
116
- args[argument.name] = items;
117
- else {
118
- const contents = argument.content.map((content) => content.toLowerCase()), itemList = [];
119
- items.map((item) => (contents.includes(item.toLowerCase()) ? itemList.push(argument.content?.at(contents.indexOf(item.toLowerCase()))) : null));
120
- args[argument.name] = itemList;
121
- break;
122
- }
123
- }
124
- if (argument.type === 'rest') {
125
- args[argument.name] = content.join(separator);
126
- break;
127
- }
128
- content.splice(0, 1);
129
- }
130
- if (!command.flags)
131
- flags = null;
132
- if (!command.args)
133
- args = null;
134
- return { args, flags };
3
+ const separator = command.separator || ' ',
4
+ content = message.content
5
+ .replace(new RegExp(`${prefix} +?`), '')
6
+ .split(separator)
7
+ .slice(1);
8
+ let args = {},
9
+ flags = {};
10
+ if (command.flags)
11
+ command.flags.map((flag) => {
12
+ if (!flags) flags = {};
13
+ if (content.includes(flag.match)) flags[flag.name] = true;
14
+ else flags[flag.name] = false;
15
+ const index = content.indexOf(flag.match);
16
+ if (index > 0) content.splice(index, 1);
17
+ });
18
+ if (command.args)
19
+ for (const argument of command.args) {
20
+ const element = content.at(0) || null;
21
+ if (!element) {
22
+ if (typeof argument.default === 'function') args[argument.name] = argument.default(message);
23
+ args[argument.name] = argument.default || null;
24
+ continue;
25
+ }
26
+ if (argument.type === 'option') argument.match?.includes(element) ? (args[argument.name] = element) : (args[argument.name] = null);
27
+ if (argument.type === 'number') args[argument.name] = parseInt(element);
28
+ if (argument.type === 'integer') args[argument.name] = parseInt(element);
29
+ if (argument.type === 'boolean') args[argument.name] = element === 'true' ? true : false;
30
+ if (argument.type === 'confirm') args[argument.name] = element === 'yes' ? 'yes' : 'no';
31
+ if (argument.type === 'string') args[argument.name] = element;
32
+ if (argument.type === 'channel') {
33
+ try {
34
+ const channel = await message.client.channels.fetch(element);
35
+ args[argument.name] = channel;
36
+ } catch (e) {
37
+ args[argument.name] = null;
38
+ }
39
+ }
40
+ if (argument.type === 'guild') {
41
+ try {
42
+ const guild = await message.client.guilds.fetch(element);
43
+ args[argument.name] = guild;
44
+ } catch (e) {
45
+ args[argument.name] = null;
46
+ }
47
+ }
48
+ if (argument.type === 'mentionable') {
49
+ (
50
+ await Promise.all(
51
+ [message.guild?.roles, message.client.users, message.client.guilds, message.client.channels, message.guild?.members, message.channel.messages].map((req) =>
52
+ req
53
+ ? req
54
+ .fetch(element)
55
+ .then((r) => r)
56
+ .catch(() => null)
57
+ : null
58
+ )
59
+ )
60
+ ).map((mentionable) => {
61
+ if (!args) args = {};
62
+ if (mentionable) return (args[argument.name] = mentionable);
63
+ else return (args[argument.name] = null);
64
+ });
65
+ }
66
+ if (argument.type === 'role') {
67
+ try {
68
+ const role = await message.guild?.roles.fetch(element);
69
+ args[argument.name] = role;
70
+ } catch (e) {
71
+ args[argument.name] = null;
72
+ }
73
+ }
74
+ if (argument.type === 'user') {
75
+ try {
76
+ const user = await message.client.users.fetch(element);
77
+ args[argument.name] = user;
78
+ } catch (e) {
79
+ args[argument.name] = null;
80
+ }
81
+ }
82
+ if (argument.type === 'member') {
83
+ try {
84
+ const member = await message.guild?.members.fetch(element);
85
+ args[argument.name] = member;
86
+ } catch (e) {
87
+ args[argument.name] = null;
88
+ }
89
+ }
90
+ if (argument.type === 'message') {
91
+ try {
92
+ const msg = await message.channel?.messages.fetch(element);
93
+ args[argument.name] = msg;
94
+ } catch (e) {
95
+ args[argument.name] = null;
96
+ }
97
+ }
98
+ if (argument.type === 'list') {
99
+ let separator = String(argument.separator) || ',';
100
+ if (separator.startsWith('/') && separator.endsWith('/')) separator = separator.replace(/^\/|\/$/gim, '');
101
+ const items = content.join(' ').split(new RegExp(' *' + separator + ' *', 'gi'));
102
+ if (!argument.content) args[argument.name] = items;
103
+ else {
104
+ const contents = argument.content.map((content) => content.toLowerCase()),
105
+ itemList = [];
106
+ items.map((item) => (contents.includes(item.toLowerCase()) ? itemList.push(argument.content?.at(contents.indexOf(item.toLowerCase()))) : null));
107
+ args[argument.name] = itemList;
108
+ break;
109
+ }
110
+ }
111
+ if (argument.type === 'rest') {
112
+ args[argument.name] = content.join(separator);
113
+ break;
114
+ }
115
+ content.splice(0, 1);
116
+ }
117
+ if (!command.flags) flags = null;
118
+ if (!command.args) args = null;
119
+ return { args, flags };
135
120
  }
136
121
  export async function interactionArguments(interaction, command) {
137
- if (command.filetype === 'SlashCommand') {
138
- const options = {};
139
- let args = interaction?.options?._hoistedOptions, group = interaction?.options?._group, subcommand = interaction?.options?._subcommand;
140
- if (interaction.options._hoistedOptions) {
141
- for (const option of interaction.options._hoistedOptions) {
142
- options[option.name] = option.member || option.channel || option.user || option.role || option.value;
143
- }
144
- args = options;
145
- }
146
- return { args, group, subcommand };
147
- }
148
- if (command.filetype === 'ContextCommand') {
149
- if (command.type === 'user')
150
- return await interaction.client.users.fetch(interaction.targetId);
151
- if (command.type === 'message')
152
- return await interaction.channel.messages.fetch(interaction.targetId);
153
- }
122
+ if (command.filetype === 'SlashCommand') {
123
+ const options = {};
124
+ let args = interaction?.options?._hoistedOptions,
125
+ group = interaction?.options?._group,
126
+ subcommand = interaction?.options?._subcommand;
127
+ if (interaction.options._hoistedOptions) {
128
+ for (const option of interaction.options._hoistedOptions) {
129
+ options[option.name] = option.member || option.channel || option.user || option.role || option.value;
130
+ }
131
+ args = options;
132
+ }
133
+ return { args, group, subcommand };
134
+ }
135
+ if (command.filetype === 'ContextCommand') {
136
+ if (command.type === 'user') return await interaction.client.users.fetch(interaction.targetId);
137
+ if (command.type === 'message') return await interaction.channel.messages.fetch(interaction.targetId);
138
+ }
154
139
  }
@@ -2,10 +2,10 @@
2
2
  import { Collection } from 'discord.js';
3
3
  import XernerxClient from '../client/XernerxClient.js';
4
4
  export default class Cooldowns {
5
- private readonly _client;
6
- readonly collections: Record<string, Collection<string, unknown>>;
7
- constructor(client: XernerxClient, collections?: Array<string>);
8
- add(collection: keyof typeof this.collections, id: string, value: unknown): string | Collection<string, unknown>;
9
- delete(collection: keyof typeof this.collections, id: string): string | boolean;
10
- has(id: string): Record<string, Collection<string, unknown>>;
5
+ private readonly _client;
6
+ readonly collections: Record<string, Collection<string, unknown>>;
7
+ constructor(client: XernerxClient, collections?: Array<string>);
8
+ add(collection: keyof typeof this.collections, id: string, value: unknown): string | Collection<string, unknown>;
9
+ delete(collection: keyof typeof this.collections, id: string): string | boolean;
10
+ has(id: string): Record<string, Collection<string, unknown>>;
11
11
  }
@@ -1,33 +1,29 @@
1
1
  /** @format */
2
2
  import { Collection } from 'discord.js';
3
3
  export default class Cooldowns {
4
- constructor(client, collections = []) {
5
- this._client = client;
6
- this.collections = {
7
- commands: new Collection(),
8
- };
9
- for (const collection of collections) {
10
- this.collections[collection] = new Collection();
11
- }
12
- }
13
- add(collection, id, value) {
14
- if (!this.collections[collection])
15
- return `${collection} collection does not exist!`;
16
- return this.collections[collection].set(id, value);
17
- }
18
- delete(collection, id) {
19
- if (!this.collections[collection])
20
- return `${collection} collection does not exist!`;
21
- return this.collections[collection].delete(id);
22
- }
23
- has(id) {
24
- const collected = {};
25
- for (const [name, collection] of Object.entries(this.collections)) {
26
- if (collection.has(id))
27
- collected[name] = collection;
28
- else
29
- continue;
30
- }
31
- return collected;
32
- }
4
+ constructor(client, collections = []) {
5
+ this._client = client;
6
+ this.collections = {
7
+ commands: new Collection(),
8
+ };
9
+ for (const collection of collections) {
10
+ this.collections[collection] = new Collection();
11
+ }
12
+ }
13
+ add(collection, id, value) {
14
+ if (!this.collections[collection]) return `${collection} collection does not exist!`;
15
+ return this.collections[collection].set(id, value);
16
+ }
17
+ delete(collection, id) {
18
+ if (!this.collections[collection]) return `${collection} collection does not exist!`;
19
+ return this.collections[collection].delete(id);
20
+ }
21
+ has(id) {
22
+ const collected = {};
23
+ for (const [name, collection] of Object.entries(this.collections)) {
24
+ if (collection.has(id)) collected[name] = collection;
25
+ else continue;
26
+ }
27
+ return collected;
28
+ }
33
29
  }
@@ -1,7 +1,7 @@
1
1
  /** @format */
2
2
  export default class XernerxError {
3
- name: string;
4
- message: string | null;
5
- stack: {} | undefined;
6
- constructor(message?: string, error?: Error | unknown);
3
+ name: string;
4
+ message: string | null;
5
+ stack: {} | undefined;
6
+ constructor(message?: string, error?: Error | unknown);
7
7
  }
@@ -1,11 +1,11 @@
1
1
  /** @format */
2
2
  export default class XernerxError {
3
- name;
4
- message;
5
- stack;
6
- constructor(message, error) {
7
- this.name = 'XernerxError';
8
- this.message = message || null;
9
- this.stack = error || new Error().stack;
10
- }
3
+ name;
4
+ message;
5
+ stack;
6
+ constructor(message, error) {
7
+ this.name = 'XernerxError';
8
+ this.message = message || null;
9
+ this.stack = error || new Error().stack;
10
+ }
11
11
  }
@@ -1,6 +1,6 @@
1
1
  /** @format */
2
2
  import { GatewayIntentBits } from 'discord.js';
3
3
  export declare const XernerxIntents: {
4
- Default: GatewayIntentBits[];
5
- All: GatewayIntentBits[];
4
+ Default: GatewayIntentBits[];
5
+ All: GatewayIntentBits[];
6
6
  };
@@ -1,26 +1,26 @@
1
1
  /** @format */
2
2
  import { GatewayIntentBits } from 'discord.js';
3
3
  export const XernerxIntents = {
4
- Default: [
5
- GatewayIntentBits.Guilds,
6
- GatewayIntentBits.GuildModeration,
7
- GatewayIntentBits.GuildBans,
8
- GatewayIntentBits.GuildModeration,
9
- GatewayIntentBits.GuildEmojisAndStickers,
10
- GatewayIntentBits.GuildIntegrations,
11
- GatewayIntentBits.GuildWebhooks,
12
- GatewayIntentBits.GuildInvites,
13
- GatewayIntentBits.GuildVoiceStates,
14
- GatewayIntentBits.GuildMessages,
15
- GatewayIntentBits.GuildMessageReactions,
16
- GatewayIntentBits.GuildMessageTyping,
17
- GatewayIntentBits.DirectMessages,
18
- GatewayIntentBits.DirectMessageReactions,
19
- GatewayIntentBits.DirectMessageTyping,
20
- GatewayIntentBits.GuildScheduledEvents,
21
- GatewayIntentBits.AutoModerationConfiguration,
22
- GatewayIntentBits.AutoModerationExecution,
23
- ],
24
- All: [GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildPresences, GatewayIntentBits.MessageContent],
4
+ Default: [
5
+ GatewayIntentBits.Guilds,
6
+ GatewayIntentBits.GuildModeration,
7
+ GatewayIntentBits.GuildBans,
8
+ GatewayIntentBits.GuildModeration,
9
+ GatewayIntentBits.GuildEmojisAndStickers,
10
+ GatewayIntentBits.GuildIntegrations,
11
+ GatewayIntentBits.GuildWebhooks,
12
+ GatewayIntentBits.GuildInvites,
13
+ GatewayIntentBits.GuildVoiceStates,
14
+ GatewayIntentBits.GuildMessages,
15
+ GatewayIntentBits.GuildMessageReactions,
16
+ GatewayIntentBits.GuildMessageTyping,
17
+ GatewayIntentBits.DirectMessages,
18
+ GatewayIntentBits.DirectMessageReactions,
19
+ GatewayIntentBits.DirectMessageTyping,
20
+ GatewayIntentBits.GuildScheduledEvents,
21
+ GatewayIntentBits.AutoModerationConfiguration,
22
+ GatewayIntentBits.AutoModerationExecution,
23
+ ],
24
+ All: [GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildPresences, GatewayIntentBits.MessageContent],
25
25
  };
26
26
  XernerxIntents.All.push(...XernerxIntents.Default);
@@ -3,27 +3,27 @@ import XernerxError from './XernerxError.js';
3
3
  import XernerxClient from '../client/XernerxClient.js';
4
4
  import { XernerxClientType } from '../types/extenders.js';
5
5
  export default class XernerxLog {
6
- private readonly client;
7
- private readonly errorLog;
8
- private readonly infoLog;
9
- private readonly warnLog;
10
- private readonly readyLog;
11
- private readonly tableLog;
12
- private readonly format;
13
- private readonly time;
14
- private readonly ram;
15
- private shard;
16
- private readonly base;
17
- constructor(client: XernerxClient | XernerxClientType | true);
18
- info(message: string, force?: boolean): void | null;
19
- warn(message: string): void | null;
20
- update(version: string, url: string): Promise<void>;
21
- error(message: string, error?: XernerxError | unknown): void | null;
22
- ready(): void;
23
- private cyan;
24
- private blue;
25
- private yellow;
26
- private purple;
27
- private red;
28
- private green;
6
+ private readonly client;
7
+ private readonly errorLog;
8
+ private readonly infoLog;
9
+ private readonly warnLog;
10
+ private readonly readyLog;
11
+ private readonly tableLog;
12
+ private readonly format;
13
+ private readonly time;
14
+ private readonly ram;
15
+ private shard;
16
+ private readonly base;
17
+ constructor(client: XernerxClient | XernerxClientType | true);
18
+ info(message: string, force?: boolean): void | null;
19
+ warn(message: string): void | null;
20
+ update(version: string, url: string): Promise<void>;
21
+ error(message: string, error?: XernerxError | unknown): void | null;
22
+ ready(): void;
23
+ private cyan;
24
+ private blue;
25
+ private yellow;
26
+ private purple;
27
+ private red;
28
+ private green;
29
29
  }