xernerx 3.5.0 → 3.5.2

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 (114) hide show
  1. package/dist/cjs/build/ContextCommandBuilder.js +97 -0
  2. package/dist/cjs/build/EventBuilder.js +44 -0
  3. package/dist/cjs/build/InhibitorBuilder.js +37 -0
  4. package/dist/cjs/build/MessageCommandBuilder.js +100 -0
  5. package/{types → dist/cjs}/build/SlashCommandBuilder.d.ts +2 -1
  6. package/dist/cjs/build/SlashCommandBuilder.js +169 -0
  7. package/dist/cjs/client/XernerxClient.js +116 -0
  8. package/dist/{handlers → cjs/handlers}/CommandHandler.js +11 -8
  9. package/dist/{handlers → cjs/handlers}/EventHandler.js +6 -3
  10. package/dist/cjs/handlers/Handler.js +308 -0
  11. package/dist/{handlers → cjs/handlers}/InhibitorHandler.js +6 -3
  12. package/dist/cjs/main.js +112 -0
  13. package/dist/{models → cjs/models}/CommandArguments.js +37 -52
  14. package/dist/cjs/models/Events.js +307 -0
  15. package/dist/cjs/models/Extensions.js +26 -0
  16. package/dist/{tools → cjs/tools}/XernerxError.js +4 -1
  17. package/{types → dist/cjs}/tools/package.d.ts +11 -0
  18. package/dist/cjs/tools/package.js +50 -0
  19. package/dist/cjs/types/enums.js +38 -0
  20. package/dist/cjs/types/interfaces.js +2 -0
  21. package/dist/cjs/types/options.js +2 -0
  22. package/dist/cjs/types/types.js +2 -0
  23. package/dist/{utils → cjs/utils}/ClientUtil.js +73 -84
  24. package/dist/{utils → cjs/utils}/CommandUtil.js +102 -103
  25. package/dist/{validators → cjs/validators}/CommandValidations.js +36 -50
  26. package/dist/{validators → cjs/validators}/InhibitorValidations.js +12 -14
  27. package/dist/mjs/build/ContextCommandBuilder.d.ts +68 -0
  28. package/dist/mjs/build/ContextCommandBuilder.js +97 -0
  29. package/dist/mjs/build/EventBuilder.d.ts +21 -0
  30. package/dist/mjs/build/EventBuilder.js +44 -0
  31. package/dist/mjs/build/InhibitorBuilder.d.ts +19 -0
  32. package/dist/mjs/build/InhibitorBuilder.js +37 -0
  33. package/dist/mjs/build/MessageCommandBuilder.d.ts +59 -0
  34. package/dist/mjs/build/MessageCommandBuilder.js +100 -0
  35. package/dist/mjs/build/SlashCommandBuilder.d.ts +65 -0
  36. package/dist/mjs/build/SlashCommandBuilder.js +169 -0
  37. package/dist/mjs/client/XernerxClient.d.ts +28 -0
  38. package/dist/mjs/client/XernerxClient.js +116 -0
  39. package/dist/mjs/handlers/CommandHandler.d.ts +27 -0
  40. package/dist/mjs/handlers/CommandHandler.js +45 -0
  41. package/dist/mjs/handlers/EventHandler.d.ts +13 -0
  42. package/dist/mjs/handlers/EventHandler.js +19 -0
  43. package/dist/mjs/handlers/Handler.d.ts +57 -0
  44. package/dist/mjs/handlers/Handler.js +308 -0
  45. package/dist/mjs/handlers/InhibitorHandler.d.ts +18 -0
  46. package/dist/mjs/handlers/InhibitorHandler.js +24 -0
  47. package/dist/{main.js → mjs/main.d.ts} +20 -18
  48. package/dist/mjs/main.js +112 -0
  49. package/dist/mjs/models/CommandArguments.d.ts +17 -0
  50. package/dist/mjs/models/CommandArguments.js +106 -0
  51. package/dist/mjs/models/Events.d.ts +24 -0
  52. package/dist/mjs/models/Events.js +307 -0
  53. package/dist/mjs/models/Extensions.d.ts +7 -0
  54. package/dist/mjs/models/Extensions.js +26 -0
  55. package/dist/mjs/tools/XernerxError.d.ts +5 -0
  56. package/dist/mjs/tools/XernerxError.js +11 -0
  57. package/dist/mjs/tools/package.d.ts +49 -0
  58. package/dist/mjs/tools/package.js +50 -0
  59. package/dist/mjs/types/enums.d.ts +44 -0
  60. package/dist/mjs/types/enums.js +38 -0
  61. package/dist/mjs/types/interfaces.d.ts +25 -0
  62. package/dist/mjs/types/interfaces.js +2 -0
  63. package/dist/mjs/types/options.d.ts +241 -0
  64. package/dist/mjs/types/options.js +2 -0
  65. package/dist/mjs/types/types.d.ts +61 -0
  66. package/dist/mjs/types/types.js +2 -0
  67. package/dist/mjs/utils/ClientUtil.d.ts +25 -0
  68. package/dist/mjs/utils/ClientUtil.js +211 -0
  69. package/dist/mjs/utils/CommandUtil.d.ts +58 -0
  70. package/dist/mjs/utils/CommandUtil.js +247 -0
  71. package/dist/mjs/validators/CommandValidations.d.ts +12 -0
  72. package/dist/mjs/validators/CommandValidations.js +169 -0
  73. package/dist/mjs/validators/InhibitorValidations.d.ts +11 -0
  74. package/dist/mjs/validators/InhibitorValidations.js +40 -0
  75. package/package.json +11 -16
  76. package/dist/build/ContextCommandBuilder.js +0 -93
  77. package/dist/build/EventBuilder.js +0 -34
  78. package/dist/build/InhibitorBuilder.js +0 -27
  79. package/dist/build/MessageCommandBuilder.js +0 -90
  80. package/dist/build/SlashCommandBuilder.js +0 -125
  81. package/dist/client/XernerxClient.js +0 -101
  82. package/dist/handlers/Handler.js +0 -250
  83. package/dist/main.cjs +0 -2012
  84. package/dist/models/Events.js +0 -294
  85. package/dist/models/Extensions.js +0 -23
  86. package/dist/tools/package.js +0 -37
  87. package/dist/types/enums.js +0 -35
  88. package/dist/types/interfaces.js +0 -1
  89. package/dist/types/options.js +0 -1
  90. package/dist/types/types.js +0 -1
  91. package/dist/validators/Shapes.js +0 -1
  92. package/types/validators/Shapes.d.ts +0 -1
  93. /package/{types → dist/cjs}/build/ContextCommandBuilder.d.ts +0 -0
  94. /package/{types → dist/cjs}/build/EventBuilder.d.ts +0 -0
  95. /package/{types → dist/cjs}/build/InhibitorBuilder.d.ts +0 -0
  96. /package/{types → dist/cjs}/build/MessageCommandBuilder.d.ts +0 -0
  97. /package/{types → dist/cjs}/client/XernerxClient.d.ts +0 -0
  98. /package/{types → dist/cjs}/handlers/CommandHandler.d.ts +0 -0
  99. /package/{types → dist/cjs}/handlers/EventHandler.d.ts +0 -0
  100. /package/{types → dist/cjs}/handlers/Handler.d.ts +0 -0
  101. /package/{types → dist/cjs}/handlers/InhibitorHandler.d.ts +0 -0
  102. /package/{types → dist/cjs}/main.d.ts +0 -0
  103. /package/{types → dist/cjs}/models/CommandArguments.d.ts +0 -0
  104. /package/{types → dist/cjs}/models/Events.d.ts +0 -0
  105. /package/{types → dist/cjs}/models/Extensions.d.ts +0 -0
  106. /package/{types → dist/cjs}/tools/XernerxError.d.ts +0 -0
  107. /package/{types → dist/cjs}/types/enums.d.ts +0 -0
  108. /package/{types → dist/cjs}/types/interfaces.d.ts +0 -0
  109. /package/{types → dist/cjs}/types/options.d.ts +0 -0
  110. /package/{types → dist/cjs}/types/types.d.ts +0 -0
  111. /package/{types → dist/cjs}/utils/ClientUtil.d.ts +0 -0
  112. /package/{types → dist/cjs}/utils/CommandUtil.d.ts +0 -0
  113. /package/{types → dist/cjs}/validators/CommandValidations.d.ts +0 -0
  114. /package/{types → dist/cjs}/validators/InhibitorValidations.d.ts +0 -0
