xernerx 4.5.5 → 4.5.7

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 (106) hide show
  1. package/dist/build/XernerxContextCommand.d.ts +46 -44
  2. package/dist/build/XernerxContextCommand.js +64 -62
  3. package/dist/build/XernerxEvent.d.ts +16 -14
  4. package/dist/build/XernerxEvent.js +21 -19
  5. package/dist/build/XernerxInhibitor.d.ts +19 -17
  6. package/dist/build/XernerxInhibitor.js +13 -11
  7. package/dist/build/XernerxMessageCommand.d.ts +44 -42
  8. package/dist/build/XernerxMessageCommand.js +58 -56
  9. package/dist/build/XernerxSlashCommand.d.ts +56 -54
  10. package/dist/build/XernerxSlashCommand.js +110 -108
  11. package/dist/client/XernerxClient.d.ts +46 -44
  12. package/dist/client/XernerxClient.js +75 -73
  13. package/dist/client/XernerxShardClient.d.ts +12 -10
  14. package/dist/client/XernerxShardClient.js +50 -48
  15. package/dist/functions/deploy.d.ts +2 -0
  16. package/dist/functions/deploy.js +32 -30
  17. package/dist/functions/load.d.ts +2 -0
  18. package/dist/functions/load.js +29 -27
  19. package/dist/functions/reload.d.ts +2 -0
  20. package/dist/functions/reload.js +36 -34
  21. package/dist/functions/sendWebhook.d.ts +2 -0
  22. package/dist/functions/sendWebhook.js +12 -10
  23. package/dist/functions/setPresence.d.ts +2 -0
  24. package/dist/functions/setPresence.js +19 -17
  25. package/dist/functions/xernerxUser.d.ts +2 -0
  26. package/dist/functions/xernerxUser.js +10 -8
  27. package/dist/handlers/CommandHandler.d.ts +10 -8
  28. package/dist/handlers/CommandHandler.js +241 -239
  29. package/dist/handlers/EventHandler.d.ts +4 -2
  30. package/dist/handlers/EventHandler.js +20 -18
  31. package/dist/handlers/ExtensionHandler.d.ts +4 -2
  32. package/dist/handlers/ExtensionHandler.js +19 -17
  33. package/dist/handlers/Handler.d.ts +9 -7
  34. package/dist/handlers/Handler.js +33 -31
  35. package/dist/handlers/InhibitorHandler.d.ts +4 -2
  36. package/dist/handlers/InhibitorHandler.js +20 -18
  37. package/dist/handlers/WebhookHandler.d.ts +5 -3
  38. package/dist/handlers/WebhookHandler.js +48 -46
  39. package/dist/main.d.ts +28 -26
  40. package/dist/main.js +28 -26
  41. package/dist/models/Arguments.d.ts +4 -2
  42. package/dist/models/Arguments.js +136 -134
  43. package/dist/tools/XernerxError.d.ts +6 -4
  44. package/dist/tools/XernerxError.js +10 -8
  45. package/dist/tools/XernerxLog.d.ts +14 -12
  46. package/dist/tools/XernerxLog.js +77 -80
  47. package/dist/tools/XernerxLog.js.map +1 -1
  48. package/dist/types/extenders.d.ts +13 -11
  49. package/dist/types/extenders.js +2 -0
  50. package/dist/types/interfaces.d.ts +184 -172
  51. package/dist/types/interfaces.d.ts.map +1 -1
  52. package/dist/types/interfaces.js +2 -0
  53. package/dist/types/interfaces.js.map +1 -1
  54. package/dist/types/types.d.ts +173 -171
  55. package/dist/types/types.js +2 -0
  56. package/dist/utils/ClientUtil.d.ts +8 -5
  57. package/dist/utils/ClientUtil.d.ts.map +1 -1
  58. package/dist/utils/ClientUtil.js +45 -26
  59. package/dist/utils/ClientUtil.js.map +1 -1
  60. package/dist/utils/InteractionUtil.d.ts +11 -5
  61. package/dist/utils/InteractionUtil.d.ts.map +1 -1
  62. package/dist/utils/InteractionUtil.js +98 -8
  63. package/dist/utils/InteractionUtil.js.map +1 -1
  64. package/dist/utils/MessageUtil.d.ts +14 -9
  65. package/dist/utils/MessageUtil.d.ts.map +1 -1
  66. package/dist/utils/MessageUtil.js +131 -37
  67. package/dist/utils/MessageUtil.js.map +1 -1
  68. package/dist/utils/Util.d.ts +5 -3
  69. package/dist/utils/Util.js +9 -7
  70. package/dist/validators/commandValidation.d.ts +4 -2
  71. package/dist/validators/commandValidation.js +44 -42
  72. package/dist/validators/inhibitorValidations.d.ts +16 -14
  73. package/dist/validators/inhibitorValidations.js +32 -30
  74. package/package.json +1 -1
  75. package/dist/build/ContextCommandBuilder.d.ts +0 -51
  76. package/dist/build/ContextCommandBuilder.d.ts.map +0 -1
  77. package/dist/build/ContextCommandBuilder.js +0 -68
  78. package/dist/build/ContextCommandBuilder.js.map +0 -1
  79. package/dist/build/EventBuilder.d.ts +0 -25
  80. package/dist/build/EventBuilder.d.ts.map +0 -1
  81. package/dist/build/EventBuilder.js +0 -30
  82. package/dist/build/EventBuilder.js.map +0 -1
  83. package/dist/build/InhibitorBuilder.d.ts +0 -29
  84. package/dist/build/InhibitorBuilder.d.ts.map +0 -1
  85. package/dist/build/InhibitorBuilder.js +0 -21
  86. package/dist/build/InhibitorBuilder.js.map +0 -1
  87. package/dist/build/MessageCommandBuilder.d.ts +0 -48
  88. package/dist/build/MessageCommandBuilder.d.ts.map +0 -1
  89. package/dist/build/MessageCommandBuilder.js +0 -61
  90. package/dist/build/MessageCommandBuilder.js.map +0 -1
  91. package/dist/build/SlashCommandBuilder.d.ts +0 -62
  92. package/dist/build/SlashCommandBuilder.d.ts.map +0 -1
  93. package/dist/build/SlashCommandBuilder.js +0 -114
  94. package/dist/build/SlashCommandBuilder.js.map +0 -1
  95. package/dist/functions/delay.d.ts +0 -2
  96. package/dist/functions/delay.d.ts.map +0 -1
  97. package/dist/functions/delay.js +0 -4
  98. package/dist/functions/delay.js.map +0 -1
  99. package/dist/functions/isOwner.d.ts +0 -4
  100. package/dist/functions/isOwner.d.ts.map +0 -1
  101. package/dist/functions/isOwner.js +0 -2
  102. package/dist/functions/isOwner.js.map +0 -1
  103. package/dist/functions/isVoter.d.ts +0 -4
  104. package/dist/functions/isVoter.d.ts.map +0 -1
  105. package/dist/functions/isVoter.js +0 -6
  106. package/dist/functions/isVoter.js.map +0 -1
