xernerx 3.4.2 → 3.5.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 (71) hide show
  1. package/README.md +10 -10
  2. package/dist/build/ContextCommandBuilder.js +93 -88
  3. package/dist/build/EventBuilder.js +34 -35
  4. package/dist/build/InhibitorBuilder.js +27 -28
  5. package/dist/build/MessageCommandBuilder.js +90 -80
  6. package/dist/build/SlashCommandBuilder.js +125 -118
  7. package/dist/client/XernerxClient.js +101 -81
  8. package/dist/handlers/CommandHandler.js +42 -42
  9. package/dist/handlers/EventHandler.js +16 -16
  10. package/dist/handlers/Handler.js +250 -250
  11. package/dist/handlers/InhibitorHandler.js +21 -21
  12. package/dist/main.cjs +2012 -0
  13. package/dist/main.js +42 -42
  14. package/dist/models/CommandArguments.js +121 -123
  15. package/dist/models/Events.js +294 -304
  16. package/dist/models/Extensions.js +23 -23
  17. package/dist/tools/XernerxError.js +8 -8
  18. package/dist/tools/package.js +37 -41
  19. package/dist/types/enums.js +35 -35
  20. package/dist/types/interfaces.js +1 -1
  21. package/dist/types/options.js +1 -1
  22. package/dist/types/types.js +1 -1
  23. package/dist/utils/ClientUtil.js +222 -218
  24. package/dist/utils/CommandUtil.js +248 -260
  25. package/dist/validators/CommandValidations.js +183 -185
  26. package/dist/validators/InhibitorValidations.js +42 -42
  27. package/dist/validators/Shapes.js +1 -0
  28. package/package.json +54 -39
  29. package/types/build/ContextCommandBuilder.d.ts +68 -0
  30. package/{dist → types}/build/EventBuilder.d.ts +21 -17
  31. package/{dist → types}/build/InhibitorBuilder.d.ts +19 -20
  32. package/types/build/MessageCommandBuilder.d.ts +59 -0
  33. package/types/build/SlashCommandBuilder.d.ts +64 -0
  34. package/{dist → types}/client/XernerxClient.d.ts +28 -28
  35. package/{dist → types}/handlers/CommandHandler.d.ts +27 -26
  36. package/{dist → types}/handlers/EventHandler.d.ts +13 -12
  37. package/{dist → types}/handlers/Handler.d.ts +57 -57
  38. package/{dist → types}/handlers/InhibitorHandler.d.ts +18 -17
  39. package/{dist → types}/main.d.ts +44 -30
  40. package/{dist → types}/models/CommandArguments.d.ts +17 -17
  41. package/{dist → types}/models/Events.d.ts +24 -24
  42. package/{dist → types}/models/Extensions.d.ts +7 -7
  43. package/{dist → types}/tools/XernerxError.d.ts +5 -5
  44. package/{dist → types}/tools/package.d.ts +38 -38
  45. package/types/types/enums.d.ts +44 -0
  46. package/{dist → types}/types/interfaces.d.ts +25 -25
  47. package/{dist → types}/types/options.d.ts +241 -206
  48. package/{dist → types}/types/types.d.ts +61 -32
  49. package/{dist → types}/utils/ClientUtil.d.ts +25 -25
  50. package/{dist → types}/utils/CommandUtil.d.ts +58 -56
  51. package/{dist → types}/validators/CommandValidations.d.ts +12 -7
  52. package/{dist → types}/validators/InhibitorValidations.d.ts +11 -11
  53. package/types/validators/Shapes.d.ts +1 -0
  54. package/dist/build/ContextCommandBuilder.d.ts +0 -42
  55. package/dist/build/MessageCommandBuilder.d.ts +0 -42
  56. package/dist/build/SlashCommandBuilder.d.ts +0 -40
  57. package/dist/build/XContextCommandBuilder.d.ts +0 -40
  58. package/dist/build/XContextCommandBuilder.js +0 -84
  59. package/dist/build/XEventBuilder.d.ts +0 -17
  60. package/dist/build/XEventBuilder.js +0 -35
  61. package/dist/build/XInhibitorBuilder.d.ts +0 -20
  62. package/dist/build/XInhibitorBuilder.js +0 -28
  63. package/dist/build/XMessageCommandBuilder.d.ts +0 -42
  64. package/dist/build/XMessageCommandBuilder.js +0 -80
  65. package/dist/build/XSlashCommandBuilder.d.ts +0 -36
  66. package/dist/build/XSlashCommandBuilder.js +0 -114
  67. package/dist/models/CommandValidations.d.ts +0 -4
  68. package/dist/models/CommandValidations.js +0 -183
  69. package/dist/models/InhibitorValidations.d.ts +0 -12
  70. package/dist/models/InhibitorValidations.js +0 -42
  71. package/dist/types/enums.d.ts +0 -35
