xernerx 4.2.1 → 4.3.1

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 (117) hide show
  1. package/LICENSE +21 -21
  2. package/dist/build/ContextCommandBuilder.d.ts +14 -13
  3. package/dist/build/ContextCommandBuilder.js +2 -13
  4. package/dist/build/EventBuilder.d.ts +7 -7
  5. package/dist/build/EventBuilder.js +0 -6
  6. package/dist/build/InhibitorBuilder.d.ts +5 -5
  7. package/dist/build/InhibitorBuilder.js +0 -4
  8. package/dist/build/MessageCommandBuilder.d.ts +1 -0
  9. package/dist/build/MessageCommandBuilder.js +2 -16
  10. package/dist/build/SlashCommandBuilder.d.ts +13 -12
  11. package/dist/build/SlashCommandBuilder.js +2 -12
  12. package/dist/client/XernerxClient.d.ts +2 -2
  13. package/dist/client/XernerxClient.js +2 -2
  14. package/dist/handlers/ExtensionHandler.js +3 -1
  15. package/dist/handlers/WebhookHandler.js +1 -1
  16. package/dist/main.d.ts +2 -2
  17. package/dist/main.js +3 -2
  18. package/dist/types/interfaces.d.ts +3 -2
  19. package/dist/utils/ClientUtil.d.ts +1 -0
  20. package/dist/utils/ClientUtil.js +10 -0
  21. package/package.json +2 -2
  22. package/dist/cjs/build/ContextCommandBuilder.d.ts +0 -68
  23. package/dist/cjs/build/ContextCommandBuilder.js +0 -97
  24. package/dist/cjs/build/EventBuilder.d.ts +0 -21
  25. package/dist/cjs/build/EventBuilder.js +0 -44
  26. package/dist/cjs/build/InhibitorBuilder.d.ts +0 -19
  27. package/dist/cjs/build/InhibitorBuilder.js +0 -37
  28. package/dist/cjs/build/MessageCommandBuilder.d.ts +0 -59
  29. package/dist/cjs/build/MessageCommandBuilder.js +0 -100
  30. package/dist/cjs/build/SlashCommandBuilder.d.ts +0 -64
  31. package/dist/cjs/build/SlashCommandBuilder.js +0 -168
  32. package/dist/cjs/client/XernerxClient.d.ts +0 -28
  33. package/dist/cjs/client/XernerxClient.js +0 -116
  34. package/dist/cjs/handlers/CommandHandler.d.ts +0 -27
  35. package/dist/cjs/handlers/CommandHandler.js +0 -45
  36. package/dist/cjs/handlers/EventHandler.d.ts +0 -13
  37. package/dist/cjs/handlers/EventHandler.js +0 -19
  38. package/dist/cjs/handlers/Handler.d.ts +0 -57
  39. package/dist/cjs/handlers/Handler.js +0 -308
  40. package/dist/cjs/handlers/InhibitorHandler.d.ts +0 -18
  41. package/dist/cjs/handlers/InhibitorHandler.js +0 -24
  42. package/dist/cjs/main.d.ts +0 -44
  43. package/dist/cjs/main.js +0 -112
  44. package/dist/cjs/models/CommandArguments.d.ts +0 -17
  45. package/dist/cjs/models/CommandArguments.js +0 -106
  46. package/dist/cjs/models/Events.d.ts +0 -24
  47. package/dist/cjs/models/Events.js +0 -307
  48. package/dist/cjs/models/Extensions.d.ts +0 -7
  49. package/dist/cjs/models/Extensions.js +0 -26
  50. package/dist/cjs/tools/XernerxError.d.ts +0 -5
  51. package/dist/cjs/tools/XernerxError.js +0 -11
  52. package/dist/cjs/tools/package.d.ts +0 -49
  53. package/dist/cjs/tools/package.js +0 -50
  54. package/dist/cjs/types/enums.d.ts +0 -44
  55. package/dist/cjs/types/enums.js +0 -38
  56. package/dist/cjs/types/interfaces.d.ts +0 -25
  57. package/dist/cjs/types/interfaces.js +0 -2
  58. package/dist/cjs/types/options.d.ts +0 -241
  59. package/dist/cjs/types/options.js +0 -2
  60. package/dist/cjs/types/types.d.ts +0 -61
  61. package/dist/cjs/types/types.js +0 -2
  62. package/dist/cjs/utils/ClientUtil.d.ts +0 -25
  63. package/dist/cjs/utils/ClientUtil.js +0 -211
  64. package/dist/cjs/utils/CommandUtil.d.ts +0 -58
  65. package/dist/cjs/utils/CommandUtil.js +0 -247
  66. package/dist/cjs/validators/CommandValidations.d.ts +0 -12
  67. package/dist/cjs/validators/CommandValidations.js +0 -169
  68. package/dist/cjs/validators/InhibitorValidations.d.ts +0 -11
  69. package/dist/cjs/validators/InhibitorValidations.js +0 -40
  70. package/dist/mjs/build/ContextCommandBuilder.d.ts +0 -68
  71. package/dist/mjs/build/ContextCommandBuilder.js +0 -88
  72. package/dist/mjs/build/EventBuilder.d.ts +0 -21
  73. package/dist/mjs/build/EventBuilder.js +0 -34
  74. package/dist/mjs/build/InhibitorBuilder.d.ts +0 -19
  75. package/dist/mjs/build/InhibitorBuilder.js +0 -27
  76. package/dist/mjs/build/MessageCommandBuilder.d.ts +0 -59
  77. package/dist/mjs/build/MessageCommandBuilder.js +0 -90
  78. package/dist/mjs/build/SlashCommandBuilder.d.ts +0 -64
  79. package/dist/mjs/build/SlashCommandBuilder.js +0 -121
  80. package/dist/mjs/client/XernerxClient.d.ts +0 -28
  81. package/dist/mjs/client/XernerxClient.js +0 -108
  82. package/dist/mjs/handlers/CommandHandler.d.ts +0 -27
  83. package/dist/mjs/handlers/CommandHandler.js +0 -42
  84. package/dist/mjs/handlers/EventHandler.d.ts +0 -13
  85. package/dist/mjs/handlers/EventHandler.js +0 -16
  86. package/dist/mjs/handlers/Handler.d.ts +0 -57
  87. package/dist/mjs/handlers/Handler.js +0 -260
  88. package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -18
  89. package/dist/mjs/handlers/InhibitorHandler.js +0 -21
  90. package/dist/mjs/main.d.ts +0 -44
  91. package/dist/mjs/main.js +0 -52
  92. package/dist/mjs/models/CommandArguments.d.ts +0 -17
  93. package/dist/mjs/models/CommandArguments.js +0 -101
  94. package/dist/mjs/models/Events.d.ts +0 -24
  95. package/dist/mjs/models/Events.js +0 -295
  96. package/dist/mjs/models/Extensions.d.ts +0 -7
  97. package/dist/mjs/models/Extensions.js +0 -23
  98. package/dist/mjs/tools/XernerxError.d.ts +0 -5
  99. package/dist/mjs/tools/XernerxError.js +0 -8
  100. package/dist/mjs/tools/package.d.ts +0 -49
  101. package/dist/mjs/tools/package.js +0 -48
  102. package/dist/mjs/types/enums.d.ts +0 -44
  103. package/dist/mjs/types/enums.js +0 -35
  104. package/dist/mjs/types/interfaces.d.ts +0 -25
  105. package/dist/mjs/types/interfaces.js +0 -1
  106. package/dist/mjs/types/options.d.ts +0 -241
  107. package/dist/mjs/types/options.js +0 -1
  108. package/dist/mjs/types/types.d.ts +0 -61
  109. package/dist/mjs/types/types.js +0 -1
  110. package/dist/mjs/utils/ClientUtil.d.ts +0 -25
  111. package/dist/mjs/utils/ClientUtil.js +0 -202
  112. package/dist/mjs/utils/CommandUtil.d.ts +0 -58
  113. package/dist/mjs/utils/CommandUtil.js +0 -232
  114. package/dist/mjs/validators/CommandValidations.d.ts +0 -12
  115. package/dist/mjs/validators/CommandValidations.js +0 -166
  116. package/dist/mjs/validators/InhibitorValidations.d.ts +0 -11
  117. package/dist/mjs/validators/InhibitorValidations.js +0 -36
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Dummi
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Dummi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -3,15 +3,16 @@ import XernerxClient from '../client/XernerxClient.js';
3
3
  import { XernerxMessageContextInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
4
4
  import { ContextCommandOptions } from '../types/interfaces.js';
5
5
  export default class ContextCommandBuilder {
6
- id: string;
7
- data: ContextMenuCommandBuilder;
8
- name: string;
9
- type: 'message' | 'user';
10
- description: string | null | undefined;
11
- info: string | null | undefined;
12
- category: string | null | undefined;
13
- cooldown: number | null | undefined;
14
- ignore:
6
+ readonly id: string;
7
+ readonly data: ContextMenuCommandBuilder;
8
+ readonly name: string;
9
+ readonly type: 'message' | 'user';
10
+ readonly description: string | null | undefined;
11
+ readonly usage: string | null | undefined;
12
+ readonly info: string | null | undefined;
13
+ readonly category: string | null | undefined;
14
+ readonly cooldown: number | null | undefined;
15
+ readonly ignore:
15
16
  | {
16
17
  owner?: boolean | undefined;
17
18
  users?: string[] | undefined;
@@ -19,7 +20,7 @@ export default class ContextCommandBuilder {
19
20
  guilds?: string[] | undefined;
20
21
  }
21
22
  | undefined;
22
- strict:
23
+ readonly strict:
23
24
  | {
24
25
  owner?: boolean | undefined;
25
26
  users?: string[] | undefined;
@@ -27,21 +28,21 @@ export default class ContextCommandBuilder {
27
28
  guilds?: string[] | undefined;
28
29
  }
29
30
  | undefined;
30
- permissions:
31
+ readonly permissions:
31
32
  | {
32
33
  user?: string[] | import('../types/types.js').PermissionNames[] | undefined;
33
34
  client?: string[] | import('../types/types.js').PermissionNames[] | undefined;
34
35
  dm?: boolean | undefined;
35
36
  }
36
37
  | undefined;
37
- defer:
38
+ readonly defer:
38
39
  | {
39
40
  reply?: boolean | undefined;
40
41
  ephemeral?: boolean | undefined;
41
42
  fetchReply?: boolean | undefined;
42
43
  }
43
44
  | undefined;
44
- client: typeof XernerxClient;
45
+ readonly client: typeof XernerxClient;
45
46
  constructor(id: string, options: ContextCommandOptions);
46
47
  exec(interaction: XernerxUserContextInteraction | XernerxMessageContextInteraction): Promise<void>;
47
48
  }
@@ -2,19 +2,6 @@ import { ContextMenuCommandBuilder } from 'discord.js';
2
2
  import { z } from 'zod';
3
3
  import XernerxClient from '../client/XernerxClient.js';
4
4
  export default class ContextCommandBuilder {
5
- id;
6
- data;
7
- name;
8
- type;
9
- description;
10
- info;
11
- category;
12
- cooldown;
13
- ignore;
14
- strict;
15
- permissions;
16
- defer;
17
- client;
18
5
  constructor(id, options) {
19
6
  this.id = id;
20
7
  this.data = new ContextMenuCommandBuilder();
@@ -27,6 +14,7 @@ export default class ContextCommandBuilder {
27
14
  name: z.string(),
28
15
  type: z.enum(['user', 'message']),
29
16
  description: z.string().or(z.null()).default(null),
17
+ usage: z.string().or(z.null()).default(null),
30
18
  info: z.string().or(z.null()).default(null),
31
19
  category: z.string().or(z.null()).default(null),
32
20
  cooldown: z.number().or(z.null()).default(null),
@@ -65,6 +53,7 @@ export default class ContextCommandBuilder {
65
53
  this.name = options.name;
66
54
  this.type = options.type;
67
55
  this.description = options.description;
56
+ this.usage = options.usage;
68
57
  this.info = options.info;
69
58
  this.category = options.category;
70
59
  this.cooldown = options.cooldown;
@@ -7,16 +7,16 @@ import { EventType } from '../types/types.js';
7
7
  * @param {EventOptions} options - The event options.
8
8
  */
9
9
  export default class EventBuilder {
10
- id: string;
11
- name: EventType;
12
- emitter: 'client' | 'process' | string;
13
- type: 'discord' | string;
14
- once: boolean;
15
- client: typeof XernerxClient;
10
+ readonly id: string;
11
+ readonly name: EventType;
12
+ readonly emitter?: 'client' | 'process' | string;
13
+ readonly type?: 'discord' | string;
14
+ readonly once?: boolean;
15
+ readonly client: typeof XernerxClient;
16
16
  constructor(id: string, options: EventBuilderOptions);
17
17
  /**
18
18
  * @description run your custom event here.
19
19
  * TODO - update description
20
20
  */
21
- run<T extends Array<T>>(...args: T): Promise<void>;
21
+ run<T>(...args: T[]): Promise<void>;
22
22
  }
@@ -7,12 +7,6 @@ import XernerxClient from '../client/XernerxClient.js';
7
7
  * @param {EventOptions} options - The event options.
8
8
  */
9
9
  export default class EventBuilder {
10
- id;
11
- name;
12
- emitter;
13
- type;
14
- once;
15
- client;
16
10
  constructor(id, options) {
17
11
  this.id = id;
18
12
  z.object({
@@ -8,10 +8,10 @@ import { XernerxMessage } from '../types/extenders.js';
8
8
  * @param {InhibitorOptions} options - The inhibitor options.
9
9
  */
10
10
  export default class InhibitorBuilder {
11
- id: string;
12
- name: string;
13
- type: InhibitorType;
14
- client: typeof XernerxClient;
11
+ readonly id: string;
12
+ readonly name: string;
13
+ readonly type: InhibitorType;
14
+ readonly client: typeof XernerxClient;
15
15
  constructor(id: string, options: InhibitorBuilderOptions);
16
- check(action: XernerxInteraction | XernerxMessage, args: any): Promise<void>;
16
+ check<T>(action: XernerxInteraction | XernerxMessage, args: T): Promise<void>;
17
17
  }
@@ -8,10 +8,6 @@ import XernerxClient from '../client/XernerxClient.js';
8
8
  * @param {InhibitorOptions} options - The inhibitor options.
9
9
  */
10
10
  export default class InhibitorBuilder {
11
- id;
12
- name;
13
- type;
14
- client;
15
11
  constructor(id, options) {
16
12
  this.id = id;
17
13
  z.object({
@@ -8,6 +8,7 @@ export default class MessageCommandBuilder {
8
8
  readonly regex: RegExp | undefined;
9
9
  readonly prefix: string | string[] | undefined;
10
10
  readonly description: string | null | undefined;
11
+ readonly usage: string | null | undefined;
11
12
  readonly info: string | null | undefined;
12
13
  readonly separator: string | undefined;
13
14
  readonly args: import('../types/interfaces.js').MessageCommandArgumentOptions[] | undefined;
@@ -1,22 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import XernerxClient from '../client/XernerxClient.js';
3
3
  export default class MessageCommandBuilder {
4
- id;
5
- name;
6
- aliases;
7
- regex;
8
- prefix;
9
- description;
10
- info;
11
- separator;
12
- args;
13
- flags;
14
- category;
15
- cooldown;
16
- ignore;
17
- strict;
18
- permissions;
19
- client;
20
4
  constructor(id, options) {
21
5
  this.id = id;
22
6
  this.regex = options.regex;
@@ -27,6 +11,7 @@ export default class MessageCommandBuilder {
27
11
  name: z.string(),
28
12
  aliases: z.array(z.string()).default([]),
29
13
  description: z.string().or(z.null()).default(null),
14
+ usage: z.string().or(z.null()).default(null),
30
15
  info: z.string().or(z.null()).default(null),
31
16
  category: z.string().or(z.null()).default(null),
32
17
  cooldown: z.number().or(z.null()).default(null),
@@ -60,6 +45,7 @@ export default class MessageCommandBuilder {
60
45
  this.aliases = options.aliases;
61
46
  this.prefix = options.prefix;
62
47
  this.description = options.description;
48
+ this.usage = options.usage;
63
49
  this.info = options.info;
64
50
  this.category = options.category;
65
51
  this.cooldown = options.cooldown;
@@ -3,14 +3,15 @@ import XernerxClient from '../client/XernerxClient.js';
3
3
  import { XernerxSlashInteraction } from '../types/extenders.js';
4
4
  import { SlashCommandArguments, SlashCommandOptions } from '../types/interfaces.js';
5
5
  export default class SlashCommandBuilder {
6
- id: string;
7
- data: Discord.SlashCommandBuilder;
8
- name: string;
9
- description: string;
10
- info: string | null | undefined;
11
- category: string | null | undefined;
12
- cooldown: number | null | undefined;
13
- ignore:
6
+ readonly id: string;
7
+ readonly data: Discord.SlashCommandBuilder;
8
+ readonly name: string;
9
+ readonly description: string;
10
+ readonly usage: string | null | undefined;
11
+ readonly info: string | null | undefined;
12
+ readonly category: string | null | undefined;
13
+ readonly cooldown: number | null | undefined;
14
+ readonly ignore:
14
15
  | {
15
16
  owner?: boolean | undefined;
16
17
  users?: string[] | undefined;
@@ -18,7 +19,7 @@ export default class SlashCommandBuilder {
18
19
  guilds?: string[] | undefined;
19
20
  }
20
21
  | undefined;
21
- strict:
22
+ readonly strict:
22
23
  | {
23
24
  owner?: boolean | undefined;
24
25
  users?: string[] | undefined;
@@ -26,21 +27,21 @@ export default class SlashCommandBuilder {
26
27
  guilds?: string[] | undefined;
27
28
  }
28
29
  | undefined;
29
- permissions:
30
+ readonly permissions:
30
31
  | {
31
32
  user?: string[] | import('../types/types.js').PermissionNames[] | undefined;
32
33
  client?: string[] | import('../types/types.js').PermissionNames[] | undefined;
33
34
  dm?: boolean | undefined;
34
35
  }
35
36
  | undefined;
36
- defer:
37
+ readonly defer:
37
38
  | {
38
39
  reply?: boolean | undefined;
39
40
  ephemeral?: boolean | undefined;
40
41
  fetchReply?: boolean | undefined;
41
42
  }
42
43
  | undefined;
43
- client: typeof XernerxClient;
44
+ readonly client: typeof XernerxClient;
44
45
  constructor(id: string, options: SlashCommandOptions);
45
46
  autocomplete<T>(interaction: XernerxSlashInteraction, focused: T, options: Array<T>): Promise<void>;
46
47
  conditions(interaction: XernerxSlashInteraction, args: SlashCommandArguments): Promise<void>;
@@ -2,18 +2,6 @@ import Discord, { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuil
2
2
  import { z } from 'zod';
3
3
  import XernerxClient from '../client/XernerxClient.js';
4
4
  export default class SlashCommandBuilder {
5
- id;
6
- data;
7
- name;
8
- description;
9
- info;
10
- category;
11
- cooldown;
12
- ignore;
13
- strict;
14
- permissions;
15
- defer;
16
- client;
17
5
  constructor(id, options) {
18
6
  this.id = id;
19
7
  this.data = new Discord.SlashCommandBuilder();
@@ -35,6 +23,7 @@ export default class SlashCommandBuilder {
35
23
  .object({
36
24
  name: z.string(),
37
25
  description: z.string(),
26
+ usage: z.string().or(z.null()).default(null),
38
27
  info: z.string().or(z.null()).default(null),
39
28
  category: z.string().or(z.null()).default(null),
40
29
  number: z.number().or(z.null()).default(null),
@@ -73,6 +62,7 @@ export default class SlashCommandBuilder {
73
62
  .parse(options);
74
63
  this.name = options.name;
75
64
  this.description = options.description;
65
+ this.usage = options.usage;
76
66
  this.info = options.info;
77
67
  this.category = options.category;
78
68
  this.cooldown = options.cooldown;
@@ -37,7 +37,7 @@ export default class XernerxClient extends Client {
37
37
  }
38
38
  | undefined;
39
39
  };
40
- readonly config: unknown;
40
+ readonly config: Record<string, unknown> | null;
41
41
  readonly commands: XernerxCommands;
42
42
  readonly events: Collection<string, EventBuilder>;
43
43
  readonly inhibitors: Collection<string, InhibitorBuilder>;
@@ -50,6 +50,6 @@ export default class XernerxClient extends Client {
50
50
  shardCount: number;
51
51
  };
52
52
  readonly cache: XernerxCache;
53
- constructor(discordOptions: ClientOptions, xernerxOptions: XernerxOptions, config?: unknown);
53
+ constructor(discordOptions: ClientOptions, xernerxOptions: XernerxOptions, config?: Record<string, unknown>);
54
54
  connect(token: string): void;
55
55
  }
@@ -46,7 +46,7 @@ export default class XernerxClient extends Client {
46
46
  .optional(),
47
47
  })
48
48
  .parse(xernerxOptions);
49
- this.config = config;
49
+ this.config = config || null;
50
50
  this.commands = {
51
51
  message: new Collection(),
52
52
  slash: new Collection(),
@@ -64,7 +64,7 @@ export default class XernerxClient extends Client {
64
64
  };
65
65
  this.util = new ClientUtil(this);
66
66
  this.stats = {
67
- guildCount: 0,
67
+ guildCount: this.guilds.cache.size,
68
68
  userCount: 0,
69
69
  shardId: 0,
70
70
  shardCount: 1,
@@ -8,7 +8,9 @@ export default class ExtensionHandler extends Handler {
8
8
  const active = extensions.map((extension) => {
9
9
  try {
10
10
  if (extension.main) extension.main(this.client);
11
- if (extension.await) extension.await(this.client);
11
+ if (extension.defer) {
12
+ this.client.on('ready', (client) => extension.defer(client));
13
+ }
12
14
  return extension.name;
13
15
  } catch (error) {
14
16
  new XernerxLog(this.client).error(`An error occurred while loading ${extension.name}`, error);
@@ -23,7 +23,7 @@ export default class WebhookHandler extends Handler {
23
23
  }
24
24
  async post(token) {
25
25
  const guilds = await this.client.guilds.fetch();
26
- this.client.stats.guildCount = guilds.size;
26
+ this.client.stats.guildCount = this.client.guilds.cache.size;
27
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
28
  this.client.stats.shardId = this.client.options.shards?.at(0) || 0;
29
29
  this.client.stats.shardCount = this.client.options.shardCount || this.client.options.shards?.length || 1;
package/dist/main.d.ts CHANGED
@@ -5,10 +5,10 @@ import ContextCommandBuilder from './build/ContextCommandBuilder.js';
5
5
  import EventBuilder from './build/EventBuilder.js';
6
6
  import InhibitorBuilder from './build/InhibitorBuilder.js';
7
7
  import XernerxLog from './tools/XernerxLog.js';
8
- export default XernerxClient;
9
8
  export * from 'discord.js';
10
9
  export * from 'dumfunctions';
11
10
  import ExtensionBuilder from 'xernerx-extension-builder';
12
11
  import Discord from 'discord.js';
13
- declare const version = '4.2.1';
12
+ declare const version: any;
13
+ export default XernerxClient;
14
14
  export { XernerxClient, MessageCommandBuilder, SlashCommandBuilder, ContextCommandBuilder, EventBuilder, InhibitorBuilder, ExtensionBuilder, Discord, version, XernerxLog };
package/dist/main.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as fs from 'fs';
1
2
  import XernerxClient from './client/XernerxClient.js';
2
3
  import MessageCommandBuilder from './build/MessageCommandBuilder.js';
3
4
  import SlashCommandBuilder from './build/SlashCommandBuilder.js';
@@ -5,10 +6,10 @@ import ContextCommandBuilder from './build/ContextCommandBuilder.js';
5
6
  import EventBuilder from './build/EventBuilder.js';
6
7
  import InhibitorBuilder from './build/InhibitorBuilder.js';
7
8
  import XernerxLog from './tools/XernerxLog.js';
8
- export default XernerxClient;
9
9
  export * from 'discord.js';
10
10
  export * from 'dumfunctions';
11
11
  import ExtensionBuilder from 'xernerx-extension-builder';
12
12
  import Discord from 'discord.js';
13
- const version = '4.2.1';
13
+ const version = JSON.parse(fs.readFileSync('node_modules/xernerx/package.json', 'utf-8')).version;
14
+ export default XernerxClient;
14
15
  export { XernerxClient, MessageCommandBuilder, SlashCommandBuilder, ContextCommandBuilder, EventBuilder, InhibitorBuilder, ExtensionBuilder, Discord, version, XernerxLog };
@@ -116,6 +116,7 @@ export interface InhibitorHandlerOptions {
116
116
  interface CommandOptions {
117
117
  name: string;
118
118
  description?: string | null;
119
+ usage?: string | null;
119
120
  info?: string | null;
120
121
  category?: string | null;
121
122
  cooldown?: number | null;
@@ -217,8 +218,8 @@ export interface SlashCommandArguments {
217
218
  }
218
219
  export interface EventBuilderOptions {
219
220
  name: EventType;
220
- emitter: 'discord' | 'process';
221
- type: string;
221
+ emitter: 'client' | 'process';
222
+ type: 'discord';
222
223
  once: boolean;
223
224
  }
224
225
  export interface InhibitorBuilderOptions {
@@ -6,4 +6,5 @@ export default class ClientUtil extends Util {
6
6
  constructor(client: XernerxClient);
7
7
  setPresence(options: PresenceOptions): import('discord.js').ClientPresence | undefined;
8
8
  resolveChannel(query: string | Record<string, string>): Promise<import('discord.js').Channel | null>;
9
+ resolveGuild(query: string | Record<string, string>): Promise<import('discord.js').Guild | null>;
9
10
  }
@@ -17,4 +17,14 @@ export default class ClientUtil extends Util {
17
17
  return null;
18
18
  }
19
19
  }
20
+ async resolveGuild(query) {
21
+ if (typeof query == 'object') query = query.id;
22
+ try {
23
+ let guild = this.client.guilds.cache.find((guild) => guild.name.toLowerCase() == query.toLowerCase()) || null;
24
+ if (!guild) guild = (await this.client.guilds.fetch(query)) || null;
25
+ return guild;
26
+ } catch {
27
+ return null;
28
+ }
29
+ }
20
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "4.2.1",
3
+ "version": "4.3.1",
4
4
  "description": "A bot framework for discord.js.",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",
@@ -39,7 +39,7 @@
39
39
  "dbl-sdk": "^1.2.0",
40
40
  "discord.js": "^14.9.0",
41
41
  "dumfunctions": "^2.1.2",
42
- "xernerx-extension-builder": "^0.0.12",
42
+ "xernerx-extension-builder": "^0.0.16",
43
43
  "zod": "^3.21.4"
44
44
  },
45
45
  "devDependencies": {
@@ -1,68 +0,0 @@
1
- import { ContextMenuCommandBuilder, Interaction } from 'discord.js';
2
- import { ContextCommandOptions } from '../types/options.js';
3
- import XernerxClient from '../client/XernerxClient.js';
4
- /**
5
- * @description The command builder for context commands.
6
- * @param {String} id - The unique ID of the command.
7
- * @param {ContextCommandOptions} options - The command options.
8
- */
9
- export default class ContextCommandBuilder {
10
- id: string;
11
- data: ContextMenuCommandBuilder;
12
- name: string;
13
- type: import('@discordjs/builders').ContextMenuCommandType;
14
- description: string | undefined;
15
- info: string | undefined;
16
- category: string | undefined;
17
- channelType: number | number[] | undefined;
18
- cooldown: number | undefined;
19
- ignore:
20
- | {
21
- owner?: boolean | undefined;
22
- users?: string[] | undefined;
23
- channels?: string[] | undefined;
24
- guilds?: string[] | undefined;
25
- }
26
- | undefined;
27
- strict:
28
- | {
29
- owner?: boolean | undefined;
30
- users?: string[] | undefined;
31
- channels?: string[] | undefined;
32
- guilds?: string[] | undefined;
33
- }
34
- | undefined;
35
- permissions:
36
- | {
37
- client?: string[] | undefined;
38
- users?: string[] | undefined;
39
- dm?: boolean | undefined;
40
- }
41
- | undefined;
42
- defer:
43
- | {
44
- /**
45
- * @param {Interaction} interaction - The Discord interaction event data.
46
- * @description Make your custom command here.
47
- * TODO - update description
48
- */
49
- reply?: boolean | undefined;
50
- ephemeral?: boolean | undefined;
51
- fetch?: boolean | undefined;
52
- }
53
- | undefined;
54
- client: typeof XernerxClient;
55
- constructor(id: string, options: ContextCommandOptions);
56
- /**
57
- * @param {Interaction} interaction - The Discord interaction event data.
58
- * @description make any preconditions here.
59
- * TODO - update description
60
- */
61
- conditions(interaction: Interaction, args: any): Promise<void>;
62
- /**
63
- * @param {Interaction} interaction - The Discord interaction event data.
64
- * @description Make your custom command here.
65
- * TODO - update description
66
- */
67
- exec(interaction: Interaction, args: any): Promise<void>;
68
- }
@@ -1,97 +0,0 @@
1
- 'use strict';
2
- var __importDefault =
3
- (this && this.__importDefault) ||
4
- function (mod) {
5
- return mod && mod.__esModule ? mod : { default: mod };
6
- };
7
- Object.defineProperty(exports, '__esModule', { value: true });
8
- const discord_js_1 = require('discord.js');
9
- const zod_1 = require('zod');
10
- const XernerxClient_js_1 = __importDefault(require('../client/XernerxClient.js'));
11
- /**
12
- * @description The command builder for context commands.
13
- * @param {String} id - The unique ID of the command.
14
- * @param {ContextCommandOptions} options - The command options.
15
- */
16
- class ContextCommandBuilder {
17
- id;
18
- data;
19
- name;
20
- type;
21
- description;
22
- info;
23
- category;
24
- channelType;
25
- cooldown;
26
- ignore;
27
- strict;
28
- permissions;
29
- defer;
30
- client;
31
- constructor(id, options) {
32
- this.id = id;
33
- this.data = new discord_js_1.ContextMenuCommandBuilder();
34
- if (options.name) this.data.setName(options.name);
35
- if (options.type) this.data.setType(options.type);
36
- if (options.permissions?.users) this.data.setDefaultMemberPermissions(options.permissions?.users);
37
- if (options.permissions?.dm === false) this.data.setDMPermission(options.permissions?.dm);
38
- if (options.nameLocalizations) this.data.setNameLocalizations(options.nameLocalizations);
39
- zod_1.z
40
- .object({
41
- description: zod_1.z.string(),
42
- info: zod_1.z.string(),
43
- category: zod_1.z.string(),
44
- channelType: zod_1.z.array(zod_1.z.number()).or(zod_1.z.number()),
45
- cooldown: zod_1.z.number(),
46
- ignore: zod_1.z.object({
47
- owner: zod_1.z.boolean(),
48
- users: zod_1.z.array(zod_1.z.string()),
49
- channels: zod_1.z.array(zod_1.z.string()),
50
- guilds: zod_1.z.array(zod_1.z.string()),
51
- }),
52
- strict: zod_1.z.object({
53
- owner: zod_1.z.boolean(),
54
- users: zod_1.z.array(zod_1.z.string()),
55
- channels: zod_1.z.array(zod_1.z.string()),
56
- guilds: zod_1.z.array(zod_1.z.string()),
57
- }),
58
- permissions: zod_1.z.object({
59
- client: zod_1.z.array(zod_1.z.string()),
60
- users: zod_1.z.array(zod_1.z.string()),
61
- dm: zod_1.z.boolean(),
62
- }),
63
- defer: zod_1.z.object({
64
- reply: zod_1.z.boolean(),
65
- ephemeral: zod_1.z.boolean(),
66
- fetch: zod_1.z.boolean(),
67
- }),
68
- })
69
- .deepPartial()
70
- .parse(options);
71
- this.name = options.name;
72
- this.type = options.type;
73
- this.description = options.description;
74
- this.info = options.info;
75
- this.category = options.category;
76
- this.channelType = options.channelType;
77
- this.cooldown = options.cooldown;
78
- this.ignore = options.ignore;
79
- this.strict = options.strict;
80
- this.permissions = options.permissions;
81
- this.defer = options.defer;
82
- this.client = XernerxClient_js_1.default;
83
- }
84
- /**
85
- * @param {Interaction} interaction - The Discord interaction event data.
86
- * @description make any preconditions here.
87
- * TODO - update description
88
- */
89
- async conditions(interaction, args) {}
90
- /**
91
- * @param {Interaction} interaction - The Discord interaction event data.
92
- * @description Make your custom command here.
93
- * TODO - update description
94
- */
95
- async exec(interaction, args) {}
96
- }
97
- exports.default = ContextCommandBuilder;