@@ -1,37 +1,39 @@
1
+ /** @format */
2
+
1
3
  import * as fs from 'fs';
2
4
  import * as path from 'path';
3
5
  import load from '../functions/load.js';
4
6
  export default class Handler {
5
- client;
6
- files;
7
- readyTimestamp;
8
- constructor(client) {
9
- this.client = client;
10
- this.files = [];
11
- this.readyTimestamp = Number(Date.now());
12
- }
13
- readdir(dir) {
14
- try {
15
- return fs.readdirSync(path.resolve(dir)).filter((file) => file.endsWith('.js'));
16
- } catch (error) {
17
- console.error(error);
18
- }
19
- return [];
20
- }
21
- async load(filePath, type) {
22
- const file = await load(this.client, filePath, type);
23
- this.files.push(file);
24
- return file;
25
- }
26
- async emit(event) {
27
- if (!event?.fileType) return;
28
- if (event.fileType === 'Event') {
29
- if (event.emitter === 'client') event.once ? this.client.once(event.name, (...args) => event.run(...args)) : this.client.on(event.name, (...args) => event.run(...args));
30
- else if (event.emitter === 'process') event.once ? process.once(event.name, (...args) => event.run(...args)) : process.on(event.name, (...args) => event.run(...args));
31
- }
32
- if (['MessageCommand', 'SlashCommand', 'ContextCommand'].includes(event.fileType)) {
33
- event.once ? this.client.once(event.name, (...args) => event.run(...args)) : this.client.on(event.name, (...args) => event.run(...args));
34
- }
35
- }
7
+ client;
8
+ files;
9
+ readyTimestamp;
10
+ constructor(client) {
11
+ this.client = client;
12
+ this.files = [];
13
+ this.readyTimestamp = Number(Date.now());
14
+ }
15
+ readdir(dir) {
16
+ try {
17
+ return fs.readdirSync(path.resolve(dir)).filter((file) => file.endsWith('.js'));
18
+ } catch (error) {
19
+ console.error(error);
20
+ }
21
+ return [];
22
+ }
23
+ async load(filePath, type) {
24
+ const file = await load(this.client, filePath, type);
25
+ this.files.push(file);
26
+ return file;
27
+ }
28
+ async emit(event) {
29
+ if (!event?.fileType) return;
30
+ if (event.fileType === 'Event') {
31
+ if (event.emitter === 'client') event.once ? this.client.once(event.name, (...args) => event.run(...args)) : this.client.on(event.name, (...args) => event.run(...args));
32
+ else if (event.emitter === 'process') event.once ? process.once(event.name, (...args) => event.run(...args)) : process.on(event.name, (...args) => event.run(...args));
33
+ }
34
+ if (['MessageCommand', 'SlashCommand', 'ContextCommand'].includes(event.fileType)) {
35
+ event.once ? this.client.once(event.name, (...args) => event.run(...args)) : this.client.on(event.name, (...args) => event.run(...args));
36
+ }
37
+ }
36
38
  }
