xernerx 3.5.2 → 4.0.0

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 (194) hide show
  1. package/dist/build/ContextCommandBuilder.d.ts +47 -0
  2. package/dist/build/ContextCommandBuilder.js +78 -0
  3. package/dist/{cjs/build → build}/EventBuilder.d.ts +7 -6
  4. package/dist/build/EventBuilder.js +35 -0
  5. package/dist/build/InhibitorBuilder.d.ts +17 -0
  6. package/dist/build/InhibitorBuilder.js +26 -0
  7. package/dist/build/MessageCommandBuilder.d.ts +43 -0
  8. package/dist/build/MessageCommandBuilder.js +71 -0
  9. package/dist/{cjs/build → build}/SlashCommandBuilder.d.ts +16 -31
  10. package/dist/build/SlashCommandBuilder.js +122 -0
  11. package/dist/build copy/ContextCommandBuilder.d.ts +37 -0
  12. package/dist/build copy/ContextCommandBuilder.js +88 -0
  13. package/dist/{mjs/build/EventBuilder.d.ts → build copy/EventBuilder.d.ts } +4 -4
  14. package/dist/build copy/EventBuilder.js +34 -0
  15. package/dist/{cjs/build/InhibitorBuilder.d.ts → build copy/InhibitorBuilder.d.ts } +2 -2
  16. package/dist/build copy/InhibitorBuilder.js +27 -0
  17. package/dist/{cjs/build/MessageCommandBuilder.d.ts → build copy/MessageCommandBuilder.d.ts } +14 -34
  18. package/dist/build copy/MessageCommandBuilder.js +90 -0
  19. package/dist/build copy/SlashCommandBuilder.d.ts +41 -0
  20. package/dist/build copy/SlashCommandBuilder.js +122 -0
  21. package/dist/client/DBLClient.d.ts +8 -0
  22. package/dist/client/DBLClient.js +15 -0
  23. package/dist/client/Top.ggClient.d.ts +1 -0
  24. package/dist/client/Top.ggClient.js +1 -0
  25. package/dist/client/XernerxClient.d.ts +54 -0
  26. package/dist/client/XernerxClient.js +90 -0
  27. package/dist/events/messageCreate.d.ts +1 -0
  28. package/dist/events/messageCreate.js +1 -0
  29. package/dist/functions/AsyncFunctions.d.ts +1 -0
  30. package/dist/functions/AsyncFunctions.js +1 -0
  31. package/dist/functions/delay.d.ts +1 -0
  32. package/dist/functions/delay.js +3 -0
  33. package/dist/functions/deploy.d.ts +2 -0
  34. package/dist/functions/deploy.js +29 -0
  35. package/dist/functions/getPermissionBitField.d.ts +2 -0
  36. package/dist/functions/getPermissionBitField.js +17 -0
  37. package/dist/functions/hasVoted.d.ts +1 -0
  38. package/dist/functions/hasVoted.js +1 -0
  39. package/dist/functions/isOwner.d.ts +3 -0
  40. package/dist/functions/isOwner.js +3 -0
  41. package/dist/functions/isVoter.d.ts +3 -0
  42. package/dist/functions/isVoter.js +5 -0
  43. package/dist/functions/load.d.ts +3 -0
  44. package/dist/functions/load.js +32 -0
  45. package/dist/functions/reload.d.ts +2 -0
  46. package/dist/functions/reload.js +39 -0
  47. package/dist/functions/sendWebhook.d.ts +2 -0
  48. package/dist/functions/sendWebhook.js +12 -0
  49. package/dist/functions/voted.d.ts +1 -0
  50. package/dist/functions/voted.js +1 -0
  51. package/dist/functions/xernerxUser.d.ts +3 -0
  52. package/dist/functions/xernerxUser.js +8 -0
  53. package/dist/handlers/CommandHandler.d.ts +13 -0
  54. package/dist/handlers/CommandHandler.js +220 -0
  55. package/dist/handlers/EventHandler.d.ts +7 -0
  56. package/dist/handlers/EventHandler.js +24 -0
  57. package/dist/handlers/ExtensionHandler.d.ts +7 -0
  58. package/dist/handlers/ExtensionHandler.js +19 -0
  59. package/dist/handlers/Handler.d.ts +14 -0
  60. package/dist/handlers/Handler.js +36 -0
  61. package/dist/handlers/InhibitorHandler.d.ts +7 -0
  62. package/dist/handlers/InhibitorHandler.js +24 -0
  63. package/dist/handlers/WebhookHandler.d.ts +7 -0
  64. package/dist/handlers/WebhookHandler.js +50 -0
  65. package/dist/main.d.ts +11 -0
  66. package/dist/main.js +11 -0
  67. package/dist/models/Arguments.d.ts +15 -0
  68. package/dist/models/Arguments.js +129 -0
  69. package/dist/{mjs/models → models}/CommandArguments.js +2 -7
  70. package/dist/{mjs/models → models}/Events.js +44 -54
  71. package/dist/models/Extensions.js +23 -0
  72. package/dist/models/XernerxUser.d.ts +2 -0
  73. package/dist/models/XernerxUser.js +9 -0
  74. package/dist/tools/XernerxError.d.ts +6 -0
  75. package/dist/tools/XernerxError.js +10 -0
  76. package/dist/tools/XernerxLog.d.ts +13 -0
  77. package/dist/tools/XernerxLog.js +30 -0
  78. package/dist/tools/classes.d.ts +6 -0
  79. package/dist/tools/classes.js +10 -0
  80. package/dist/tools/loggers.d.ts +4 -0
  81. package/dist/tools/loggers.js +4 -0
  82. package/dist/{cjs/tools → tools}/package.d.ts +5 -9
  83. package/dist/{cjs/tools → tools}/package.js +12 -18
  84. package/dist/{cjs/types → types}/enums.js +8 -11
  85. package/dist/types/extenders.d.ts +23 -0
  86. package/dist/types/extenders.js +1 -0
  87. package/dist/types/interfaces.d.ts +224 -0
  88. package/dist/types/interfaces.js +1 -0
  89. package/dist/{cjs/types → types}/options.d.ts +13 -0
  90. package/dist/types/options.js +1 -0
  91. package/dist/types/types.d.ts +181 -0
  92. package/dist/types/types.js +1 -0
  93. package/dist/utils/ClientUtil.d.ts +6 -0
  94. package/dist/utils/ClientUtil.js +7 -0
  95. package/dist/{cjs/utils → utils}/CommandUtil.js +14 -29
  96. package/dist/utils/InteractionArguments.d.ts +1 -0
  97. package/dist/utils/InteractionArguments.js +1 -0
  98. package/dist/utils/InteractionUtil.d.ts +10 -0
  99. package/dist/utils/InteractionUtil.js +15 -0
  100. package/dist/utils/MessageUtil.d.ts +11 -0
  101. package/dist/utils/MessageUtil.js +42 -0
  102. package/dist/utils/Util.d.ts +5 -0
  103. package/dist/utils/Util.js +6 -0
  104. package/dist/{mjs/validators → validators}/CommandValidations.js +11 -14
  105. package/dist/validators/InhibitorValidations.d.ts +18 -0
  106. package/dist/validators/InhibitorValidations.js +34 -0
  107. package/dist/validators/commandValidation.d.ts +6 -0
  108. package/dist/validators/commandValidation.js +48 -0
  109. package/dist/validators/commands.d.ts +4 -0
  110. package/dist/validators/commands.js +25 -0
  111. package/package.json +10 -13
  112. package/dist/cjs/build/ContextCommandBuilder.d.ts +0 -68
  113. package/dist/cjs/build/ContextCommandBuilder.js +0 -97
  114. package/dist/cjs/build/EventBuilder.js +0 -44
  115. package/dist/cjs/build/InhibitorBuilder.js +0 -37
  116. package/dist/cjs/build/MessageCommandBuilder.js +0 -100
  117. package/dist/cjs/build/SlashCommandBuilder.js +0 -169
  118. package/dist/cjs/client/XernerxClient.d.ts +0 -28
  119. package/dist/cjs/client/XernerxClient.js +0 -116
  120. package/dist/cjs/handlers/CommandHandler.d.ts +0 -27
  121. package/dist/cjs/handlers/CommandHandler.js +0 -45
  122. package/dist/cjs/handlers/EventHandler.d.ts +0 -13
  123. package/dist/cjs/handlers/EventHandler.js +0 -19
  124. package/dist/cjs/handlers/Handler.d.ts +0 -57
  125. package/dist/cjs/handlers/Handler.js +0 -308
  126. package/dist/cjs/handlers/InhibitorHandler.d.ts +0 -18
  127. package/dist/cjs/handlers/InhibitorHandler.js +0 -24
  128. package/dist/cjs/main.d.ts +0 -44
  129. package/dist/cjs/main.js +0 -112
  130. package/dist/cjs/models/CommandArguments.js +0 -106
  131. package/dist/cjs/models/Events.js +0 -307
  132. package/dist/cjs/models/Extensions.js +0 -26
  133. package/dist/cjs/tools/XernerxError.d.ts +0 -5
  134. package/dist/cjs/tools/XernerxError.js +0 -11
  135. package/dist/cjs/types/interfaces.d.ts +0 -25
  136. package/dist/cjs/types/interfaces.js +0 -2
  137. package/dist/cjs/types/options.js +0 -2
  138. package/dist/cjs/types/types.d.ts +0 -61
  139. package/dist/cjs/types/types.js +0 -2
  140. package/dist/cjs/utils/ClientUtil.d.ts +0 -25
  141. package/dist/cjs/utils/ClientUtil.js +0 -211
  142. package/dist/cjs/validators/CommandValidations.js +0 -169
  143. package/dist/cjs/validators/InhibitorValidations.d.ts +0 -11
  144. package/dist/cjs/validators/InhibitorValidations.js +0 -40
  145. package/dist/mjs/build/ContextCommandBuilder.d.ts +0 -68
  146. package/dist/mjs/build/ContextCommandBuilder.js +0 -97
  147. package/dist/mjs/build/EventBuilder.js +0 -44
  148. package/dist/mjs/build/InhibitorBuilder.d.ts +0 -19
  149. package/dist/mjs/build/InhibitorBuilder.js +0 -37
  150. package/dist/mjs/build/MessageCommandBuilder.d.ts +0 -59
  151. package/dist/mjs/build/MessageCommandBuilder.js +0 -100
  152. package/dist/mjs/build/SlashCommandBuilder.d.ts +0 -65
  153. package/dist/mjs/build/SlashCommandBuilder.js +0 -169
  154. package/dist/mjs/client/XernerxClient.d.ts +0 -28
  155. package/dist/mjs/client/XernerxClient.js +0 -116
  156. package/dist/mjs/handlers/CommandHandler.d.ts +0 -27
  157. package/dist/mjs/handlers/CommandHandler.js +0 -45
  158. package/dist/mjs/handlers/EventHandler.d.ts +0 -13
  159. package/dist/mjs/handlers/EventHandler.js +0 -19
  160. package/dist/mjs/handlers/Handler.d.ts +0 -57
  161. package/dist/mjs/handlers/Handler.js +0 -308
  162. package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -18
  163. package/dist/mjs/handlers/InhibitorHandler.js +0 -24
  164. package/dist/mjs/main.d.ts +0 -44
  165. package/dist/mjs/main.js +0 -112
  166. package/dist/mjs/models/CommandArguments.d.ts +0 -17
  167. package/dist/mjs/models/Events.d.ts +0 -24
  168. package/dist/mjs/models/Extensions.d.ts +0 -7
  169. package/dist/mjs/models/Extensions.js +0 -26
  170. package/dist/mjs/tools/XernerxError.d.ts +0 -5
  171. package/dist/mjs/tools/XernerxError.js +0 -11
  172. package/dist/mjs/tools/package.d.ts +0 -49
  173. package/dist/mjs/tools/package.js +0 -50
  174. package/dist/mjs/types/enums.d.ts +0 -44
  175. package/dist/mjs/types/enums.js +0 -38
  176. package/dist/mjs/types/interfaces.d.ts +0 -25
  177. package/dist/mjs/types/interfaces.js +0 -2
  178. package/dist/mjs/types/options.d.ts +0 -241
  179. package/dist/mjs/types/options.js +0 -2
  180. package/dist/mjs/types/types.d.ts +0 -61
  181. package/dist/mjs/types/types.js +0 -2
  182. package/dist/mjs/utils/ClientUtil.d.ts +0 -25
  183. package/dist/mjs/utils/ClientUtil.js +0 -211
  184. package/dist/mjs/utils/CommandUtil.d.ts +0 -58
  185. package/dist/mjs/utils/CommandUtil.js +0 -247
  186. package/dist/mjs/validators/CommandValidations.d.ts +0 -12
  187. package/dist/mjs/validators/InhibitorValidations.d.ts +0 -11
  188. package/dist/mjs/validators/InhibitorValidations.js +0 -40
  189. /package/dist/{cjs/models → models}/CommandArguments.d.ts +0 -0
  190. /package/dist/{cjs/models → models}/Events.d.ts +0 -0
  191. /package/dist/{cjs/models → models}/Extensions.d.ts +0 -0
  192. /package/dist/{cjs/types → types}/enums.d.ts +0 -0
  193. /package/dist/{cjs/utils → utils}/CommandUtil.d.ts +0 -0
  194. /package/dist/{cjs/validators → validators}/CommandValidations.d.ts +0 -0
