xernerx 4.2.1 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/LICENSE +21 -21
  2. package/dist/build/ContextCommandBuilder.d.ts +14 -13
  3. package/dist/build/ContextCommandBuilder.js +2 -13
  4. package/dist/build/EventBuilder.d.ts +7 -7
  5. package/dist/build/EventBuilder.js +0 -6
  6. package/dist/build/InhibitorBuilder.d.ts +5 -5
  7. package/dist/build/InhibitorBuilder.js +0 -4
  8. package/dist/build/MessageCommandBuilder.d.ts +1 -0
  9. package/dist/build/MessageCommandBuilder.js +2 -16
  10. package/dist/build/SlashCommandBuilder.d.ts +13 -12
  11. package/dist/build/SlashCommandBuilder.js +2 -12
  12. package/dist/client/XernerxClient.d.ts +2 -2
  13. package/dist/client/XernerxClient.js +2 -2
  14. package/dist/handlers/ExtensionHandler.js +3 -1
  15. package/dist/handlers/WebhookHandler.js +1 -1
  16. package/dist/main.d.ts +2 -2
  17. package/dist/main.js +3 -2
  18. package/dist/types/interfaces.d.ts +3 -2
  19. package/dist/utils/ClientUtil.d.ts +1 -0
  20. package/dist/utils/ClientUtil.js +10 -0
  21. package/package.json +2 -2
  22. package/dist/cjs/build/ContextCommandBuilder.d.ts +0 -68
  23. package/dist/cjs/build/ContextCommandBuilder.js +0 -97
  24. package/dist/cjs/build/EventBuilder.d.ts +0 -21
  25. package/dist/cjs/build/EventBuilder.js +0 -44
  26. package/dist/cjs/build/InhibitorBuilder.d.ts +0 -19
  27. package/dist/cjs/build/InhibitorBuilder.js +0 -37
  28. package/dist/cjs/build/MessageCommandBuilder.d.ts +0 -59
  29. package/dist/cjs/build/MessageCommandBuilder.js +0 -100
  30. package/dist/cjs/build/SlashCommandBuilder.d.ts +0 -64
  31. package/dist/cjs/build/SlashCommandBuilder.js +0 -168
  32. package/dist/cjs/client/XernerxClient.d.ts +0 -28
  33. package/dist/cjs/client/XernerxClient.js +0 -116
  34. package/dist/cjs/handlers/CommandHandler.d.ts +0 -27
  35. package/dist/cjs/handlers/CommandHandler.js +0 -45
  36. package/dist/cjs/handlers/EventHandler.d.ts +0 -13
  37. package/dist/cjs/handlers/EventHandler.js +0 -19
  38. package/dist/cjs/handlers/Handler.d.ts +0 -57
  39. package/dist/cjs/handlers/Handler.js +0 -308
  40. package/dist/cjs/handlers/InhibitorHandler.d.ts +0 -18
  41. package/dist/cjs/handlers/InhibitorHandler.js +0 -24
  42. package/dist/cjs/main.d.ts +0 -44
  43. package/dist/cjs/main.js +0 -112
  44. package/dist/cjs/models/CommandArguments.d.ts +0 -17
  45. package/dist/cjs/models/CommandArguments.js +0 -106
  46. package/dist/cjs/models/Events.d.ts +0 -24
  47. package/dist/cjs/models/Events.js +0 -307
  48. package/dist/cjs/models/Extensions.d.ts +0 -7
  49. package/dist/cjs/models/Extensions.js +0 -26
  50. package/dist/cjs/tools/XernerxError.d.ts +0 -5
  51. package/dist/cjs/tools/XernerxError.js +0 -11
  52. package/dist/cjs/tools/package.d.ts +0 -49
  53. package/dist/cjs/tools/package.js +0 -50
  54. package/dist/cjs/types/enums.d.ts +0 -44
  55. package/dist/cjs/types/enums.js +0 -38
  56. package/dist/cjs/types/interfaces.d.ts +0 -25
  57. package/dist/cjs/types/interfaces.js +0 -2
  58. package/dist/cjs/types/options.d.ts +0 -241
  59. package/dist/cjs/types/options.js +0 -2
  60. package/dist/cjs/types/types.d.ts +0 -61
  61. package/dist/cjs/types/types.js +0 -2
  62. package/dist/cjs/utils/ClientUtil.d.ts +0 -25
  63. package/dist/cjs/utils/ClientUtil.js +0 -211
  64. package/dist/cjs/utils/CommandUtil.d.ts +0 -58
  65. package/dist/cjs/utils/CommandUtil.js +0 -247
  66. package/dist/cjs/validators/CommandValidations.d.ts +0 -12
  67. package/dist/cjs/validators/CommandValidations.js +0 -169
  68. package/dist/cjs/validators/InhibitorValidations.d.ts +0 -11
  69. package/dist/cjs/validators/InhibitorValidations.js +0 -40
  70. package/dist/mjs/build/ContextCommandBuilder.d.ts +0 -68
  71. package/dist/mjs/build/ContextCommandBuilder.js +0 -88
  72. package/dist/mjs/build/EventBuilder.d.ts +0 -21
  73. package/dist/mjs/build/EventBuilder.js +0 -34
  74. package/dist/mjs/build/InhibitorBuilder.d.ts +0 -19
  75. package/dist/mjs/build/InhibitorBuilder.js +0 -27
  76. package/dist/mjs/build/MessageCommandBuilder.d.ts +0 -59
  77. package/dist/mjs/build/MessageCommandBuilder.js +0 -90
  78. package/dist/mjs/build/SlashCommandBuilder.d.ts +0 -64
  79. package/dist/mjs/build/SlashCommandBuilder.js +0 -121
  80. package/dist/mjs/client/XernerxClient.d.ts +0 -28
  81. package/dist/mjs/client/XernerxClient.js +0 -108
  82. package/dist/mjs/handlers/CommandHandler.d.ts +0 -27
  83. package/dist/mjs/handlers/CommandHandler.js +0 -42
  84. package/dist/mjs/handlers/EventHandler.d.ts +0 -13
  85. package/dist/mjs/handlers/EventHandler.js +0 -16
  86. package/dist/mjs/handlers/Handler.d.ts +0 -57
  87. package/dist/mjs/handlers/Handler.js +0 -260
  88. package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -18
  89. package/dist/mjs/handlers/InhibitorHandler.js +0 -21
  90. package/dist/mjs/main.d.ts +0 -44
  91. package/dist/mjs/main.js +0 -52
  92. package/dist/mjs/models/CommandArguments.d.ts +0 -17
  93. package/dist/mjs/models/CommandArguments.js +0 -101
  94. package/dist/mjs/models/Events.d.ts +0 -24
  95. package/dist/mjs/models/Events.js +0 -295
  96. package/dist/mjs/models/Extensions.d.ts +0 -7
  97. package/dist/mjs/models/Extensions.js +0 -23
  98. package/dist/mjs/tools/XernerxError.d.ts +0 -5
  99. package/dist/mjs/tools/XernerxError.js +0 -8
  100. package/dist/mjs/tools/package.d.ts +0 -49
  101. package/dist/mjs/tools/package.js +0 -48
  102. package/dist/mjs/types/enums.d.ts +0 -44
  103. package/dist/mjs/types/enums.js +0 -35
  104. package/dist/mjs/types/interfaces.d.ts +0 -25
  105. package/dist/mjs/types/interfaces.js +0 -1
  106. package/dist/mjs/types/options.d.ts +0 -241
  107. package/dist/mjs/types/options.js +0 -1
  108. package/dist/mjs/types/types.d.ts +0 -61
  109. package/dist/mjs/types/types.js +0 -1
  110. package/dist/mjs/utils/ClientUtil.d.ts +0 -25
  111. package/dist/mjs/utils/ClientUtil.js +0 -202
  112. package/dist/mjs/utils/CommandUtil.d.ts +0 -58
  113. package/dist/mjs/utils/CommandUtil.js +0 -232
  114. package/dist/mjs/validators/CommandValidations.d.ts +0 -12
  115. package/dist/mjs/validators/CommandValidations.js +0 -166
  116. package/dist/mjs/validators/InhibitorValidations.d.ts +0 -11
  117. package/dist/mjs/validators/InhibitorValidations.js +0 -36