37
39
  //# sourceMappingURL=Handler.js.map
@@ -1,8 +1,10 @@
1
+ /** @format */
2
+
1
3
  import XernerxClient from '../client/XernerxClient.js';
2
4
  import Handler from './Handler.js';
3
5
  import { InhibitorHandlerOptions } from '../types/interfaces.js';
4
6
  export default class InhibitorHandler extends Handler {
5
- constructor(client: XernerxClient);
6
- loadInhibitors(options: InhibitorHandlerOptions): Promise<void>;
7
+ constructor(client: XernerxClient);
8
+ loadInhibitors(options: InhibitorHandlerOptions): Promise<void>;
7
9
  }
8
10
  //# sourceMappingURL=InhibitorHandler.d.ts.map
@@ -1,26 +1,28 @@
1
+ /** @format */
2
+
1
3
  import { z } from 'zod';
2
4
  import * as path from 'path';
3
5
  import Handler from './Handler.js';
4
6
  import XernerxLog from '../tools/XernerxLog.js';
5
7
  import { Style } from 'dumfunctions';
6
8
  export default class InhibitorHandler extends Handler {
7
- constructor(client) {
8
- super(client);
9
- }
10
- async loadInhibitors(options) {
11
- options = z
12
- .object({
13
- directory: z.string(),
14
- })
15
- .parse(options);
16
- this.client.modules.options.inhibitors = options;
17
- const files = this.readdir(options.directory);
18
- for (const file of files) {
19
- const filePath = `${path.resolve(options.directory)}\\${file}`;
20
- const data = await this.load(filePath, 'Inhibitor');
21
- this.emit(data);
22
- }
23
- new XernerxLog(this.client).info(`Loaded ${Style.log(String(this.client.inhibitors.size), { color: Style.TextColor.Cyan })} Inhibitors.`);
24
- }
9
+ constructor(client) {
10
+ super(client);
11
+ }
12
+ async loadInhibitors(options) {
13
+ options = z
14
+ .object({
15
+ directory: z.string(),
16
+ })
17
+ .parse(options);
18
+ this.client.modules.options.inhibitors = options;
19
+ const files = this.readdir(options.directory);
20
+ for (const file of files) {
21
+ const filePath = `${path.resolve(options.directory)}\\${file}`;
22
+ const data = await this.load(filePath, 'Inhibitor');
23
+ this.emit(data);
24
+ }
25
+ new XernerxLog(this.client).info(`Loaded ${Style.log(String(this.client.inhibitors.size), { color: Style.TextColor.Cyan })} Inhibitors.`);
26
+ }
25
27
  }
26
28
  //# sourceMappingURL=InhibitorHandler.js.map
@@ -1,8 +1,10 @@
1
+ /** @format */
2
+
1
3
  import XernerxClient from '../client/XernerxClient.js';
2
4
  import Handler from './Handler.js';
3
5
  export default class WebhookHandler extends Handler {
4
- constructor(client: XernerxClient);
5
- loadWebhooks(options: { token: string }): Promise<void>;
6
- private post;
6
+ constructor(client: XernerxClient);
7
+ loadWebhooks(options: { token: string }): Promise<void>;
8
+ private post;
7
9
  }
8
10
  //# sourceMappingURL=WebhookHandler.d.ts.map
@@ -1,51 +1,53 @@
1
+ /** @format */
2
+
1
3
  import XernerxLog from '../tools/XernerxLog.js';