@@ -0,0 +1,47 @@
1
+ import { ContextMenuCommandBuilder } from 'discord.js';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ import { XernerxMessageContextInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
4
+ import { ContextCommandOptions } from '../types/interfaces.js';
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:
15
+ | {
16
+ owner?: boolean | undefined;
17
+ users?: string[] | undefined;
18
+ channels?: string[] | undefined;
19
+ guilds?: string[] | undefined;
20
+ }
21
+ | undefined;
22
+ strict:
23
+ | {
24
+ owner?: boolean | undefined;
25
+ users?: string[] | undefined;
26
+ channels?: string[] | undefined;
27
+ guilds?: string[] | undefined;
28
+ }
29
+ | undefined;
30
+ permissions:
31
+ | {
32
+ user?: string[] | import('../types/types.js').PermissionNames[] | undefined;
33
+ client?: string[] | import('../types/types.js').PermissionNames[] | undefined;
34
+ dm?: boolean | undefined;
35
+ }
36
+ | undefined;
37
+ defer:
38
+ | {
39
+ reply?: boolean | undefined;
40
+ ephemeral?: boolean | undefined;
41
+ fetchReply?: boolean | undefined;
42
+ }
43
+ | undefined;
44
+ client: typeof XernerxClient;
45
+ constructor(id: string, options: ContextCommandOptions);
46
+ exec(interaction: XernerxUserContextInteraction | XernerxMessageContextInteraction): Promise<void>;
47
+ }
@@ -0,0 +1,78 @@
1
+ import { ContextMenuCommandBuilder } from 'discord.js';
2
+ import { z } from 'zod';
3
+ import XernerxClient from '../client/XernerxClient.js';
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
+ constructor(id, options) {
19
+ this.id = id;
20
+ this.data = new ContextMenuCommandBuilder();
21
+ this.data.setName(options.name);
22
+ this.data.setNameLocalizations(options.nameLocalizations || null);
23
+ this.data.setType(options.type === 'user' ? 2 : 3);
24
+ this.data.setDMPermission(options.permissions?.dm || null);
25
+ options = z
26
+ .object({
27
+ name: z.string(),
28
+ type: z.enum(['user', 'message']),
29
+ description: z.string().or(z.null()).default(null),
30
+ info: z.string().or(z.null()).default(null),
31
+ category: z.string().or(z.null()).default(null),
32
+ cooldown: z.number().or(z.null()).default(null),
33
+ ignore: z
34
+ .object({
35
+ owner: z.boolean().default(false),
36
+ users: z.array(z.string()).default([]),
37
+ channels: z.array(z.string()).default([]),
38
+ guilds: z.array(z.string()).default([]),
39
+ })
40
+ .default({}),
41
+ strict: z
42
+ .object({
43
+ owner: z.boolean().default(false),
44
+ users: z.array(z.string()).default([]),
45
+ channels: z.array(z.string()).default([]),
46
+ guilds: z.array(z.string()).default([]),
47
+ })
48
+ .default({}),
49
+ permissions: z
50
+ .object({
51
+ user: z.array(z.string()).default([]),
52
+ client: z.array(z.string()).default([]),
53
+ dm: z.boolean().default(true),
54
+ })
55
+ .default({}),
56
+ defer: z
57
+ .object({
58
+ reply: z.boolean().default(false),
59
+ ephemeral: z.boolean().default(false),
60
+ fetch: z.boolean().default(false),
61
+ })
62
+ .default({}),
63
+ })
64
+ .parse(options);
65
+ this.name = options.name;
66
+ this.type = options.type;
67
+ this.description = options.description;
68
+ this.info = options.info;
69
+ this.category = options.category;
70
+ this.cooldown = options.cooldown;
71
+ this.ignore = options.ignore;
72
+ this.strict = options.strict;
73
+ this.permissions = options.permissions;
74
+ this.defer = options.defer;
75
+ this.client = XernerxClient;
76
+ }
77
+ async exec(interaction) {}
78
+ }
@@ -1,5 +1,6 @@
1
1
  import XernerxClient from '../client/XernerxClient.js';