package/README.md CHANGED
@@ -4,18 +4,18 @@ Xernerx is a class based discord.js framework. \[BETA\]
4
4
 
5
5
  ## Includes
6
6
 
7
- > - Slash command handler
8
- > - Message command handler
9
- > - Context command handler
10
- > - Event handler (with custom Events)
11
- > - Inhibitor handler
12
- > - Custom utilities
13
- > - Message command handles
14
- > - Extension support
7
+ > - Slash command handler
8
+ > - Message command handler
9
+ > - Context command handler
10
+ > - Event handler (with custom Events)
11
+ > - Inhibitor handler
12
+ > - Custom utilities
13
+ > - Message command handles
14
+ > - Extension support
15
15
 
16
16
  You can checkout the docs [here](https://xernerx.github.io/xernerx/home.html)
17
17
 
18
18
  ## Notes
19
19
 
20
- - Only compatible with ESM
21
- - TypeScript and JavaScript support
20
+ - Only compatible with ESM
21
+ - TypeScript and JavaScript support
@@ -1,88 +1,93 @@
1
- import { ContextMenuCommandBuilder } from 'discord.js';
2
- import { s } from '@sapphire/shapeshift';
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
- owner;
18
- channelType;
19
- cooldown;
20
- ignoreOwner;
21
- channels;
22
- guilds;
23
- userPermissions;
24
- clientPermissions;
25
- defer;
26
- client;
27
- constructor(id, options) {
28
- this.id = id;
29
- this.data = new ContextMenuCommandBuilder();
30
- if (options.name)
31
- this.data.setName(options.name);
32
- if (options.type)
33
- this.data.setType(options.type);
34
- if (options.defaultMemberPermissions)
35
- this.data.setDefaultMemberPermissions(options.defaultMemberPermissions);
36
- if (options.DMPermission)
37
- this.data.setDMPermission(options.DMPermission);
38
- if (options.nameLocalization)
39
- this.data.setNameLocalization(options.nameLocalization.locale, options.nameLocalization.localizedName);
40
- if (options.nameLocalizations)
41
- this.data.setNameLocalizations(options.nameLocalizations);
42
- s.object({
43
- description: s.string.optional,
44
- info: s.string.optional,
45
- category: s.string.optional,
46
- owner: s.boolean.optional,
47
- channelType: s.union(s.number, s.array(s.number)).optional,
48
- cooldown: s.number.optional,
49
- ignoreOwner: s.boolean.optional,
50
- channels: s.array(s.string).optional,
51
- guilds: s.array(s.string).optional,
52
- userPermissions: s.array(s.bigint).optional,
53
- clientPermissions: s.array(s.bigint).optional,
54
- defer: s.object({
55
- reply: s.boolean.optional,
56
- ephemeral: s.boolean.optional,
57
- fetchReply: s.boolean.optional,
58
- }).optional,
59
- }).parse(options);
60
- this.name = options.name;
61
- this.type = options.type;
62
- this.description = options.description;
63
- this.info = options.info;
64
- this.category = options.category;
65
- this.owner = options.owner;
66
- this.channelType = options.channelType;
67
- this.cooldown = options.cooldown;
68
- this.ignoreOwner = options.ignoreOwner;
69
- this.channels = options.channels;
70
- this.guilds = options.guilds;
71
- this.userPermissions = options.userPermissions;
72
- this.clientPermissions = options.clientPermissions;
73
- this.defer = options.defer;
74
- this.client = XernerxClient;
75
- this.conditions = this.conditions;
76
- this.exec = this.exec;
77
- }
78
- /**
79
- * @param {Interaction} interaction - The Discord interaction event data.
80
- * @description make any preconditions here.
81
- */
82
- async conditions(interaction) { }
83
- /**
84
- * @param {Interaction} interaction - The Discord interaction event data.
85
- * @description Make your custom command here.
86
- */
87
- async exec(interaction) { }
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)
28
+ this.data.setName(options.name);
29
+ if (options.type)
30
+ this.data.setType(options.type);
31
+ if (options.permissions?.users)
32
+ this.data.setDefaultMemberPermissions(options.permissions?.users);
33
+ if (options.permissions?.dm === false)
34
+ this.data.setDMPermission(options.permissions?.dm);
35
+ if (options.nameLocalizations)
36
+ this.data.setNameLocalizations(options.nameLocalizations);
37
+ z.object({
38
+ description: z.string(),
39
+ info: z.string(),
40
+ category: z.string(),
41
+ channelType: z.array(z.number()).or(z.number()),
42
+ cooldown: z.number(),
43
+ ignore: z.object({
44
+ owner: z.boolean(),
45
+ users: z.array(z.string()),
46
+ channels: z.array(z.string()),
47
+ guilds: z.array(z.string()),
48
+ }),
49
+ strict: z.object({
50
+ owner: z.boolean(),
51
+ users: z.array(z.string()),
52
+ channels: z.array(z.string()),
53
+ guilds: z.array(z.string()),
54
+ }),
55
+ permissions: z.object({
56
+ client: z.array(z.string()),
57
+ users: z.array(z.string()),
58
+ dm: z.boolean(),
59
+ }),
60
+ defer: z.object({
61
+ reply: z.boolean(),
62
+ ephemeral: z.boolean(),
63
+ fetch: z.boolean(),
64
+ }),
65
+ })
66
+ .deepPartial()
67
+ .parse(options);
68
+ this.name = options.name;
69
+ this.type = options.type;
70
+ this.description = options.description;
71
+ this.info = options.info;
72
+ this.category = options.category;
73
+ this.channelType = options.channelType;
74
+ this.cooldown = options.cooldown;
75
+ this.ignore = options.ignore;
76
+ this.strict = options.strict;
77
+ this.permissions = options.permissions;
78
+ this.defer = options.defer;
79
+ this.client = XernerxClient;
80
+ }
81
+ /**
82
+ * @param {Interaction} interaction - The Discord interaction event data.
83
+ * @description make any preconditions here.
84
+ * TODO - update description
85
+ */
86
+ async conditions(interaction, args) { }
87
+ /**
88
+ * @param {Interaction} interaction - The Discord interaction event data.
89
+ * @description Make your custom command here.
90
+ * TODO - update description
91
+ */
92
+ async exec(interaction, args) { }
93
+ }
@@ -1,35 +1,34 @@
1
- import { s } from '@sapphire/shapeshift';
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
- s.object({
18
- name: s.string,
19
- emitter: s.string.optional,
20
- type: s.string.optional,
21
- once: s.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
- this.run = this.run;
29
- }
30
- async run() {
31
- /**
32
- * @description run your custom event here.
33
- */
34
- }
35
- }
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
+ }
@@ -1,28 +1,27 @@
1
- import { s } from '@sapphire/shapeshift';
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
- s.object({
16
- name: s.string,
17
- type: s.string,
18
- }).parse(options);
19
- this.name = options.name;
20
- this.type = options.type;
21
- this.client = XernerxClient;
22
- this.check = this.check;
23
- }
24
- /**
25
- *
26
- */
27
- async check(interaction, args) { }
28
- }
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
+ }
@@ -1,80 +1,90 @@
1
- import { s } from '@sapphire/shapeshift';
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
- description;
13
- info;
14
- category;
15
- prefix;
16
- regex;
17
- owner;
18
- channelType;
19
- separator;
20
- cooldown;
21
- ignoreOwner;
22
- channels;
23
- guilds;
24
- userPermissions;
25
- clientPermissions;
26
- args;
27
- client;
28
- constructor(id, options) {
29
- this.id = id;
30
- s.object({
31
- name: s.string,
32
- aliases: s.union(s.array(s.string).unique, s.string).optional,
33
- description: s.string.optional,
34
- info: s.string.optional,
35
- category: s.string.optional,
36
- prefix: s.union(s.array(s.string).unique, s.string).optional,
37
- owner: s.boolean.optional,
38
- channelType: s.union(s.number, s.array(s.number)).optional,
39
- separator: s.string.optional,
40
- cooldown: s.number.optional,
41
- ignoreOwner: s.boolean.optional,
42
- channels: s.array(s.string).unique.optional,
43
- guilds: s.array(s.string).unique.optional,
44
- userPermissions: s.array(s.bigint).unique.optional,
45
- clientPermissions: s.array(s.bigint).unique.optional,
46
- }).parse(options);
47
- this.name = options.name;
48
- this.aliases = options.aliases;
49
- this.description = options.description;
50
- this.info = options.info;
51
- this.category = options.category;
52
- this.prefix = options.prefix ? (Array.isArray(options.prefix) ? options.prefix : [options.prefix]) : [];
53
- this.regex = options.regex;
54
- this.owner = options.owner || false;
55
- this.channelType = options.channelType;
56
- this.separator = options.separator || ' ';
57
- this.cooldown = options.cooldown || 0;
58
- this.ignoreOwner = options.ignoreOwner || false;
59
- this.channels = options.channels || [];
60
- this.guilds = options.guilds || [];
61
- this.userPermissions = options.userPermissions || [];
62
- this.clientPermissions = options.clientPermissions || [];
63
- this.args = options.args || [];
64
- this.client = XernerxClient;
65
- this.conditions = this.conditions;
66
- this.exec = this.exec;
67
- }
68
- /**
69
- * @param {Message} message - The Discord message event data.
70
- * @param {object} args - The arguments you created.
71
- * @description make any preconditions here.
72
- */
73
- async conditions(message, args) { }
74
- /**
75
- * @param {Message} message - The Discord message event data.
76
- * @param {object} args - The arguments you created.
77
- * @description Make your custom command here.
78
- */
79
- async exec(message, args) { }
80
- }
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
+ }