2
4
  import Handler from './Handler.js';
3
5
  export default class WebhookHandler extends Handler {
4
- constructor(client) {
5
- super(client);
6
- }
7
- async loadWebhooks(options) {
8
- this.client.once('ready', async (client) => {
9
- this.post(options.token);
10
- setInterval(() => {
11
- this.post(client.token);
12
- }, 60000 * 30);
13
- this.client.util.hasVoted = async (userId) => {
14
- return !!(
15
- await (
16
- await fetch(`https://top.gg/api/bots/${this.client.user?.id}/check?userId=${userId}`, {
17
- headers: { Authorization: options.token, 'Content-Type': 'application/json' },
18
- })
19
- ).json()
20
- ).voted;
21
- };
22
- });
23
- }
24
- async post(token) {
25
- const guilds = await this.client.guilds.fetch();
26
- this.client.stats.guildCount = this.client.guilds.cache.size;
27
- this.client.stats.userCount = (await Promise.all(guilds.map(async (guild) => (await this.client.guilds.fetch(guild.id)).memberCount))).reduce((a, b) => (a += b));
28
- this.client.stats.shardId = this.client.options.shards?.at(0) || 0;
29
- this.client.stats.shardCount = this.client.options.shardCount || this.client.options.shards?.length || 1;
30
- try {
31
- new XernerxLog(this.client).info(`Posted Stats to Top.gg!`);
32
- this.client.emit('webhookCreate', this.client, this.client.stats);
33
- return await fetch(`https://top.gg/api/bots/stats`, {
34
- method: 'POST',
35
- headers: {
36
- Authorization: token,
37
- 'Content-Type': 'application/json',
38
- },
39
- body: JSON.stringify({
40
- server_count: this.client.stats.guildCount,
41
- shard_id: this.client.stats.shardId,
42
- shard_count: this.client.stats.shardCount,
43
- }),
44
- });
45
- } catch (error) {
46
- new XernerxLog(this.client).error(`An error occurred while posting stats to Top.gg`, error);
47
- return this.client.emit('webhookError', this.client, this.client.stats);
48
- }
49
- }
6
+ constructor(client) {
7
+ super(client);
8
+ }
9
+ async loadWebhooks(options) {
10
+ this.client.once('ready', async (client) => {
11
+ this.post(options.token);
12
+ setInterval(() => {
13
+ this.post(client.token);
14
+ }, 60000 * 30);
15
+ this.client.util.hasVoted = async (userId) => {
16
+ return !!(
17
+ await (
18
+ await fetch(`https://top.gg/api/bots/${this.client.user?.id}/check?userId=${userId}`, {
19
+ headers: { 'Authorization': options.token, 'Content-Type': 'application/json' },
20
+ })
21
+ ).json()
22
+ ).voted;
23
+ };
24
+ });
25
+ }
26
+ async post(token) {
27
+ const guilds = await this.client.guilds.fetch();
28
+ this.client.stats.guildCount = this.client.guilds.cache.size;
29
+ this.client.stats.userCount = (await Promise.all(guilds.map(async (guild) => (await this.client.guilds.fetch(guild.id)).memberCount))).reduce((a, b) => (a += b));
30
+ this.client.stats.shardId = this.client.options.shards?.at(0) || 0;
31
+ this.client.stats.shardCount = this.client.options.shardCount || this.client.options.shards?.length || 1;
32
+ try {
33
+ new XernerxLog(this.client).info(`Posted Stats to Top.gg!`);
34
+ this.client.emit('webhookCreate', this.client, this.client.stats);
35
+ return await fetch(`https://top.gg/api/bots/stats`, {
36
+ method: 'POST',
37
+ headers: {
38
+ 'Authorization': token,
39
+ 'Content-Type': 'application/json',
40
+ },
41
+ body: JSON.stringify({
42
+ server_count: this.client.stats.guildCount,
43
+ shard_id: this.client.stats.shardId,
44
+ shard_count: this.client.stats.shardCount,
45
+ }),
46
+ });
47
+ } catch (error) {
48
+ new XernerxLog(this.client).error(`An error occurred while posting stats to Top.gg`, error);
49
+ return this.client.emit('webhookError', this.client, this.client.stats);
50
+ }
51
+ }
50
52
  }
51
53
  //# sourceMappingURL=WebhookHandler.js.map
package/dist/main.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /** @format */
2
+
1
3
  declare const version: any;
2
4
  import XernerxClient from './client/XernerxClient.js';