2
- import { EventOptions } from '../types/options.js';
2
+ import { EventBuilderOptions } from '../types/interfaces.js';
3
+ import { EventType } from '../types/types.js';
3
4
  /**
4
5
  * @description - The event builder for events.
5
6
  * @param {String} id - The unique ID of the event.
@@ -7,15 +8,15 @@ import { EventOptions } from '../types/options.js';
7
8
  */
8
9
  export default class EventBuilder {
9
10
  id: string;
10
- name: string;
11
- emitter: string;
12
- type: string;
11
+ name: EventType;
12
+ emitter: 'client' | 'process' | string;
13
+ type: 'discord' | string;
13
14
  once: boolean;
14
15
  client: typeof XernerxClient;
15
- constructor(id: string, options: EventOptions);
16
+ constructor(id: string, options: EventBuilderOptions);
16
17
  /**
17
18
  * @description run your custom event here.
18
19
  * TODO - update description
19
20
  */
20
- run(): Promise<void>;
21
+ run<T extends Array<T>>(...args: T): Promise<void>;
21
22
  }
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ // import { EventOptions } from '../types/options.js';
4
+ /**
5
+ * @description - The event builder for events.
6
+ * @param {String} id - The unique ID of the event.
7
+ * @param {EventOptions} options - The event options.
8
+ */
9
+ export default class EventBuilder {
10
+ id;
11
+ name;
12
+ emitter;
13
+ type;
14
+ once;
15
+ client;
16
+ constructor(id, options) {
17
+ this.id = id;
18
+ z.object({
19
+ name: z.string(),
20
+ emitter: z.string().optional(),
21
+ type: z.string().optional(),
22
+ once: z.boolean().optional(),
23
+ }).parse(options);
24
+ this.name = options.name;
25
+ this.emitter = options.emitter || 'client';
26
+ this.type = options.type || 'discord';
27
+ this.once = options.once || false;
28
+ this.client = XernerxClient;
29
+ }
30
+ /**
31
+ * @description run your custom event here.
32
+ * TODO - update description
33
+ */
34
+ async run(...args) {}
35
+ }
@@ -0,0 +1,17 @@
1
+ import XernerxClient from '../client/XernerxClient.js';
2
+ import { InhibitorBuilderOptions } from '../types/interfaces.js';
3
+ import { InhibitorType, XernerxInteraction } from '../types/types.js';
4
+ import { XernerxMessage } from '../types/extenders.js';
5
+ /**
6
+ * @description - The inhibitor builder for inhibitors.
7
+ * @param {String} id - The unique ID of the inhibitor.
8
+ * @param {InhibitorOptions} options - The inhibitor options.
9
+ */
10
+ export default class InhibitorBuilder {
11
+ id: string;
12
+ name: string;
13
+ type: InhibitorType;
14
+ client: typeof XernerxClient;
15
+ constructor(id: string, options: InhibitorBuilderOptions);
16
+ check(action: XernerxInteraction | XernerxMessage, args: any): Promise<void>;
17
+ }
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ // import { InhibitorOptions, MessageArgumentOptions, SlashArgumentOptions } from '../types/options.js';
4
+ // import { XernerxInteraction, XernerxMessage } from '../types/types.js';
5
+ /**
6
+ * @description - The inhibitor builder for inhibitors.
7
+ * @param {String} id - The unique ID of the inhibitor.
8
+ * @param {InhibitorOptions} options - The inhibitor options.
9
+ */
10
+ export default class InhibitorBuilder {
11
+ id;
12
+ name;
13
+ type;
14
+ client;
15
+ constructor(id, options) {
16
+ this.id = id;
17
+ z.object({
18
+ name: z.string(),
19
+ type: z.string(),
20
+ }).parse(options);
21
+ this.name = options.name;
22
+ this.type = options.type;
23
+ this.client = XernerxClient;
24
+ }
25
+ async check(action, args) {}
26
+ }
@@ -0,0 +1,43 @@
1
+ import XernerxClient from '../client/XernerxClient.js';
2
+ import { XernerxMessage } from '../types/extenders.js';
3
+ import { MessageCommandArguments, MessageCommandOptions } from '../types/interfaces.js';
4
+ export default class MessageCommandBuilder {
5
+ id: string;
6
+ name: string;
7
+ regex: RegExp | undefined;
8
+ prefix: string | string[] | undefined;
9
+ description: string | null | undefined;
10
+ info: string | null | undefined;
11
+ separator: string | undefined;
12
+ args: import('../types/interfaces.js').MessageCommandArgumentOptions[] | undefined;
13
+ flags: import('../types/interfaces.js').MessageCommandFlagOptions[] | undefined;
14
+ category: string | null | undefined;
15
+ cooldown: number | null | undefined;
16
+ ignore:
17
+ | {
18
+ owner?: boolean | undefined;
19
+ users?: string[] | undefined;
20
+ channels?: string[] | undefined;
21
+ guilds?: string[] | undefined;
22
+ }
23
+ | undefined;
24
+ strict:
25
+ | {
26
+ owner?: boolean | undefined;
27
+ users?: string[] | undefined;
28
+ channels?: string[] | undefined;
29
+ guilds?: string[] | undefined;
30
+ }
31
+ | undefined;
32
+ permissions:
33
+ | {
34
+ user?: string[] | import('../types/types.js').PermissionNames[] | undefined;
35
+ client?: string[] | import('../types/types.js').PermissionNames[] | undefined;
36
+ dm?: boolean | undefined;
37
+ }
38
+ | undefined;
39
+ client: typeof XernerxClient;
40
+ constructor(id: string, options: MessageCommandOptions);
41
+ conditions(message: XernerxMessage, args: MessageCommandArguments): Promise<void>;
42
+ exec(message: XernerxMessage, args: MessageCommandArguments): Promise<void>;
43
+ }
@@ -0,0 +1,71 @@
1
+ import { z } from 'zod';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ export default class MessageCommandBuilder {
4
+ id;
5
+ name;
6
+ regex;
7
+ prefix;
8
+ description;
9
+ info;
10
+ separator;
11
+ args;
12
+ flags;
13
+ category;
14
+ cooldown;
15
+ ignore;
16
+ strict;
17
+ permissions;
18
+ client;
19
+ constructor(id, options) {
20
+ this.id = id;
21
+ this.regex = options.regex;
22
+ this.args = options.args;
23
+ this.flags = options.flags;
24
+ options = z
25
+ .object({
26
+ name: z.string(),
27
+ description: z.string().or(z.null()).default(null),
28
+ info: z.string().or(z.null()).default(null),
29
+ category: z.string().or(z.null()).default(null),
30
+ cooldown: z.number().or(z.null()).default(null),
31
+ prefix: z.array(z.string()).or(z.string()).default([]),
32
+ ignore: z
33
+ .object({
34
+ owner: z.boolean().default(false),
35
+ users: z.array(z.string()).default([]),
36
+ channels: z.array(z.string()).default([]),
37
+ guilds: z.array(z.string()).default([]),
38
+ })
39
+ .default({}),
40
+ strict: z
41
+ .object({
42
+ owner: z.boolean().default(false),
43
+ users: z.array(z.string()).default([]),
44
+ channels: z.array(z.string()).default([]),
45
+ guilds: z.array(z.string()).default([]),
46
+ })
47
+ .default({}),
48
+ permissions: z
49
+ .object({
50
+ user: z.array(z.string()).default([]),
51
+ client: z.array(z.string()).default([]),
52
+ dm: z.boolean().default(true),
53
+ })
54
+ .default({}),
55
+ })
56
+ .parse(options);
57
+ this.name = options.name;
58
+ this.prefix = options.prefix;
59
+ this.description = options.description;
60
+ this.info = options.info;
61
+ this.category = options.category;
62
+ this.cooldown = options.cooldown;
63
+ this.ignore = options.ignore;
64
+ this.strict = options.strict;
65
+ this.separator = options.separator;
66
+ this.permissions = options.permissions;
67
+ this.client = XernerxClient;
68
+ }
69
+ async conditions(message, args) {}
70
+ async exec(message, args) {}
71
+ }
@@ -1,21 +1,15 @@
1
- import * as Discord from 'discord.js';
2
- import { Interaction } from 'discord.js';
3
- import { SlashCommandOptions } from '../types/options.js';
1
+ import Discord from 'discord.js';
4
2
  import XernerxClient from '../client/XernerxClient.js';