@@ -1,57 +0,0 @@
1
- import XernerxClient from '../client/XernerxClient.js';
2
- import { ContextCommandHandlerOptions, EventHandlerOptions, InhibitorHandlerOptions, MessageCommandHandlerOptions, SlashCommandHandlerOptions } from '../types/options.js';
3
- /**
4
- * @description - The Handler class.
5
- * @param {XernerxClient} client - The XernerxClient.
6
- */
7
- export declare class Handler {
8
- private client;
9
- commands: object[];
10
- readyTimestamp: number;
11
- constructor(client: XernerxClient);
12
- /**
13
- * @description - The loader for the message commands.
14
- * @param {MessageCommandOptions} options - The options for the message command loader.
15
- */
16
- loadAllMessageCommands(options: MessageCommandHandlerOptions): void;
17
- /**
18
- * @description - The loader for the slash commands.
19
- * @param {SlashCommandOptions} options - The options for the slash command loader.
20
- */
21
- loadAllSlashCommands(options: SlashCommandHandlerOptions): void;
22
- /**
23
- * @description - The loader for the context commands.
24
- * @param {ContextCommandOptions} options - The options for the context command loader.
25
- */
26
- loadAllContextCommands(options: ContextCommandHandlerOptions): void;
27
- /**
28
- * @description - The loader for the events.
29
- * @param {EventLoadOptions} options - The options for the event loader.
30
- */
31
- loadAllEvents(options: EventHandlerOptions): void;
32
- /**
33
- * @description - The loader for the inhibitors.
34
- * @param {InhibitorLoadOptions} options - The options for the inhibitor loader.
35
- */
36
- loadAllInhibitors(options: InhibitorHandlerOptions): void;
37
- /**
38
- * @description - a reader for directories
39
- * @param {string} dir - the directory to look for.
40
- * @returns array of files.
41
- */
42
- private readdir;
43
- /**
44
- * @description file loader.
45
- * @param {string} dir - the directory.
46
- * @param {string} file - the file in the directory.
47
- * @param {string} type - the type of file.
48
- * @returns undefined
49
- */
50
- private load;
51
- /**
52
- * @description the event emitter to emit all events.
53
- * @param {object} event - the event to be emitted.
54
- * @returns void
55
- */
56
- private emitter;
57
- }
@@ -1,260 +0,0 @@
1
- import fs from 'fs';
2
- import * as path from 'path';
3
- import { CommandType } from '../types/enums.js';
4
- import { s } from '@sapphire/shapeshift';
5
- import { Style } from 'dumfunctions';
6
- // TODO - Add reload<handlerFunction>
7
- // TODO - Add unload<handlerFunction>
8
- // TODO - Rename load<handlerFunction>
9
- // TODO - Update validator to zod
10
- /**
11
- * @description - The Handler class.
12
- * @param {XernerxClient} client - The XernerxClient.
13
- */
14
- export class Handler {
15
- client;
16
- commands;
17
- readyTimestamp;
18
- constructor(client) {
19
- this.client = client;
20
- this.commands = [];
21
- this.readyTimestamp = Number(Date.now());
22
- }
23
- /**
24
- * @description - The loader for the message commands.
25
- * @param {MessageCommandOptions} options - The options for the message command loader.
26
- */
27
- loadAllMessageCommands(options) {
28
- this.client.handlerOptions.message = s
29
- .object({
30
- directory: s.string,
31
- prefix: s.union(s.string, s.array(s.string)),
32
- allowMention: s.boolean.default(false),
33
- cooldown: s.number.default(0),
34
- userPermissions: s.array(s.bigint).default([]),
35
- clientPermissions: s.array(s.bigint).default([]),
36
- handleEdits: s.boolean.default(false),
37
- handleDeletes: s.boolean.default(false),
38
- handleTyping: s.boolean.default(false),
39
- logging: s.boolean.default(false),
40
- })
41
- .parse(options);
42
- const files = this.readdir(options.directory),
43
- loaded = [];
44
- for (const file of files) {
45
- this.load(options.directory, file, CommandType.MessageCommand);
46
- loaded.push(file.replace('.js', ''));
47
- }
48
- if (this.client.handlerOptions.message?.logging)
49
- console.info(
50
- Style.log(`Xernerx | Loaded ${loaded.length} message commands: ${loaded.join(', ')}.`, {
51
- color: Style.TextColor.Cyan,
52
- })
53
- );
54
- }
55
- /**
56
- * @description - The loader for the slash commands.
57
- * @param {SlashCommandOptions} options - The options for the slash command loader.
58
- */
59
- loadAllSlashCommands(options) {
60
- this.client.handlerOptions.slash = s
61
- .object({
62
- directory: s.string,
63
- guildId: s.string,
64
- global: s.boolean,
65
- cooldown: s.number.default(0),
66
- userPermissions: s.array(s.bigint).default([]),
67
- clientPermissions: s.array(s.bigint).default([]),
68
- logging: s.boolean.default(false),
69
- defer: s.object({
70
- reply: s.boolean.optional,
71
- ephemeral: s.boolean.optional,
72
- fetchReply: s.boolean.optional,
73
- }).optional,
74
- })
75
- .parse(options);
76
- const files = this.readdir(options.directory),
77
- loaded = [];
78
- for (const file of files) {
79
- this.load(options.directory, file, CommandType.SlashCommand);
80
- loaded.push(file.replace('.js', ''));
81
- }
82
- if (this.client.handlerOptions.slash?.logging)
83
- console.info(
84
- Style.log(`Xernerx | Loaded ${loaded.length} slash commands: ${loaded.join(', ')}.`, {
85
- color: Style.TextColor.Cyan,
86
- })
87
- );
88
- }
89
- /**
90
- * @description - The loader for the context commands.
91
- * @param {ContextCommandOptions} options - The options for the context command loader.
92
- */
93
- loadAllContextCommands(options) {
94
- this.client.handlerOptions.context = s
95
- .object({
96
- directory: s.string,
97
- guildId: s.string,
98
- global: s.boolean,
99
- cooldown: s.number.default(0),
100
- userPermissions: s.array(s.bigint).default([]),
101
- clientPermissions: s.array(s.bigint).default([]),
102
- logging: s.boolean.default(false),
103
- defer: s.object({
104
- reply: s.boolean.optional,
105
- ephemeral: s.boolean.optional,
106
- fetchReply: s.boolean.optional,
107
- }).optional,
108
- })
109
- .parse(options);
110
- const files = this.readdir(options.directory),
111
- loaded = [];
112
- for (const file of files) {
113
- this.load(options.directory, file, CommandType.ContextCommand);
114
- loaded.push(file.replace('.js', ''));
115
- }
116
- if (this.client.handlerOptions.context?.logging)
117
- console.info(
118
- Style.log(`Xernerx | Loaded ${loaded.length} context commands: ${loaded.join(', ')}.`, {
119
- color: Style.TextColor.Cyan,
120
- })
121
- );
122
- }
123
- /**
124
- * @description - The loader for the events.
125
- * @param {EventLoadOptions} options - The options for the event loader.
126
- */
127
- loadAllEvents(options) {
128
- this.client.handlerOptions.events = s
129
- .object({
130
- directory: s.string,
131
- logging: s.boolean.default(false),
132
- })
133
- .parse(options);
134
- const files = this.readdir(options.directory),
135
- loaded = [];
136
- (async () => {
137
- for (const file of files) {
138
- try {
139
- options.directory.split(/\//).shift();
140
- let event = (await import('file://' + `${path.resolve(options.directory)}/${file}`)).default;
141
- event = new event();
142
- event.client = this.client;
143
- event.commandType = CommandType.Event;
144
- this.client.events.set(event.name, event);
145
- this.emitter(event);
146
- } catch (error) {
147
- console.error(Style.log(`Xernerx | Couldn't load ${file} because <${error}>`, { color: Style.BackgroundColor.Red }));
148
- }
149
- loaded.push(file.replace('.js', ''));
150
- }
151
- if (this.client.handlerOptions.events?.logging) console.info(Style.log(`Xernerx | Loaded ${loaded.length} events: ${loaded.join(', ')}.`, { color: Style.TextColor.Cyan }));
152
- })();
153
- }
154
- /**
155
- * @description - The loader for the inhibitors.
156
- * @param {InhibitorLoadOptions} options - The options for the inhibitor loader.
157
- */
158
- loadAllInhibitors(options) {
159
- this.client.handlerOptions.inhibitors = s
160
- .object({
161
- directory: s.string,
162
- logging: s.boolean.default(false),
163
- })
164
- .parse(options);
165
- const files = this.readdir(options.directory),
166
- loaded = [];
167
- for (const file of files) {
168
- this.load(options.directory, file, CommandType.Inhibitor);
169
- loaded.push(file.replace('.js', ''));
170
- }
171
- if (this.client.handlerOptions.inhibitors?.logging)
172
- console.info(
173
- Style.log(`Xernerx | Loaded ${loaded.length} inhibitors: ${loaded.join(', ')}.`, {
174
- color: Style.TextColor.Cyan,
175
- })
176
- );
177
- }
178
- /**
179
- * @description - a reader for directories
180
- * @param {string} dir - the directory to look for.
181
- * @returns array of files.
182
- */
183
- readdir(dir) {
184
- try {
185
- return fs.readdirSync(path.resolve(dir)).filter((file) => file.endsWith('.js'));
186
- } catch (error) {
187
- console.error(Style.log(`Xernerx | Couldn't read ${dir} because <${error}>.`, { color: Style.BackgroundColor.Red }));
188
- }
189
- return [];
190
- }
191
- /**
192
- * @description file loader.
193
- * @param {string} dir - the directory.
194
- * @param {string} file - the file in the directory.
195
- * @param {string} type - the type of file.
196
- * @returns undefined
197
- */
198
- async load(dir, file, type) {
199
- try {
200
- dir.split(/\//).shift();
201
- let command = (await import('file://' + `${path.resolve(dir)}/${file}`)).default;
202
- command = new command();
203
- command.client = this.client;
204
- command.commandType = type;
205
- command.filepath = `${path.resolve(dir)}\\${file}`;
206
- command.file = file;
207
- if (type === CommandType.MessageCommand) this.client.commands.message.set(command?.name || command?.name, command);
208
- if (type === CommandType.SlashCommand) {
209
- this.client.commands.slash.set(command?.data?.name || command?.name, command);
210
- }
211
- if (type === CommandType.ContextCommand) {
212
- this.client.commands.context.set(command?.data?.name || command?.name, command);
213
- }
214
- if (type === CommandType.Event) {
215
- this.client.events.set(command.name, command);
216
- }
217
- if (type === CommandType.Inhibitor) {
218
- this.client.inhibitors.set(command.name, command);
219
- }
220
- } catch (error) {
221
- console.error(Style.log(`Xernerx | Couldn't load ${file} because <${error}>`, { color: Style.BackgroundColor.Red }));
222
- }
223
- }
224
- /**
225
- * @description the event emitter to emit all events.
226
- * @param {object} event - the event to be emitted.
227
- * @returns void
228
- */
229
- emitter(event) {
230
- const client = this.client;
231
- if (event.emitter === 'client') {
232
- if (event.once)
233
- client.once(event.name, (...args) => {
234
- event.run(...args);
235
- });
236
- else
237
- client.on(event.name, (...args) => {
238
- event.run(...args);
239
- });
240
- } else if (event.emitter === 'rest') {
241
- if (event.once)
242
- client.once(event.name, (...args) => {
243
- event.run(...args);
244
- });
245
- else
246
- client.on(event.name, (...args) => {
247
- event.run(...args);
248
- });
249
- } else if (event.emitter === 'process') {
250
- if (event.once)
251
- process.once(event.name, (...args) => {
252
- event.run(...args);
253
- });
254
- else
255
- process.on(event.name, (...args) => {
256
- event.run(...args);
257
- });
258
- }
259
- }
260
- }
@@ -1,18 +0,0 @@
1
- import XernerxClient from '../client/XernerxClient.js';
2
- import { InhibitorHandlerOptions } from '../types/options.js';
3
- import { Handler } from './Handler.js';
4
- /**
5
- * @description - Inhibitor loader.
6
- * @param {XernerxClient} client - The XernerxClient.
7
- */
8
- export default class InhibitorHandler {
9
- client: XernerxClient;
10
- handler: Handler;
11
- constructor(client: XernerxClient);
12
- /**
13
- * @description - The loader for all inhibitors.
14
- * @param {InhibitorLoadOptions} options - the inhibitor loader options.
15
- * @returns undefined
16
- */
17
- loadAllInhibitors(options: InhibitorHandlerOptions): void;
18
- }
@@ -1,21 +0,0 @@
1
- import { Handler } from './Handler.js';
2
- /**
3
- * @description - Inhibitor loader.
4
- * @param {XernerxClient} client - The XernerxClient.
5
- */
6
- export default class InhibitorHandler {
7
- client;
8
- handler;
9
- constructor(client) {
10
- this.client = client;
11
- this.handler = new Handler(client);
12
- }
13
- /**
14
- * @description - The loader for all inhibitors.
15
- * @param {InhibitorLoadOptions} options - the inhibitor loader options.
16
- * @returns undefined
17
- */
18
- loadAllInhibitors(options) {
19
- this.handler.loadAllInhibitors(options);
20
- }
21
- }
@@ -1,44 +0,0 @@
1
- export * from 'discord.js';
2
- export * from 'dumfunctions';
3
- import ExtensionBuilder from 'xernerx-extension-builder';
4
- import XernerxClient from './client/XernerxClient.js';
5
- import EventBuilder from './build/EventBuilder.js';
6
- import InhibitorBuilder from './build/InhibitorBuilder.js';
7
- import MessageCommandBuilder from './build/MessageCommandBuilder.js';
8
- import ContextCommandBuilder from './build/ContextCommandBuilder.js';
9
- import SlashCommandBuilder from './build/SlashCommandBuilder.js';
10
- import { CommandType, EventEmitterType, ContextCommandType, InhibitorType } from './types/enums.js';
11
- import XernerxError from './tools/XernerxError.js';
12
- declare const xernerxVersion: string;
13
- declare const _default: {
14
- Client: typeof XernerxClient;
15
- XernerxClient: typeof XernerxClient;
16
- CommandType: typeof CommandType;
17
- EventEmitterType: typeof EventEmitterType;
18
- InhibitorType: typeof InhibitorType;
19
- ContextCommandType: typeof ContextCommandType;
20
- EventBuilder: typeof EventBuilder;
21
- MessageCommandBuilder: typeof MessageCommandBuilder;
22
- ContextCommandBuilder: typeof ContextCommandBuilder;
23
- SlashCommandBuilder: typeof SlashCommandBuilder;
24
- InhibitorBuilder: typeof InhibitorBuilder;
25
- ExtensionBuilder: typeof ExtensionBuilder;
26
- XernerxError: typeof XernerxError;
27
- version: string;
28
- };
29
- export default _default;
30
- export {
31
- XernerxClient,
32
- CommandType,
33
- EventEmitterType,
34
- InhibitorType,
35
- ContextCommandType,
36
- EventBuilder,
37
- MessageCommandBuilder,
38
- ContextCommandBuilder,
39
- SlashCommandBuilder,
40
- InhibitorBuilder,
41
- ExtensionBuilder,
42
- XernerxError,
43
- xernerxVersion,
44
- };
package/dist/mjs/main.js DELETED
@@ -1,52 +0,0 @@
1
- export * from 'discord.js';
2
- export * from 'dumfunctions';
3
- import ExtensionBuilder from 'xernerx-extension-builder';
4
- import XernerxClient from './client/XernerxClient.js';
5
- import EventBuilder from './build/EventBuilder.js';
6
- import InhibitorBuilder from './build/InhibitorBuilder.js';
7
- import MessageCommandBuilder from './build/MessageCommandBuilder.js';
8
- import ContextCommandBuilder from './build/ContextCommandBuilder.js';
9
- import SlashCommandBuilder from './build/SlashCommandBuilder.js';
10
- import { CommandType, EventEmitterType, ContextCommandType, InhibitorType } from './types/enums.js';
11
- import XernerxError from './tools/XernerxError.js';
12
- import pkg from './tools/package.js';
13
- const xernerxVersion = pkg.version;
14
- export default {
15
- // Client
16
- Client: XernerxClient,
17
- XernerxClient,
18
- // Enums
19
- CommandType,
20
- EventEmitterType,
21
- InhibitorType,
22
- ContextCommandType,
23
- // Builds
24
- EventBuilder,
25
- MessageCommandBuilder,
26
- ContextCommandBuilder,
27
- SlashCommandBuilder,
28
- InhibitorBuilder,
29
- ExtensionBuilder,
30
- XernerxError,
31
- // Constants
32
- version: xernerxVersion,
33
- };
34
- export {
35
- // Client
36
- XernerxClient,
37
- // Enums
38
- CommandType,
39
- EventEmitterType,
40
- InhibitorType,
41
- ContextCommandType,
42
- // Builds
43
- EventBuilder,
44
- MessageCommandBuilder,
45
- ContextCommandBuilder,
46
- SlashCommandBuilder,
47
- InhibitorBuilder,
48
- ExtensionBuilder,
49
- XernerxError,
50
- // Constants
51
- xernerxVersion,
52
- };
@@ -1,17 +0,0 @@
1
- import MessageCommandBuilder from '../build/MessageCommandBuilder.js';
2
- import { XernerxInteraction, XernerxMessage } from '../types/types.js';
3
- export declare class InteractionArguments {
4
- interaction: XernerxInteraction;
5
- constructor(interaction: XernerxInteraction);
6
- group(): string | undefined;
7
- subcommand(): string | undefined;
8
- arguments(): Record<string, object>;
9
- }
10
- interface Flag {
11
- flags: Record<string, string | boolean>;
12
- }
13
- interface Argument {
14
- [index: string]: string | number | null;
15
- }
16
- export declare function messageArguments(message: XernerxMessage, command: MessageCommandBuilder): Promise<import('discord.js').Message<boolean> | Flag | Argument | undefined>;
17
- export {};
@@ -1,101 +0,0 @@
1
- export class InteractionArguments {
2
- interaction;
3
- constructor(interaction) {
4
- this.interaction = interaction;
5
- }
6
- group() {
7
- return this.interaction?.options?._group;
8
- }
9
- subcommand() {
10
- return this.interaction?.options?._subcommand;
11
- }
12
- arguments() {
13
- const options = {};
14
- if (this.interaction?.options?._hoistedOptions) {
15
- for (const option of this.interaction.options._hoistedOptions) {
16
- options[option.name] = option.channel || option.user || option.role || option.value;
17
- }
18
- }
19
- return options;
20
- }
21
- }
22
- export async function messageArguments(message, command) {
23
- let args = { flags: {} },
24
- separator = command.separator || ' ',
25
- i = 0;
26
- if (!command.args) return;
27
- command.args
28
- .filter((c) => c.type == 'flag')
29
- .map((flag) => {
30
- args = args;
31
- for (const flg of message.content.matchAll(flag.match)) {
32
- if (flag.match == flg) {
33
- message.content = message.content.replace(flag.match, '');
34
- args.flags[flag.name] = true;
35
- }
36
- }
37
- if (!args.flags[flag.name]) args.flags[flag.name] = false;
38
- });
39
- for (const argument of command.args) {
40
- args = args;
41
- let content = message.content
42
- .split(/ +/)
43
- .slice(1)
44
- .join(separator)
45
- .replace(new RegExp(`${separator}${separator}+`, 'g'), separator)
46
- .split(separator)
47
- .slice(i);
48
- if (content.join(separator) != '' && argument.type !== 'flag') {
49
- if (argument?.content?.includes(content[0])) {
50
- args[argument.name] = content[0];
51
- } else if (argument.type == 'string') {
52
- args[argument.name] = content[0];
53
- } else if (argument.type == 'number') {
54
- args[argument.name] = parseInt(content[0]);
55
- } else if (argument.type == 'boolean') {
56
- if (content[0]?.toLowerCase() != 'true' && content[0]?.toLowerCase() != 'false') content[0] = null;
57
- args[argument.name] = content[0];
58
- } else if (argument.type == 'user') {
59
- let user = message.client.users.cache.find((u) => u?.username?.toLowerCase()?.includes(content[0])) || null;
60
- try {
61
- user = (await message.client.users.fetch(user?.id || content[0].replace(/<@!?|>/g, ''))) || null;
62
- } catch (e) {
63
- user = null;
64
- }
65
- args[argument.name] = user;
66
- } else if (argument.type == 'role') {
67
- let role = message.guild?.roles.cache.find((r) => r?.name?.toLowerCase()?.includes(content[0])) || null;
68
- try {
69
- role = (await message.guild?.roles.fetch(role?.id || content[0].replace(/<@&?|>/g, ''))) || null;
70
- } catch (e) {
71
- role = null;
72
- }
73
- args[argument.name] = role;
74
- } else if (argument.type == 'member') {
75
- let member = message.guild?.members.cache.find((m) => m?.nickname?.toLowerCase()?.includes(content[0]) || m?.user?.username?.toLowerCase()?.includes(content[0])) || null;
76
- try {
77
- member = (await message.guild?.members.fetch(member?.id || content[0].replace(/<@!?|>/g, ''))) || null;
78
- } catch (e) {
79
- member = null;
80
- }
81
- args[argument.name] = member;
82
- } else if (argument.type == 'channel') {
83
- let channel = message.guild?.channels.cache.find((c) => c?.name?.toLowerCase()?.includes(content[0]));
84
- try {
85
- channel = await message.client.channels.fetch(channel?.id || content[0].replace(/<#|>/g, ''));
86
- } catch (e) {
87
- channel = null;
88
- }
89
- args[argument.name] = channel;
90
- } else if (argument.type == 'rest') {
91
- args[argument.name] = content.join(separator);
92
- break;
93
- } else if (argument.prompt) {
94
- if (argument.prompt.reply) return message.util?.reply(argument.prompt.reply);
95
- else if (argument.prompt.send) return message.channel.send(argument.prompt.send);
96
- } else args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
97
- i++;
98
- } else args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
99
- }
100
- return args;
101
- }
@@ -1,24 +0,0 @@
1
- import XernerxClient from '../client/XernerxClient.js';
2
- export declare class MessageCommandEvents {
3
- client: XernerxClient;
4
- constructor(client: XernerxClient);
5
- messageCreate(): void;
6
- messageUpdate(): void;
7
- messageDelete(): void;
8
- }
9
- export declare class SlashCommandEvents {
10
- client: XernerxClient;
11
- constructor(client: XernerxClient);
12
- slashCreate(): void;
13
- }
14
- export declare class ContextCommandEvents {
15
- client: XernerxClient;
16
- constructor(client: XernerxClient);
17
- contextCreate(): void;
18
- }
19
- export declare class CommandsDeploy {
20
- private client;
21
- constructor(client: XernerxClient);
22
- deploy(): void;
23
- private put;
24
- }