@@ -0,0 +1,97 @@
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;
@@ -0,0 +1,44 @@
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 zod_1 = require('zod');
9
+ const XernerxClient_js_1 = __importDefault(require('../client/XernerxClient.js'));
10
+ /**
11
+ * @description - The event builder for events.
12
+ * @param {String} id - The unique ID of the event.
13
+ * @param {EventOptions} options - The event options.
14
+ */
15
+ class EventBuilder {
16
+ id;
17
+ name;
18
+ emitter;
19
+ type;
20
+ once;
21
+ client;
22
+ constructor(id, options) {
23
+ this.id = id;
24
+ zod_1.z
25
+ .object({
26
+ name: zod_1.z.string(),
27
+ emitter: zod_1.z.string().optional(),
28
+ type: zod_1.z.string().optional(),
29
+ once: zod_1.z.boolean().optional(),
30
+ })
31
+ .parse(options);
32
+ this.name = options.name;
33
+ this.emitter = options.emitter || 'client';
34
+ this.type = options.type || 'discord';
35
+ this.once = options.once || false;
36
+ this.client = XernerxClient_js_1.default;
37
+ }
38
+ /**
39
+ * @description run your custom event here.
40
+ * TODO - update description
41
+ */
42
+ async run() {}
43
+ }
44
+ exports.default = EventBuilder;
@@ -0,0 +1,37 @@
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 zod_1 = require('zod');
9
+ const XernerxClient_js_1 = __importDefault(require('../client/XernerxClient.js'));
10
+ /**
11
+ * @description - The inhibitor builder for inhibitors.
12
+ * @param {String} id - The unique ID of the inhibitor.
13
+ * @param {InhibitorOptions} options - The inhibitor options.
14
+ */
15
+ class InhibitorBuilder {
16
+ id;
17
+ name;
18
+ type;
19
+ client;
20
+ constructor(id, options) {
21
+ this.id = id;
22
+ zod_1.z
23
+ .object({
24
+ name: zod_1.z.string(),
25
+ type: zod_1.z.string(),
26
+ })
27
+ .parse(options);
28
+ this.name = options.name;
29
+ this.type = options.type;
30
+ this.client = XernerxClient_js_1.default;
31
+ }
32
+ /**
33
+ * TODO - update description
34
+ */
35
+ async check(interaction, args) {}
36
+ }
37
+ exports.default = InhibitorBuilder;
@@ -0,0 +1,100 @@
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 zod_1 = require('zod');
9
+ const XernerxClient_js_1 = __importDefault(require('../client/XernerxClient.js'));
10
+ /**
11
+ * @description - The command builder for message commands.
12
+ * @param {String} id - The unique ID of the command.
13
+ * @param {MessageCommandOptions} options - The command options.
14
+ */
15
+ class MessageCommandBuilder {
16
+ id;
17
+ name;
18
+ aliases;
19
+ separator;
20
+ description;
21
+ info;
22
+ category;
23
+ prefix;
24
+ regex;
25
+ channelType;
26
+ ignore;
27
+ strict;
28
+ permissions;
29
+ cooldown;
30
+ args;
31
+ client;
32
+ constructor(id, options) {
33
+ this.id = id;
34
+ zod_1.z
35
+ .object({
36
+ name: zod_1.z.string(),
37
+ aliases: zod_1.z.array(zod_1.z.string()).optional(),
38
+ separator: zod_1.z.string().min(1).max(1).optional(),
39
+ description: zod_1.z.string().optional(),
40
+ info: zod_1.z.string().optional(),
41
+ category: zod_1.z.string().optional(),
42
+ prefix: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
43
+ regex: zod_1.z.unknown(),
44
+ channelType: zod_1.z.array(zod_1.z.number()).or(zod_1.z.number()).optional(),
45
+ cooldown: zod_1.z.number().optional(),
46
+ ignore: zod_1.z
47
+ .object({
48
+ owners: zod_1.z.boolean().optional(),
49
+ users: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
50
+ channels: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
51
+ guilds: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
52
+ })
53
+ .optional(),
54
+ strict: zod_1.z
55
+ .object({
56
+ owners: zod_1.z.boolean().optional(),
57
+ users: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
58
+ channels: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
59
+ guilds: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
60
+ })
61
+ .optional(),
62
+ permissions: zod_1.z
63
+ .object({
64
+ client: zod_1.z.array(zod_1.z.string()).optional(),
65
+ users: zod_1.z.array(zod_1.z.string()).optional(),
66
+ dm: zod_1.z.boolean().optional(),
67
+ })
68
+ .optional(),
69
+ })
70
+ .parse(options);
71
+ this.name = options.name;
72
+ this.aliases = options.aliases;
73
+ this.separator = options.separator || ' ';
74
+ this.description = options.description;
75
+ this.info = options.info;
76
+ this.category = options.category;
77
+ this.prefix = options.prefix ? (Array.isArray(options.prefix) ? options.prefix : [options.prefix]) : [];
78
+ this.regex = options.regex;
79
+ this.channelType = options.channelType;
80
+ this.ignore = options.ignore;
81
+ this.strict = options.strict;
82
+ this.permissions = options.permissions;
83
+ this.cooldown = options.cooldown || 0;
84
+ this.args = options.args || [];
85
+ this.client = XernerxClient_js_1.default;
86
+ }
87
+ /**
88
+ * @param {Message} message - The Discord message event data.
89
+ * @param {object} args - The arguments you created.
90
+ * @description make any preconditions here.
91
+ */
92
+ async conditions(message, args) {}
93
+ /**
94
+ * @param {Message} message - The Discord message event data.
95
+ * @param {object} args - The arguments you created.
96
+ * @description Make your custom command here.
97
+ */
98
+ async exec(message, args) {}
99
+ }
100
+ exports.default = MessageCommandBuilder;
@@ -1,4 +1,5 @@
1
- import Discord, { Interaction } from 'discord.js';
1
+ import * as Discord from 'discord.js';
2
+ import { Interaction } from 'discord.js';
2
3
  import { SlashCommandOptions } from '../types/options.js';