3
5
  import XernerxShardClient from './client/XernerxShardClient.js';
@@ -16,31 +18,31 @@ export * from './types/interfaces.js';
16
18
  import Discord from 'discord.js';
17
19
  export default XernerxClient;
18
20
  export {
19
- /**
20
- ** Clients
21
- */
22
- XernerxClient,
23
- XernerxShardClient,
24
- /**
25
- ** Builders
26
- */
27
- XernerxMessageCommand,
28
- XernerxSlashCommand,
29
- XernerxContextCommand,
30
- XernerxEvent,
31
- XernerxInhibitor,
32
- XernerxExtension,
33
- /**
34
- ** Imported exports
35
- */
36
- Discord,
37
- /**
38
- ** Properties
39
- */
40
- version,
41
- /**
42
- ** Tools
43
- */
44
- XernerxLog,
21
+ /**
22
+ ** Clients
23
+ */
24
+ XernerxClient,
25
+ XernerxShardClient,
26
+ /**
27
+ ** Builders
28
+ */
29
+ XernerxMessageCommand,
30
+ XernerxSlashCommand,
31
+ XernerxContextCommand,
32
+ XernerxEvent,
33
+ XernerxInhibitor,
34
+ XernerxExtension,
35
+ /**
36
+ ** Imported exports
37
+ */
38
+ Discord,
39
+ /**
40
+ ** Properties
41
+ */
42
+ version,
43
+ /**
44
+ ** Tools
45
+ */
46
+ XernerxLog,
45
47
  };
46
48
  //# sourceMappingURL=main.d.ts.map
package/dist/main.js CHANGED
@@ -1,3 +1,5 @@
1
+ /** @format */
2
+
1
3
  import * as fs from 'fs';
2
4
  const version = JSON.parse(fs.readFileSync('node_modules/xernerx/package.json', 'utf-8')).version;
3
5
  new XernerxLog(true).update(version, 'https://raw.githubusercontent.com/xernerx/xernerx/master/package.json');
@@ -18,31 +20,31 @@ export * from './types/interfaces.js';
18
20
  import Discord from 'discord.js';
19
21
  export default XernerxClient;
20
22
  export {
21
- /**
22
- ** Clients
23
- */
24
- XernerxClient,
25
- XernerxShardClient,
26
- /**
27
- ** Builders
28
- */
29
- XernerxMessageCommand,
30
- XernerxSlashCommand,
31
- XernerxContextCommand,
32
- XernerxEvent,
33
- XernerxInhibitor,
34
- XernerxExtension,
35
- /**
36
- ** Imported exports
37
- */
38
- Discord,
39
- /**
40
- ** Properties
41
- */
42
- version,
43
- /**
44
- ** Tools
45
- */
46
- XernerxLog,
23
+ /**
24
+ ** Clients
25
+ */
26
+ XernerxClient,
27
+ XernerxShardClient,
28
+ /**
29
+ ** Builders
30
+ */
31
+ XernerxMessageCommand,
32
+ XernerxSlashCommand,
33
+ XernerxContextCommand,
34
+ XernerxEvent,
35
+ XernerxInhibitor,
36
+ XernerxExtension,
37
+ /**
38
+ ** Imported exports
39
+ */
40
+ Discord,
41
+ /**
42
+ ** Properties
43
+ */
44
+ version,
45
+ /**
46
+ ** Tools
47
+ */
48
+ XernerxLog,
47
49
  };
48
50
  //# sourceMappingURL=main.js.map
@@ -1,3 +1,5 @@
1
+ /** @format */
2
+
1
3
  import XernerxSlashCommand from '../build/XernerxSlashCommand.js';
2
4
  import XernerxContextCommand from '../build/XernerxContextCommand.js';
3
5
  import MessageCommandBuilder from '../build/XernerxMessageCommand.js';
@@ -6,7 +8,7 @@ import { MessageCommandArguments } from '../types/interfaces.js';
6
8
  import { XernerxInteraction } from '../types/types.js';
7
9
  export declare function messageArguments(message: XernerxMessage, command: MessageCommandBuilder, prefix: string): Promise<MessageCommandArguments>;
8
10
  export declare function interactionArguments(
9
- interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction> | any,
10
- command: XernerxContextCommand | XernerxSlashCommand
11
+ interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction> | any,
12
+ command: XernerxContextCommand | XernerxSlashCommand
11
13
  ): Promise<any>;
12
14
  //# sourceMappingURL=Arguments.d.ts.map