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
@@ -7,10 +7,10 @@ import { EventOptions } from '../types/options.js';
7
7
  */
8
8
  export default class EventBuilder {
9
9
  id: string;
10
- name: string;
11
- emitter: string;
12
- type: string;
13
- once: boolean;
10
+ name: any;
11
+ emitter: any;
12
+ type: any;
13
+ once: any;
14
14
  client: typeof XernerxClient;
15
15
  constructor(id: string, options: EventOptions);
16
16
  /**
@@ -0,0 +1,34 @@
1
+ import { z } from 'zod';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ /**
4
+ * @description - The event builder for events.
5
+ * @param {String} id - The unique ID of the event.
6
+ * @param {EventOptions} options - The event options.
7
+ */
8
+ export default class EventBuilder {
9
+ id;
10
+ name;
11
+ emitter;
12
+ type;
13
+ once;
14
+ client;
15
+ constructor(id, options) {
16
+ this.id = id;
17
+ z.object({
18
+ name: z.string(),
19
+ emitter: z.string().optional(),
20
+ type: z.string().optional(),
21
+ once: z.boolean().optional(),
22
+ }).parse(options);
23
+ this.name = options.name;
24
+ this.emitter = options.emitter || 'client';
25
+ this.type = options.type || 'discord';
26
+ this.once = options.once || false;
27
+ this.client = XernerxClient;
28
+ }
29
+ /**
30
+ * @description run your custom event here.
31
+ * TODO - update description
32
+ */
33
+ async run() {}
34
+ }
@@ -8,8 +8,8 @@ import { XernerxInteraction, XernerxMessage } from '../types/types.js';
8
8
  */
9
9
  export default class InhibitorBuilder {
10
10
  id: string;
11
- name: string;
12
- type: import('../main.js').InhibitorType;
11
+ name: any;
12
+ type: any;
13
13
  client: typeof XernerxClient;
14
14
  constructor(id: string, options: InhibitorOptions);
15
15
  /**
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ /**
4
+ * @description - The inhibitor builder for inhibitors.
5
+ * @param {String} id - The unique ID of the inhibitor.
6
+ * @param {InhibitorOptions} options - The inhibitor options.
7
+ */
8
+ export default class InhibitorBuilder {
9
+ id;
10
+ name;
11
+ type;
12
+ client;
13
+ constructor(id, options) {
14
+ this.id = id;
15
+ z.object({
16
+ name: z.string(),
17
+ type: z.string(),
18
+ }).parse(options);
19
+ this.name = options.name;
20
+ this.type = options.type;
21
+ this.client = XernerxClient;
22
+ }
23
+ /**
24
+ * TODO - update description
25
+ */
26
+ async check(interaction, args) {}
27
+ }
@@ -8,40 +8,20 @@ import { XernerxMessage } from '../types/types.js';
8
8
  */
9
9
  export default class MessageCommandBuilder {
10
10
  id: string;
11
- name: string;
12
- aliases: string[] | undefined;
13
- separator: string;
14
- description: string | undefined;
15
- info: string | undefined;
16
- category: string | undefined;
17
- prefix: string[];
18
- regex: string | undefined;
19
- channelType: number[] | undefined;
20
- ignore:
21
- | {
22
- owner?: boolean | undefined;
23
- users?: string[] | undefined;
24
- channels?: string[] | undefined;
25
- guilds?: string[] | undefined;
26
- }
27
- | undefined;
28
- strict:
29
- | {
30
- owner?: boolean | undefined;
31
- users?: string[] | undefined;
32
- channels?: string[] | undefined;
33
- guilds?: string[] | undefined;
34
- }
35
- | undefined;
36
- permissions:
37
- | {
38
- client?: string[] | undefined;
39
- user?: string[] | undefined;
40
- dm?: boolean | undefined;
41
- }
42
- | undefined;
43
- cooldown: number;
44
- args: MessageArgumentOptions[];
11
+ name: any;
12
+ aliases: any;
13
+ separator: any;
14
+ description: any;
15
+ info: any;
16
+ category: any;
17
+ prefix: any;
18
+ regex: any;
19
+ channelType: any;
20
+ ignore: any;
21
+ strict: any;
22
+ permissions: any;
23
+ cooldown: any;
24
+ args: any;
45
25
  client: typeof XernerxClient;
46
26
  constructor(id: string, options: MessageCommandOptions);
47
27
  /**
@@ -0,0 +1,90 @@
1
+ import { z } from 'zod';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ /**
4
+ * @description - The command builder for message commands.
5
+ * @param {String} id - The unique ID of the command.
6
+ * @param {MessageCommandOptions} options - The command options.
7
+ */
8
+ export default class MessageCommandBuilder {
9
+ id;
10
+ name;
11
+ aliases;
12
+ separator;
13
+ description;
14
+ info;
15
+ category;
16
+ prefix;
17
+ regex;
18
+ channelType;
19
+ ignore;
20
+ strict;
21
+ permissions;
22
+ cooldown;
23
+ args;
24
+ client;
25
+ constructor(id, options) {
26
+ this.id = id;
27
+ z.object({
28
+ name: z.string(),
29
+ aliases: z.array(z.string()).optional(),
30
+ separator: z.string().min(1).max(1).optional(),
31
+ description: z.string().optional(),
32
+ info: z.string().optional(),
33
+ category: z.string().optional(),
34
+ prefix: z.array(z.string()).or(z.string()).optional(),
35
+ regex: z.unknown(),
36
+ channelType: z.array(z.number()).or(z.number()).optional(),
37
+ cooldown: z.number().optional(),
38
+ ignore: z
39
+ .object({
40
+ owners: z.boolean().optional(),
41
+ users: z.array(z.string()).or(z.string()).optional(),
42
+ channels: z.array(z.string()).or(z.string()).optional(),
43
+ guilds: z.array(z.string()).or(z.string()).optional(),
44
+ })
45
+ .optional(),
46
+ strict: z
47
+ .object({
48
+ owners: z.boolean().optional(),
49
+ users: z.array(z.string()).or(z.string()).optional(),
50
+ channels: z.array(z.string()).or(z.string()).optional(),
51
+ guilds: z.array(z.string()).or(z.string()).optional(),
52
+ })
53
+ .optional(),
54
+ permissions: z
55
+ .object({
56
+ client: z.array(z.string()).optional(),
57
+ users: z.array(z.string()).optional(),
58
+ dm: z.boolean().optional(),
59
+ })
60
+ .optional(),
61
+ }).parse(options);
62
+ this.name = options.name;
63
+ this.aliases = options.aliases;
64
+ this.separator = options.separator || ' ';
65
+ this.description = options.description;
66
+ this.info = options.info;
67
+ this.category = options.category;
68
+ this.prefix = options.prefix ? (Array.isArray(options.prefix) ? options.prefix : [options.prefix]) : [];
69
+ this.regex = options.regex;
70
+ this.channelType = options.channelType;
71
+ this.ignore = options.ignore;
72
+ this.strict = options.strict;
73
+ this.permissions = options.permissions;
74
+ this.cooldown = options.cooldown || 0;
75
+ this.args = options.args || [];
76
+ this.client = XernerxClient;
77
+ }
78
+ /**
79
+ * @param {Message} message - The Discord message event data.
80
+ * @param {object} args - The arguments you created.
81
+ * @description make any preconditions here.
82
+ */
83
+ async conditions(message, args) {}
84
+ /**
85
+ * @param {Message} message - The Discord message event data.
86
+ * @param {object} args - The arguments you created.
87
+ * @description Make your custom command here.
88
+ */
89
+ async exec(message, args) {}
90
+ }
@@ -0,0 +1,41 @@
1
+ import * as Discord from 'discord.js';
2
+ import { Interaction } from 'discord.js';
3
+ import { SlashCommandOptions } from '../types/options.js';
4
+ 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
+ */
10
+ export default class SlashCommandBuilder {
11
+ id: string;
12
+ data: Discord.SlashCommandBuilder;
13
+ name: 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
+ args?: object[];
23
+ subcommands?: object[];
24
+ groups?: object[];
25
+ defer: any;
26
+ client: typeof XernerxClient;
27
+ constructor(id: string, options: SlashCommandOptions);
28
+ /**
29
+ * TODO - update description
30
+ * @param interaction
31
+ */
32
+ conditions(interaction: Interaction): Promise<void>;
33
+ /**
34
+ * TODO - update description
35
+ * @param interaction
36
+ */
37
+ exec(interaction: Interaction): Promise<void>;
38
+ private addArgs;
39
+ private addSubcommands;
40
+ private addSubcommandGroups;
41
+ }
@@ -0,0 +1,122 @@
1
+ import * as Discord from 'discord.js';
2
+ import { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from 'discord.js';
3
+ import { z } from 'zod';
4
+ import XernerxError from '../tools/XernerxError.js';
5
+ import XernerxClient from '../client/XernerxClient.js';
6
+ /**
7
+ * @description - The command builder for slash commands.
8
+ * @param {String} id - The unique ID of the command.
9
+ * @param {SlashCommandOptions} options - The command options.
10
+ */
11
+ export default class SlashCommandBuilder {
12
+ id;
13
+ data;
14
+ name;
15
+ description;
16
+ info;
17
+ category;
18
+ channelType;
19
+ cooldown;
20
+ ignore;
21
+ strict;
22
+ permissions;
23
+ args;
24
+ subcommands;
25
+ groups;
26
+ defer;
27
+ client;
28
+ constructor(id, options) {
29
+ this.id = id;
30
+ this.data = new Discord.SlashCommandBuilder().setName(options.name).setDescription(options.description);
31
+ if (options.args && options?.args?.length > 0) {
32
+ this.addArgs(this.data, options.args);
33
+ }
34
+ if (options.subcommands && options?.subcommands?.length > 0) {
35
+ this.addSubcommands(this.data, options.subcommands);
36
+ }
37
+ if (options.groups && options?.groups?.length > 0) {
38
+ this.addSubcommandGroups(options.groups);
39
+ }
40
+ z.object({
41
+ description: z.string(),
42
+ info: z.string(),
43
+ category: z.string(),
44
+ channelType: z.array(z.number()).or(z.number()),
45
+ cooldown: z.number(),
46
+ ignore: z.object({
47
+ owner: z.boolean(),
48
+ users: z.array(z.string()),
49
+ channels: z.array(z.string()),
50
+ guilds: z.array(z.string()),
51
+ }),
52
+ strict: z.object({
53
+ owner: z.boolean(),
54
+ users: z.array(z.string()),
55
+ channels: z.array(z.string()),
56
+ guilds: z.array(z.string()),
57
+ }),
58
+ permissions: z.object({
59
+ client: z.array(z.string()),
60
+ users: z.array(z.string()),
61
+ dm: z.boolean(),
62
+ }),
63
+ defer: z.object({
64
+ reply: z.boolean(),
65
+ ephemeral: z.boolean(),
66
+ fetch: z.boolean(),
67
+ }),
68
+ })
69
+ .deepPartial()
70
+ .parse(options);
71
+ this.name = options.name;
72
+ this.description = options.description;
73
+ this.info = options.info;
74
+ this.category = options.category;
75
+ this.channelType = options.channelType;
76
+ this.cooldown = options.cooldown;
77
+ this.ignore = options.ignore;
78
+ this.strict = options.strict;
79
+ this.permissions = options.permissions;
80
+ this.defer = options.defer;
81
+ this.client = XernerxClient;
82
+ }
83
+ /**
84
+ * TODO - update description
85
+ * @param interaction
86
+ */
87
+ async conditions(interaction) {}
88
+ /**
89
+ * TODO - update description
90
+ * @param interaction
91
+ */
92
+ async exec(interaction) {}
93
+ addArgs(command, args) {
94
+ const types = ['boolean', 'integer', 'number', 'string', 'user', 'role', 'channel', 'mentionable'];
95
+ for (const argument of args) {
96
+ if (!types.includes(argument.type.toLowerCase())) throw new XernerxError(`Expected one of ${types.join(', ')}, received ${argument.type} instead.`);
97
+ let slashArgumentType = `${argument.type.slice(0, 1).toUpperCase()}${argument.type.slice(1).toLowerCase()}`;
98
+ command[`add${slashArgumentType}Option`]((option) => {
99
+ option
100
+ .setName(argument.name)
101
+ .setDescription(argument.description)
102
+ .setRequired(argument.required || false);
103
+ if (argument.choices) option.setChoices(...argument?.choices);
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.addArgs(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,8 @@
1
+ import { DBL } from 'dbl-sdk';
2
+ import XernerxClient from './XernerxClient.js';
3
+ import { DBLOptions } from '../types/interfaces.js';
4
+ export default class DBLClient {
5
+ dbl: DBL | null;
6
+ readonly client: XernerxClient;
7
+ constructor(client: any, options: DBLOptions);
8
+ }
@@ -0,0 +1,15 @@
1
+ import { DBL, hasVoted } from 'dbl-sdk';
2
+ import XernerxLog from '../tools/XernerxLog.js';
3
+ export default class DBLClient {
4
+ dbl;
5
+ client;
6
+ constructor(client, options) {
7
+ this.dbl = null;
8
+ this.client = client;
9
+ this.client.once('ready', (client) => {
10
+ this.dbl = new DBL(client, options);
11
+ new XernerxLog(this.client).info(`Loaded webhooks!`);
12
+ this.client.util.hasVoted = (userId) => hasVoted(userId, client.user.id, this.dbl?.options.topgg?.token, 'top.gg');
13
+ });
14
+ }
15
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,54 @@
1
+ import { Client, ClientOptions, Collection } from 'discord.js';
2
+ import { XernerxOptions, ModuleOptions, XernerxCommands, XernerxCache } from '../types/interfaces.js';
3
+ import ClientUtil from '../utils/ClientUtil.js';
4
+ import { InhibitorBuilder } from '../main.js';
5
+ export default class XernerxClient extends Client {
6
+ readonly settings: {
7
+ ownerId: (string | string[]) & (string | string[] | undefined);
8
+ local: string;
9
+ global: boolean;
10
+ permissions?:
11
+ | {
12
+ client: string[];
13
+ user: string[];
14
+ dm: boolean;
15
+ }
16
+ | undefined;
17
+ ignore?:
18
+ | {
19
+ owner: boolean;
20
+ users: string[];
21
+ channels: string[];
22
+ guilds: string[];
23
+ }
24
+ | undefined;
25
+ log?:
26
+ | {
27
+ ready: boolean;
28
+ error: boolean;
29
+ info: boolean;
30
+ }
31
+ | undefined;
32
+ cooldown?:
33
+ | {
34
+ command: number;
35
+ cache: number;
36
+ }
37
+ | undefined;
38
+ };
39
+ readonly config: unknown;
40
+ readonly commands: XernerxCommands;
41
+ readonly events: Collection<unknown, unknown>;
42
+ readonly inhibitors: Collection<string, InhibitorBuilder>;
43
+ readonly modules: ModuleOptions;
44
+ readonly util: ClientUtil;
45
+ readonly stats: {
46
+ guildCount: number;
47
+ userCount: number;
48
+ shardId: number;
49
+ shardCount: number;
50
+ };
51
+ readonly cache: XernerxCache;
52
+ constructor(discordOptions: ClientOptions, xernerxOptions: XernerxOptions, config: unknown);
53
+ connect(token: string): void;
54
+ }
@@ -0,0 +1,90 @@
1
+ import { Client, Collection } from 'discord.js';
2
+ import { z } from 'zod';
3
+ import CommandHandler from '../handlers/CommandHandler.js';
4
+ import EventHandler from '../handlers/EventHandler.js';
5
+ import InhibitorHandler from '../handlers/InhibitorHandler.js';
6
+ import WebhookHandler from '../handlers/WebhookHandler.js';
7
+ import XernerxLog from '../tools/XernerxLog.js';
8
+ import ClientUtil from '../utils/ClientUtil.js';
9
+ import ExtensionHandler from '../handlers/ExtensionHandler.js';
10
+ export default class XernerxClient extends Client {
11
+ settings;
12
+ config;
13
+ commands;
14
+ events;
15
+ inhibitors;
16
+ modules;
17
+ util;
18
+ stats;
19
+ cache;
20
+ constructor(discordOptions, xernerxOptions, config) {
21
+ super(discordOptions);
22
+ this.settings = z
23
+ .object({
24
+ local: z.string(),
25
+ global: z.boolean().default(false),
26
+ ownerId: z.string().or(z.array(z.string())).default([]),
27
+ permissions: z
28
+ .object({
29
+ client: z.array(z.string()).default([]),
30
+ user: z.array(z.string()).default([]),
31
+ dm: z.boolean().default(false),
32
+ })
33
+ .optional(),
34
+ ignore: z
35
+ .object({
36
+ owner: z.boolean().default(false),
37
+ users: z.array(z.string()),
38
+ channels: z.array(z.string()),
39
+ guilds: z.array(z.string()),
40
+ })
41
+ .optional(),
42
+ log: z
43
+ .object({
44
+ ready: z.boolean().default(false),
45
+ info: z.boolean().default(false),
46
+ error: z.boolean().default(false),
47
+ })
48
+ .optional(),
49
+ cooldown: z
50
+ .object({
51
+ command: z.number().default(0),
52
+ cache: z.number().default(0),
53
+ })
54
+ .optional(),
55
+ })
56
+ .parse(xernerxOptions);
57
+ this.config = config;
58
+ this.commands = {
59
+ message: new Collection(),
60
+ slash: new Collection(),
61
+ context: new Collection(),
62
+ };
63
+ this.events = new Collection();
64
+ this.inhibitors = new Collection();
65
+ this.modules = {
66
+ options: {},
67
+ commandHandler: new CommandHandler(this),
68
+ eventHandler: new EventHandler(this),
69
+ inhibitorHandler: new InhibitorHandler(this),
70
+ webhookHandler: new WebhookHandler(this),
71
+ extensionHandler: new ExtensionHandler(this),
72
+ };
73
+ this.util = new ClientUtil(this);
74
+ this.stats = {
75
+ guildCount: 0,
76
+ userCount: 0,
77
+ shardId: 0,
78
+ shardCount: 1,
79
+ };
80
+ this.cache = {
81
+ messages: new Collection(),
82
+ cooldowns: new Collection(),
83
+ };
84
+ return this;
85
+ }
86
+ connect(token) {
87
+ this.login(token);
88
+ new XernerxLog(this).ready();
89
+ }
90
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export default function delay(time: number): Promise<unknown>;
@@ -0,0 +1,3 @@
1
+ export default async function delay(time) {
2
+ return await new Promise((resolve) => setTimeout(resolve, time));
3
+ }
@@ -0,0 +1,2 @@
1
+ import XernerxClient from '../client/XernerxClient.js';
2
+ export default function deploy(client: XernerxClient, type: 'slash' | 'context'): void;
@@ -0,0 +1,29 @@
1
+ import { GatewayVersion, REST, Routes } from 'discord.js';
2
+ import XernerxLog from '../tools/XernerxLog.js';
3
+ const commands = { slash: [], context: [], retries: 0 };
4
+ export default function deploy(client, type) {
5
+ client.prependOnceListener('ready', (client) => {
6
+ commands[type] = client.commands[type].map((command) => command.data.toJSON());
7
+ if (commands.retries % 2) {
8
+ try {
9
+ if (client.settings.global) {
10
+ put(client, client.settings.global, [...commands.slash, ...commands.context]);
11
+ put(client, !client.settings.global, []);
12
+ } else {
13
+ put(client, !client.settings.global, [...commands.slash, ...commands.context]);
14
+ put(client, client.settings.global, []);
15
+ }
16
+ } catch (error) {
17
+ new XernerxLog(client).error(`An error occurred while deploying the interaction commands!`, error);
18
+ } finally {
19
+ new XernerxLog(client).info(`Deployed All Commands ${client.settings.global ? 'globally' : 'locally'}.`);
20
+ }
21
+ }
22
+ commands.retries++;
23
+ });
24
+ }
25
+ function put(client, global, body) {
26
+ const rest = new REST({ version: GatewayVersion }).setToken(client.token);
27
+ if (!global) rest.put(Routes.applicationGuildCommands(client.user?.id, client.settings.local), { body });
28
+ else rest.put(Routes.applicationCommands(client.user?.id), { body });
29
+ }
@@ -0,0 +1,2 @@
1
+ import { PermissionNames } from '../types/types.js';
2
+ export default function getPermissionBitField(...permissions: Array<PermissionNames | bigint>): bigint;
@@ -0,0 +1,17 @@
1
+ import { PermissionFlagsBits } from 'discord.js';
2
+ export default function getPermissionBitField(...permissions) {
3
+ const bigIntPerms = [0n];
4
+ permissions.map((permission) => {
5
+ if (typeof permission === 'string') {
6
+ permission =
7
+ PermissionFlagsBits[
8
+ permission
9
+ .split(/ +/)
10
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
11
+ .join('')
12
+ ];
13
+ }
14
+ bigIntPerms.push(permission);
15
+ });
16
+ return bigIntPerms.reduce((a, b) => (a += b));
17
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import XernerxClient from '../client/XernerxClient.js';
2
+ import { XernerxUser } from '../types/extenders.js';
3
+ export default function isOwner(user: Pick<XernerxUser, 'id'>, client: XernerxClient): boolean;
@@ -0,0 +1,3 @@
1
+ export default function isOwner(user, client) {
2
+ return client.settings.ownerId.includes(user.id);
3
+ }