3
4
  import XernerxClient from '../client/XernerxClient.js';
4
5
  /**
@@ -0,0 +1,169 @@
1
+ 'use strict';
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = {
10
+ enumerable: true,
11
+ get: function () {
12
+ return m[k];
13
+ },
14
+ };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }
18
+ : function (o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ });
22
+ var __setModuleDefault =
23
+ (this && this.__setModuleDefault) ||
24
+ (Object.create
25
+ ? function (o, v) {
26
+ Object.defineProperty(o, 'default', { enumerable: true, value: v });
27
+ }
28
+ : function (o, v) {
29
+ o['default'] = v;
30
+ });
31
+ var __importStar =
32
+ (this && this.__importStar) ||
33
+ function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ var __importDefault =
41
+ (this && this.__importDefault) ||
42
+ function (mod) {
43
+ return mod && mod.__esModule ? mod : { default: mod };
44
+ };
45
+ Object.defineProperty(exports, '__esModule', { value: true });
46
+ const Discord = __importStar(require('discord.js'));
47
+ const discord_js_1 = require('discord.js');
48
+ const zod_1 = require('zod');
49
+ const XernerxError_js_1 = __importDefault(require('../tools/XernerxError.js'));
50
+ const XernerxClient_js_1 = __importDefault(require('../client/XernerxClient.js'));
51
+ /**
52
+ * @description - The command builder for slash commands.
53
+ * @param {String} id - The unique ID of the command.
54
+ * @param {SlashCommandOptions} options - The command options.
55
+ */
56
+ class SlashCommandBuilder {
57
+ id;
58
+ data;
59
+ name;
60
+ description;
61
+ info;
62
+ category;
63
+ channelType;
64
+ cooldown;
65
+ ignore;
66
+ strict;
67
+ permissions;
68
+ args;
69
+ subcommands;
70
+ groups;
71
+ defer;
72
+ client;
73
+ constructor(id, options) {
74
+ this.id = id;
75
+ this.data = new Discord.SlashCommandBuilder().setName(options.name).setDescription(options.description);
76
+ if (options.args && options?.args?.length > 0) {
77
+ this.addArgs(this.data, options.args);
78
+ }
79
+ if (options.subcommands && options?.subcommands?.length > 0) {
80
+ this.addSubcommands(this.data, options.subcommands);
81
+ }
82
+ if (options.groups && options?.groups?.length > 0) {
83
+ this.addSubcommandGroups(options.groups);
84
+ }
85
+ zod_1.z
86
+ .object({
87
+ description: zod_1.z.string(),
88
+ info: zod_1.z.string(),
89
+ category: zod_1.z.string(),
90
+ channelType: zod_1.z.array(zod_1.z.number()).or(zod_1.z.number()),
91
+ cooldown: zod_1.z.number(),
92
+ ignore: zod_1.z.object({
93
+ owner: zod_1.z.boolean(),
94
+ users: zod_1.z.array(zod_1.z.string()),
95
+ channels: zod_1.z.array(zod_1.z.string()),
96
+ guilds: zod_1.z.array(zod_1.z.string()),
97
+ }),
98
+ strict: zod_1.z.object({
99
+ owner: zod_1.z.boolean(),
100
+ users: zod_1.z.array(zod_1.z.string()),
101
+ channels: zod_1.z.array(zod_1.z.string()),
102
+ guilds: zod_1.z.array(zod_1.z.string()),
103
+ }),
104
+ permissions: zod_1.z.object({
105
+ client: zod_1.z.array(zod_1.z.string()),
106
+ users: zod_1.z.array(zod_1.z.string()),
107
+ dm: zod_1.z.boolean(),
108
+ }),
109
+ defer: zod_1.z.object({
110
+ reply: zod_1.z.boolean(),
111
+ ephemeral: zod_1.z.boolean(),
112
+ fetch: zod_1.z.boolean(),
113
+ }),
114
+ })
115
+ .deepPartial()
116
+ .parse(options);
117
+ this.name = options.name;
118
+ this.description = options.description;
119
+ this.info = options.info;
120
+ this.category = options.category;
121
+ this.channelType = options.channelType;
122
+ this.cooldown = options.cooldown;
123
+ this.ignore = options.ignore;
124
+ this.strict = options.strict;
125
+ this.permissions = options.permissions;
126
+ this.defer = options.defer;
127
+ this.client = XernerxClient_js_1.default;
128
+ }
129
+ /**
130
+ * TODO - update description
131
+ * @param interaction
132
+ */
133
+ async conditions(interaction) {}
134
+ /**
135
+ * TODO - update description
136
+ * @param interaction
137
+ */
138
+ async exec(interaction) {}
139
+ addArgs(command, args) {
140
+ const types = ['boolean', 'integer', 'number', 'string', 'user', 'role', 'channel', 'mentionable'];
141
+ for (const argument of args) {
142
+ if (!types.includes(argument.type.toLowerCase())) throw new XernerxError_js_1.default(`Expected one of ${types.join(', ')}, received ${argument.type} instead.`);
143
+ let slashArgumentType = `${argument.type.slice(0, 1).toUpperCase()}${argument.type.slice(1).toLowerCase()}`;
144
+ command[`add${slashArgumentType}Option`]((option) => {
145
+ option
146
+ .setName(argument.name)
147
+ .setDescription(argument.description)
148
+ .setRequired(argument.required || false);
149
+ if (argument.choices) option.setChoices(...argument?.choices);
150
+ return option;
151
+ });
152
+ }
153
+ }
154
+ addSubcommands(method, subcommands) {
155
+ for (const subcommand of subcommands) {
156
+ let sub = new discord_js_1.SlashCommandSubcommandBuilder().setName(subcommand.name).setDescription(subcommand.description);
157
+ if (subcommand.args?.length > 0) this.addArgs(sub, subcommand.args);
158
+ method.addSubcommand(sub);
159
+ }
160
+ }
161
+ addSubcommandGroups(groups) {
162
+ for (const group of groups) {
163
+ let subcommandGroup = new discord_js_1.SlashCommandSubcommandGroupBuilder().setName(group.name).setDescription(group.description);
164
+ if (group.subcommands?.length > 0) this.addSubcommands(subcommandGroup, group.subcommands);
165
+ this.data.addSubcommandGroup(subcommandGroup);
166
+ }
167
+ }
168
+ }
169
+ exports.default = SlashCommandBuilder;
@@ -0,0 +1,116 @@
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 dumfunctions_1 = require('dumfunctions');
11
+ const ClientUtil_js_1 = require('../utils/ClientUtil.js');
12
+ const CommandHandler_js_1 = __importDefault(require('../handlers/CommandHandler.js'));
13
+ const EventHandler_js_1 = __importDefault(require('../handlers/EventHandler.js'));
14
+ const InhibitorHandler_js_1 = __importDefault(require('../handlers/InhibitorHandler.js'));
15
+ const Extensions_js_1 = __importDefault(require('../models/Extensions.js'));
16
+ // TODO - Add commandNotFound as an event to the client.
17
+ /**
18
+ * @description - The Client.
19
+ * @param {DiscordOptions} discordOptions - The options for discord.js.
20
+ * @param {ClientOptions} clientOptions - The options for the Xernerx Client.
21
+ * @extends {Client}
22
+ */
23
+ class XernerxClient extends discord_js_1.Client {
24
+ settings;
25
+ commands;
26
+ cache;
27
+ modules;
28
+ util;
29
+ handlerOptions;
30
+ events;
31
+ extensions;
32
+ inhibitors;
33
+ config;
34
+ constructor(discordOptions, clientOptions, config) {
35
+ super(discordOptions);
36
+ this.settings = zod_1.z
37
+ .object({
38
+ ownerId: zod_1.z.string().or(zod_1.z.array(zod_1.z.string())).default([]),
39
+ permissions: zod_1.z
40
+ .object({
41
+ client: zod_1.z.array(zod_1.z.string()).default([]),
42
+ user: zod_1.z.array(zod_1.z.string()).default([]),
43
+ dm: zod_1.z.boolean().default(false),
44
+ })
45
+ .optional(),
46
+ ignore: zod_1.z
47
+ .object({
48
+ owner: zod_1.z.boolean().default(false),
49
+ users: zod_1.z.array(zod_1.z.string()),
50
+ channels: zod_1.z.array(zod_1.z.string()),
51
+ guilds: zod_1.z.array(zod_1.z.string()),
52
+ })
53
+ .optional(),
54
+ log: zod_1.z
55
+ .object({
56
+ ready: zod_1.z.boolean().default(false),
57
+ error: zod_1.z.boolean().default(false),
58
+ })
59
+ .optional(),
60
+ cooldown: zod_1.z
61
+ .object({
62
+ command: zod_1.z.number().default(0),
63
+ cache: zod_1.z.number().default(0),
64
+ })
65
+ .optional(),
66
+ })
67
+ .parse(clientOptions);
68
+ this.config = config || {};
69
+ this.commands = {
70
+ message: new discord_js_1.Collection(),
71
+ slash: new discord_js_1.Collection(),
72
+ context: new discord_js_1.Collection(),
73
+ };
74
+ this.events = new discord_js_1.Collection();
75
+ this.inhibitors = new discord_js_1.Collection();
76
+ this.cache = {
77
+ messages: new discord_js_1.Collection(),
78
+ cooldowns: new discord_js_1.Collection(),
79
+ messageCommands: new discord_js_1.Collection(),
80
+ slashCommands: new discord_js_1.Collection(),
81
+ contextCommands: new discord_js_1.Collection(),
82
+ commands: new discord_js_1.Collection(),
83
+ };
84
+ this.modules = {
85
+ commandHandler: new CommandHandler_js_1.default(this),
86
+ eventHandler: new EventHandler_js_1.default(this),
87
+ inhibitorHandler: new InhibitorHandler_js_1.default(this),
88
+ };
89
+ this.extensions = {};
90
+ this.util = new ClientUtil_js_1.ClientUtil(this);
91
+ this.handlerOptions = {};
92
+ if (this.settings?.log?.ready) {
93
+ this.once('ready', async (client) => {
94
+ const size = (await client.guilds.fetch()).size;
95
+ console.info(
96
+ dumfunctions_1.Style.log(
97
+ `Xernerx | ${client.user.tag} signed in watching ${size} server${size > 1 ? 's' : ''}. ${
98
+ (this.handlerOptions.slash || this.handlerOptions.context)?.guildId
99
+ ? `Using ${(await this.guilds.fetch((this.handlerOptions.slash || this.handlerOptions.context)?.guildId || '0')).name} as local guild.`
100
+ : ''
101
+ }`,
102
+ { color: dumfunctions_1.Style.TextColor.Purple }
103
+ )
104
+ );
105
+ });
106
+ }
107
+ }
108
+ register(token) {
109
+ this.login(token);
110
+ }
111
+ loadAllExtensions(options) {
112
+ const extensions = new Extensions_js_1.default(this);
113
+ return extensions.load(options.extensions, options.logging || false);
114
+ }
115
+ }
116
+ exports.default = XernerxClient;
@@ -1,16 +1,18 @@
1
- import { Handler } from './Handler.js';
2
- import { CommandsDeploy, ContextCommandEvents, MessageCommandEvents, SlashCommandEvents } from '../models/Events.js';
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ const Handler_js_1 = require('./Handler.js');
4
+ const Events_js_1 = require('../models/Events.js');
3
5
  /**
4
6
  * @description - The command handler.
5
7
  * @param {XernerxClient} client - The XernerxClient.
6
8
  */