5
- /**
6
- * @description - The command builder for slash commands.
7
- * @param {String} id - The unique ID of the command.
8
- * @param {SlashCommandOptions} options - The command options.
9
- */
3
+ import { XernerxSlashInteraction } from '../types/extenders.js';
4
+ import { SlashCommandArguments, SlashCommandOptions } from '../types/interfaces.js';
10
5
  export default class SlashCommandBuilder {
11
6
  id: string;
12
7
  data: Discord.SlashCommandBuilder;
13
8
  name: string;
14
9
  description: string;
15
- info: string | undefined;
16
- category: string | undefined;
17
- channelType: Discord.ChannelType | undefined;
18
- cooldown: number | undefined;
10
+ info: string | null | undefined;
11
+ category: string | null | undefined;
12
+ cooldown: number | null | undefined;
19
13
  ignore:
20
14
  | {
21
15
  owner?: boolean | undefined;
@@ -32,14 +26,13 @@ export default class SlashCommandBuilder {
32
26
  guilds?: string[] | undefined;
33
27
  }
34
28
  | undefined;
35
- permissions: {
36
- client?: string[] | undefined;
37
- users?: string[] | undefined;
38
- dm?: boolean | undefined;
39
- };
40
- args?: object[];
41
- subcommands?: object[];
42
- groups?: object[];
29
+ permissions:
30
+ | {
31
+ user?: string[] | import('../types/types.js').PermissionNames[] | undefined;
32
+ client?: string[] | import('../types/types.js').PermissionNames[] | undefined;
33
+ dm?: boolean | undefined;
34
+ }
35
+ | undefined;
43
36
  defer:
44
37
  | {
45
38
  reply?: boolean | undefined;
@@ -49,17 +42,9 @@ export default class SlashCommandBuilder {
49
42
  | undefined;
50
43
  client: typeof XernerxClient;
51
44
  constructor(id: string, options: SlashCommandOptions);
52
- /**
53
- * TODO - update description
54
- * @param interaction
55
- */
56
- conditions(interaction: Interaction): Promise<void>;
57
- /**
58
- * TODO - update description
59
- * @param interaction
60
- */
61
- exec(interaction: Interaction): Promise<void>;
62
- private addArgs;
45
+ conditions(interaction: XernerxSlashInteraction, args: SlashCommandArguments): Promise<void>;
46
+ exec(interaction: XernerxSlashInteraction, args: SlashCommandArguments): Promise<void>;
47
+ private addArguments;
63
48
  private addSubcommands;
64
49
  private addSubcommandGroups;
65
50
  }
@@ -0,0 +1,122 @@
1
+ import Discord, { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from 'discord.js';
2
+ import { z } from 'zod';
3
+ import XernerxClient from '../client/XernerxClient.js';
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
+ constructor(id, options) {
18
+ this.id = id;
19
+ this.data = new Discord.SlashCommandBuilder();
20
+ this.data.setName(options.name);
21
+ this.data.setNameLocalizations(options.nameLocalizations || null);
22
+ this.data.setDescription(options.description);
23
+ this.data.setDescriptionLocalizations(options.descriptionLocalizations || null);
24
+ this.data.setDMPermission(options.permissions?.dm || null);
25
+ if (options.args && options?.args?.length > 0) {
26
+ this.addArguments(this.data, options.args);
27
+ }
28
+ if (options.subcommands && options?.subcommands?.length > 0) {
29
+ this.addSubcommands(this.data, options.subcommands);
30
+ }
31
+ if (options.groups && options?.groups?.length > 0) {
32
+ this.addSubcommandGroups(options.groups);
33
+ }
34
+ options = z
35
+ .object({
36
+ name: z.string(),
37
+ description: z.string(),
38
+ info: z.string().or(z.null()).default(null),
39
+ category: z.string().or(z.null()).default(null),
40
+ number: z.number().or(z.null()).default(null),
41
+ channelType: z.array(z.number()).or(z.null()).default(null),
42
+ ignore: z
43
+ .object({
44
+ owner: z.boolean().default(false),
45
+ users: z.array(z.string()).default([]),
46
+ channels: z.array(z.string()).default([]),
47
+ guilds: z.array(z.string()).default([]),
48
+ })
49
+ .default({}),
50
+ strict: z
51
+ .object({
52
+ owner: z.boolean().default(false),
53
+ users: z.array(z.string()).default([]),
54
+ channels: z.array(z.string()).default([]),
55
+ guilds: z.array(z.string()).default([]),
56
+ })
57
+ .default({}),
58
+ permissions: z
59
+ .object({
60
+ user: z.array(z.string()).default([]),
61
+ client: z.array(z.string()).default([]),
62
+ dm: z.boolean().default(true),
63
+ })
64
+ .default({}),
65
+ defer: z
66
+ .object({
67
+ reply: z.boolean().default(false),
68
+ ephemeral: z.boolean().default(false),
69
+ fetch: z.boolean().default(false),
70
+ })
71
+ .default({}),
72
+ })
73
+ .parse(options);
74
+ this.name = options.name;
75
+ this.description = options.description;
76
+ this.info = options.info;
77
+ this.category = options.category;
78
+ this.cooldown = options.cooldown;
79
+ this.ignore = options.ignore;
80
+ this.strict = options.strict;
81
+ this.permissions = options.permissions;
82
+ this.defer = options.defer;
83
+ this.client = XernerxClient;
84
+ }
85
+ async conditions(interaction, args) {}
86
+ async exec(interaction, args) {}
87
+ addArguments(command, args) {
88
+ for (const argument of args) {
89
+ let slashCommandArgumentType = `${argument.type.charAt(0).toUpperCase()}${argument.type.slice(1).toLowerCase()}`;
90
+ command[`add${slashCommandArgumentType}Option`]((option) => {
91
+ option
92
+ .setName(argument.name)
93
+ .setDescription(argument.description)
94
+ .setRequired(argument.required || false);
95
+ if (slashCommandArgumentType === 'String') {
96
+ if (argument.choices)
97
+ option.setChoices(
98
+ ...argument.choices.map((choices) => {
99
+ return { name: Object.keys(choices).at(0), value: Object.values(choices).at(0) };
100
+ })
101
+ );
102
+ option.setAutocomplete(argument.autocomplete || false);
103
+ }
104
+ return option;
105
+ });
106
+ }
107
+ }
108
+ addSubcommands(method, subcommands) {
109
+ for (const subcommand of subcommands) {
110
+ let sub = new SlashCommandSubcommandBuilder().setName(subcommand.name).setDescription(subcommand.description);
111
+ if (subcommand.args?.length > 0) this.addArguments(sub, subcommand.args);
112
+ method.addSubcommand(sub);
113
+ }
114
+ }
115
+ addSubcommandGroups(groups) {
116
+ for (const group of groups) {
117
+ let subcommandGroup = new SlashCommandSubcommandGroupBuilder().setName(group.name).setDescription(group.description);
118
+ if (group.subcommands?.length > 0) this.addSubcommands(subcommandGroup, group.subcommands);
119
+ this.data.addSubcommandGroup(subcommandGroup);
120
+ }
121
+ }
122
+ }
@@ -0,0 +1,37 @@
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: any;
13
+ type: any;
14
+ description: any;
15
+ info: any;
16
+ category: any;
17
+ channelType: any;
18
+ cooldown: any;
19
+ ignore: any;
20
+ strict: any;
21
+ permissions: any;
22
+ defer: any;
23
+ client: typeof XernerxClient;
24
+ constructor(id: string, options: ContextCommandOptions);
25
+ /**
26
+ * @param {Interaction} interaction - The Discord interaction event data.
27
+ * @description make any preconditions here.
28
+ * TODO - update description
29
+ */
30
+ conditions(interaction: Interaction, args: any): Promise<void>;
31
+ /**
32
+ * @param {Interaction} interaction - The Discord interaction event data.
33
+ * @description Make your custom command here.
34
+ * TODO - update description
35
+ */
36
+ exec(interaction: Interaction, args: any): Promise<void>;
37
+ }
@@ -0,0 +1,88 @@
1
+ import { ContextMenuCommandBuilder } from 'discord.js';
2
+ import { z } from 'zod';
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;
11
+ data;
12
+ name;
13
+ type;
14
+ description;
15
+ info;
16
+ category;
17
+ channelType;
18
+ cooldown;
19
+ ignore;
20
+ strict;
21
+ permissions;
22
+ defer;
23
+ client;
24
+ constructor(id, options) {
25
+ this.id = id;
26
+ this.data = new ContextMenuCommandBuilder();
27
+ if (options.name) this.data.setName(options.name);
28
+ if (options.type) this.data.setType(options.type);
29
+ if (options.permissions?.users) this.data.setDefaultMemberPermissions(options.permissions?.users);
30
+ if (options.permissions?.dm === false) this.data.setDMPermission(options.permissions?.dm);
31
+ if (options.nameLocalizations) this.data.setNameLocalizations(options.nameLocalizations);
32
+ z.object({
33
+ description: z.string(),
34
+ info: z.string(),
35
+ category: z.string(),
36
+ channelType: z.array(z.number()).or(z.number()),
37
+ cooldown: z.number(),
38
+ ignore: z.object({
39
+ owner: z.boolean(),
40
+ users: z.array(z.string()),
41
+ channels: z.array(z.string()),
42
+ guilds: z.array(z.string()),
43
+ }),
44
+ strict: z.object({
45
+ owner: z.boolean(),
46
+ users: z.array(z.string()),
47
+ channels: z.array(z.string()),
48
+ guilds: z.array(z.string()),
49
+ }),
50
+ permissions: z.object({
51
+ client: z.array(z.string()),
52
+ users: z.array(z.string()),
53
+ dm: z.boolean(),
54
+ }),
55
+ defer: z.object({
56
+ reply: z.boolean(),
57
+ ephemeral: z.boolean(),
58
+ fetch: z.boolean(),
59
+ }),
60
+ })
61
+ .deepPartial()
62
+ .parse(options);
63
+ this.name = options.name;
64
+ this.type = options.type;
65
+ this.description = options.description;
66
+ this.info = options.info;
67
+ this.category = options.category;
68
+ this.channelType = options.channelType;
69
+ this.cooldown = options.cooldown;
70
+ this.ignore = options.ignore;
71
+ this.strict = options.strict;
72
+ this.permissions = options.permissions;
73
+ this.defer = options.defer;
74
+ this.client = XernerxClient;
75
+ }
76
+ /**
77
+ * @param {Interaction} interaction - The Discord interaction event data.
78
+ * @description make any preconditions here.
79
+ * TODO - update description
80
+ */
81
+ async conditions(interaction, args) {}
82
+ /**
83
+ * @param {Interaction} interaction - The Discord interaction event data.
84
+ * @description Make your custom command here.
85
+ * TODO - update description
86
+ */
87
+ async exec(interaction, args) {}
88
+ }