7
- export default class CommandHandler {
9
+ class CommandHandler {
8
10
  client;
9
11
  handler;
10
12
  constructor(client) {
11
13
  this.client = client;
12
- this.handler = new Handler(client);
13
- new CommandsDeploy(this.client).deploy();
14
+ this.handler = new Handler_js_1.Handler(client);
15
+ new Events_js_1.CommandsDeploy(this.client).deploy();
14
16
  }
15
17
  /**
16
18
  * @description - The message command loader.
@@ -18,7 +20,7 @@ export default class CommandHandler {
18
20
  */
19
21
  loadAllMessageCommands(options) {
20
22
  this.handler.loadAllMessageCommands(options);
21
- const events = new MessageCommandEvents(this.client);
23
+ const events = new Events_js_1.MessageCommandEvents(this.client);
22
24
  events.messageCreate();
23
25
  events.messageUpdate();
24
26
  events.messageDelete();
@@ -29,7 +31,7 @@ export default class CommandHandler {
29
31
  */
30
32
  loadAllSlashCommands(options) {
31
33
  this.handler.loadAllSlashCommands(options);
32
- new SlashCommandEvents(this.client).slashCreate();
34
+ new Events_js_1.SlashCommandEvents(this.client).slashCreate();
33
35
  }
34
36
  /**
35
37
  * @description - The context command loader.
@@ -37,6 +39,7 @@ export default class CommandHandler {
37
39
  */
38
40
  loadAllContextCommands(options) {
39
41
  this.handler.loadAllContextCommands(options);
40
- new ContextCommandEvents(this.client).contextCreate();
42
+ new Events_js_1.ContextCommandEvents(this.client).contextCreate();
41
43
  }
42
44
  }
45
+ exports.default = CommandHandler;
@@ -1,10 +1,12 @@
1
- import { Handler } from './Handler.js';
2
- export default class EventHandler {
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ const Handler_js_1 = require('./Handler.js');
4
+ class EventHandler {
3
5
  client;
4
6
  handler;
5
7
  constructor(client) {
6
8
  this.client = client;
7
- this.handler = new Handler(client);
9
+ this.handler = new Handler_js_1.Handler(client);
8
10
  }
9
11
  /**
10
12
  * @description - The event loader
@@ -14,3 +16,4 @@ export default class EventHandler {
14
16
  return this.handler.loadAllEvents(options);
15
17
  }
16
18
  }
19
+ exports.default = EventHandler;