xernerx 4.7.1 → 4.8.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 (114) hide show
  1. package/dist/build/XernerxContextCommand.d.ts +2 -0
  2. package/dist/build/XernerxContextCommand.js +1 -0
  3. package/dist/build/XernerxMessageCommand.d.ts +2 -0
  4. package/dist/build/XernerxMessageCommand.js +1 -0
  5. package/dist/build/XernerxSlashCommand.d.ts +2 -0
  6. package/dist/build/XernerxSlashCommand.js +1 -0
  7. package/dist/client/XernerxClient.d.ts +1 -1
  8. package/dist/functions/load.js +1 -0
  9. package/dist/functions/reload.d.ts +2 -2
  10. package/dist/functions/reload.js +24 -37
  11. package/dist/handlers/CommandHandler.d.ts +3 -2
  12. package/dist/handlers/CommandHandler.js +37 -15
  13. package/dist/handlers/EventHandler.d.ts +1 -0
  14. package/dist/handlers/EventHandler.js +6 -3
  15. package/dist/handlers/ExtensionHandler.d.ts +1 -0
  16. package/dist/handlers/ExtensionHandler.js +6 -2
  17. package/dist/handlers/Handler.d.ts +0 -1
  18. package/dist/handlers/Handler.js +0 -2
  19. package/dist/handlers/InhibitorHandler.d.ts +1 -0
  20. package/dist/handlers/InhibitorHandler.js +8 -3
  21. package/dist/handlers/WebhookHandler.d.ts +1 -0
  22. package/dist/handlers/WebhookHandler.js +1 -0
  23. package/dist/utils/InteractionUtil.d.ts +6 -2
  24. package/dist/utils/InteractionUtil.js +4 -1
  25. package/dist/utils/MessageUtil.d.ts +3 -2
  26. package/dist/utils/MessageUtil.js +1 -1
  27. package/dist/validators/commandValidation.js +7 -7
  28. package/package.json +1 -1
  29. package/dist/build/ContextCommandBuilder.d.ts +0 -43
  30. package/dist/build/ContextCommandBuilder.d.ts.map +0 -1
  31. package/dist/build/ContextCommandBuilder.js +0 -68
  32. package/dist/build/ContextCommandBuilder.js.map +0 -1
  33. package/dist/build/EventBuilder.d.ts +0 -25
  34. package/dist/build/EventBuilder.d.ts.map +0 -1
  35. package/dist/build/EventBuilder.js +0 -30
  36. package/dist/build/EventBuilder.js.map +0 -1
  37. package/dist/build/InhibitorBuilder.d.ts +0 -20
  38. package/dist/build/InhibitorBuilder.d.ts.map +0 -1
  39. package/dist/build/InhibitorBuilder.js +0 -21
  40. package/dist/build/InhibitorBuilder.js.map +0 -1
  41. package/dist/build/MessageCommandBuilder.d.ts +0 -42
  42. package/dist/build/MessageCommandBuilder.d.ts.map +0 -1
  43. package/dist/build/MessageCommandBuilder.js +0 -61
  44. package/dist/build/MessageCommandBuilder.js.map +0 -1
  45. package/dist/build/SlashCommandBuilder.d.ts +0 -48
  46. package/dist/build/SlashCommandBuilder.d.ts.map +0 -1
  47. package/dist/build/SlashCommandBuilder.js +0 -114
  48. package/dist/build/SlashCommandBuilder.js.map +0 -1
  49. package/dist/client/XernerxClient.d.ts.map +0 -1
  50. package/dist/client/XernerxClient.js.map +0 -1
  51. package/dist/client/XernerxShardClient.d.ts.map +0 -1
  52. package/dist/client/XernerxShardClient.js.map +0 -1
  53. package/dist/functions/delay.d.ts +0 -2
  54. package/dist/functions/delay.d.ts.map +0 -1
  55. package/dist/functions/delay.js +0 -4
  56. package/dist/functions/delay.js.map +0 -1
  57. package/dist/functions/deploy.d.ts.map +0 -1
  58. package/dist/functions/deploy.js.map +0 -1
  59. package/dist/functions/isOwner.d.ts +0 -4
  60. package/dist/functions/isOwner.d.ts.map +0 -1
  61. package/dist/functions/isOwner.js +0 -4
  62. package/dist/functions/isOwner.js.map +0 -1
  63. package/dist/functions/isVoter.d.ts +0 -4
  64. package/dist/functions/isVoter.d.ts.map +0 -1
  65. package/dist/functions/isVoter.js +0 -6
  66. package/dist/functions/isVoter.js.map +0 -1
  67. package/dist/functions/load.d.ts.map +0 -1
  68. package/dist/functions/load.js.map +0 -1
  69. package/dist/functions/reload.d.ts.map +0 -1
  70. package/dist/functions/reload.js.map +0 -1
  71. package/dist/functions/sendWebhook.d.ts.map +0 -1
  72. package/dist/functions/sendWebhook.js.map +0 -1
  73. package/dist/functions/setPresence.d.ts.map +0 -1
  74. package/dist/functions/setPresence.js.map +0 -1
  75. package/dist/functions/xernerxUser.d.ts.map +0 -1
  76. package/dist/functions/xernerxUser.js.map +0 -1
  77. package/dist/handlers/CommandHandler.d.ts.map +0 -1
  78. package/dist/handlers/CommandHandler.js.map +0 -1
  79. package/dist/handlers/EventHandler.d.ts.map +0 -1
  80. package/dist/handlers/EventHandler.js.map +0 -1
  81. package/dist/handlers/ExtensionHandler.d.ts.map +0 -1
  82. package/dist/handlers/ExtensionHandler.js.map +0 -1
  83. package/dist/handlers/Handler.d.ts.map +0 -1
  84. package/dist/handlers/Handler.js.map +0 -1
  85. package/dist/handlers/InhibitorHandler.d.ts.map +0 -1
  86. package/dist/handlers/InhibitorHandler.js.map +0 -1
  87. package/dist/handlers/WebhookHandler.d.ts.map +0 -1
  88. package/dist/handlers/WebhookHandler.js.map +0 -1
  89. package/dist/main.d.ts.map +0 -1
  90. package/dist/main.js.map +0 -1
  91. package/dist/models/Arguments.d.ts.map +0 -1
  92. package/dist/models/Arguments.js.map +0 -1
  93. package/dist/tools/XernerxError.d.ts.map +0 -1
  94. package/dist/tools/XernerxError.js.map +0 -1
  95. package/dist/tools/XernerxLog.d.ts.map +0 -1
  96. package/dist/tools/XernerxLog.js.map +0 -1
  97. package/dist/types/extenders.d.ts.map +0 -1
  98. package/dist/types/extenders.js.map +0 -1
  99. package/dist/types/interfaces.d.ts.map +0 -1
  100. package/dist/types/interfaces.js.map +0 -1
  101. package/dist/types/types.d.ts.map +0 -1
  102. package/dist/types/types.js.map +0 -1
  103. package/dist/utils/ClientUtil.d.ts.map +0 -1
  104. package/dist/utils/ClientUtil.js.map +0 -1
  105. package/dist/utils/InteractionUtil.d.ts.map +0 -1
  106. package/dist/utils/InteractionUtil.js.map +0 -1
  107. package/dist/utils/MessageUtil.d.ts.map +0 -1
  108. package/dist/utils/MessageUtil.js.map +0 -1
  109. package/dist/utils/Util.d.ts.map +0 -1
  110. package/dist/utils/Util.js.map +0 -1
  111. package/dist/validators/commandValidation.d.ts.map +0 -1
  112. package/dist/validators/commandValidation.js.map +0 -1
  113. package/dist/validators/inhibitorValidations.d.ts.map +0 -1
  114. package/dist/validators/inhibitorValidations.js.map +0 -1
@@ -2,6 +2,7 @@
2
2
  import { ContextMenuCommandBuilder } from 'discord.js';
3
3
  import { XernerxMessageContextInteraction, XernerxUserContextInteraction, XernerxClientType } from '../types/extenders.js';
4
4
  import { ContextCommandArguments, ContextCommandOptions } from '../types/interfaces.js';
5
+ import InteractionUtil from '../utils/InteractionUtil.js';
5
6
  export default class XernerxContextCommand {
6
7
  readonly id: string;
7
8
  readonly data: ContextMenuCommandBuilder;
@@ -41,6 +42,7 @@ export default class XernerxContextCommand {
41
42
  readonly filetype: 'ContextCommand';
42
43
  readonly filepath: string;
43
44
  readonly client: XernerxClientType;
45
+ util: InteractionUtil;
44
46
  constructor(id: string, options: ContextCommandOptions);
45
47
  /**
46
48
  * @description the execution of the command
@@ -107,6 +107,7 @@ export default class XernerxContextCommand {
107
107
  this.permissions = options.permissions;
108
108
  this.defer = options.defer;
109
109
  this.client = this.client;
110
+ this.util = this.util;
110
111
  }
111
112
  /**
112
113
  * @description the execution of the command
@@ -1,6 +1,7 @@
1
1
  /** @format */
2
2
  import { XernerxClientType, XernerxMessage } from '../types/extenders.js';
3
3
  import { MessageCommandArguments, MessageCommandOptions } from '../types/interfaces.js';
4
+ import MessageUtil from '../utils/MessageUtil.js';
4
5
  export default class XernerxMessageCommand {
5
6
  readonly id: string;
6
7
  readonly name: string;
@@ -39,6 +40,7 @@ export default class XernerxMessageCommand {
39
40
  readonly filetype: 'MessageCommand';
40
41
  readonly filepath: string;
41
42
  readonly client: XernerxClientType;
43
+ util: MessageUtil;
42
44
  constructor(id: string, options: MessageCommandOptions);
43
45
  /**
44
46
  * @description Checks for conditions before running the command
@@ -99,6 +99,7 @@ export default class XernerxMessageCommand {
99
99
  this.separator = options.separator;
100
100
  this.permissions = options.permissions;
101
101
  this.client = this.client;
102
+ this.util = this.util;
102
103
  }
103
104
  /**
104
105
  * @description Checks for conditions before running the command
@@ -3,6 +3,7 @@ import Discord from 'discord.js';
3
3
  import { XernerxClientType, XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
4
4
  import { SlashCommandArguments, SlashCommandOptions } from '../types/interfaces.js';
5
5
  import { XernerxInteraction } from '../types/types.js';
6
+ import InteractionUtil from '../utils/InteractionUtil.js';
6
7
  export default class XernerxSlashCommand {
7
8
  readonly id: string;
8
9
  readonly data: Discord.SlashCommandBuilder;
@@ -41,6 +42,7 @@ export default class XernerxSlashCommand {
41
42
  readonly filetype: 'SlashCommand';
42
43
  readonly filepath: string;
43
44
  readonly client: XernerxClientType;
45
+ util: InteractionUtil;
44
46
  constructor(id: string, options: SlashCommandOptions);
45
47
  /**
46
48
  * @description autocomplete let's you add choices to string option arguments
@@ -115,6 +115,7 @@ export default class XernerxSlashCommand {
115
115
  this.permissions = options.permissions;
116
116
  this.defer = options.defer;
117
117
  this.client = this.client;
118
+ this.util = this.util;
118
119
  }
119
120
  /**
120
121
  * @description autocomplete let's you add choices to string option arguments
@@ -10,8 +10,8 @@ export default class XernerxClient extends Client {
10
10
  local: string;
11
11
  global?: boolean | undefined;
12
12
  permissions?: {
13
- client: string[] | null;
14
13
  user: string[] | null;
14
+ client: string[] | null;
15
15
  dm: boolean;
16
16
  } | undefined;
17
17
  ignore?: {
@@ -6,6 +6,7 @@ export default async function load(client, path, type) {
6
6
  file.filetype = type;
7
7
  file.filepath = path;
8
8
  file.client = client;
9
+ file.util = {};
9
10
  fileSave(client, file, type);
10
11
  return file;
11
12
  }
@@ -1,3 +1,3 @@
1
1
  /** @format */
2
- import XernerxClient from '../client/XernerxClient.js';
3
- export default function reload(client: XernerxClient, type: 'message' | 'slash' | 'context' | 'event' | 'inhibitor'): Promise<any>[];
2
+ import { XernerxClient } from '../main.js';
3
+ export default function reload(client: XernerxClient, type: 'commands' | 'context' | 'message' | 'slash' | 'events' | 'inhibitors'): Promise<true | void | null>;
@@ -1,43 +1,30 @@
1
1
  /** @format */
2
- var filetypes;
3
- (function (filetypes) {
4
- filetypes["message"] = "MessageCommand";
5
- filetypes["slash"] = "SlashCommand";
6
- filetypes["context"] = "ContextCommand";
7
- filetypes["event"] = "Event";
8
- filetypes["inhibitor"] = "Inhibitor";
9
- })(filetypes || (filetypes = {}));
10
- export default function reload(client, type) {
11
- const files = [];
12
- if (type === 'message' || type === 'slash' || type === 'context') {
13
- for (const [name] of client.commands[type]) {
14
- files.push(client.commands[type].get(name).filepath);
2
+ import * as path from 'path';
3
+ import * as fs from 'fs';
4
+ import load from './load.js';
5
+ export default async function reload(client, type) {
6
+ switch (type) {
7
+ case 'message': {
8
+ client.commands.message.clear();
9
+ if (!client.modules.options.message)
10
+ return null;
11
+ const directory = path.resolve(client.modules.options.message?.directory);
12
+ for (const file of fs.readdirSync(directory)) {
13
+ load(client, `${directory}\\${file}`, 'MessageCommand');
14
+ }
15
+ return true;
15
16
  }
16
- client.commands[type].sweep(() => true);
17
- }
18
- if (type === 'event') {
19
- for (const [name] of client.events) {
20
- files.push(client.events.get(name).filepath);
17
+ case 'slash': {
18
+ return client.commands.slash.clear();
21
19
  }
22
- client.events.sweep(() => true);
23
- }
24
- if (type === 'inhibitor') {
25
- for (const [name] of client.inhibitors) {
26
- files.push(client.inhibitors.get(name).filepath);
20
+ case 'context': {
21
+ return client.commands.context.clear();
22
+ }
23
+ case 'events': {
24
+ return client.events.clear();
25
+ }
26
+ case 'inhibitors': {
27
+ return client.inhibitors.clear();
27
28
  }
28
- client.inhibitors.sweep(() => true);
29
29
  }
30
- return files.map(async (file) => {
31
- let filedata = new (await import(`file://${file}`)).default();
32
- filedata.filetype = filetypes[type];
33
- filedata.filepath = file;
34
- filedata.client = client;
35
- if (type === 'message' || type === 'slash' || type === 'context')
36
- client.commands[type].set(filedata.name, filedata);
37
- if (type === 'event')
38
- client.events.set(filedata.name, filedata);
39
- if (type === 'inhibitor')
40
- client.inhibitors.set(filedata.name, filedata);
41
- return filedata;
42
- });
43
30
  }
@@ -3,10 +3,11 @@ import XernerxClient from '../client/XernerxClient.js';
3
3
  import { ContextHandlerOptions, MessageHandlerOptions, SlashHandlerOptions } from '../types/interfaces.js';
4
4
  import Handler from './Handler.js';
5
5
  export default class CommandHandler extends Handler {
6
+ readonly readyTimestamp: number;
6
7
  constructor(client: XernerxClient);
7
8
  loadMessageCommands(options: MessageHandlerOptions): Promise<void>;
8
- loadSlashCommands(options: SlashHandlerOptions): void;
9
- loadContextCommands(options: ContextHandlerOptions): void;
9
+ loadSlashCommands(options: SlashHandlerOptions): Promise<void>;
10
+ loadContextCommands(options: ContextHandlerOptions): Promise<void>;
10
11
  private messageCommandRun;
11
12
  private slashCommandRun;
12
13
  private contextCommandRun;
@@ -14,8 +14,10 @@ import { Style } from 'dumfunctions';
14
14
  export default class CommandHandler extends Handler {
15
15
  constructor(client) {
16
16
  super(client);
17
+ this.readyTimestamp = Number(Date.now());
17
18
  }
18
19
  async loadMessageCommands(options) {
20
+ const commands = [];
19
21
  if (!this.client.options.intents.has(GatewayIntentBits.MessageContent))
20
22
  new XernerxLog(this.client).warn(`Message commands might not work as you're missing the intent MessageContent!`);
21
23
  if (!this.client.options.intents.has(GatewayIntentBits.GuildMessages))
@@ -45,8 +47,9 @@ export default class CommandHandler extends Handler {
45
47
  const filepath = `${path.resolve(options.directory)}\\${file}`;
46
48
  const command = await this.load(filepath, 'MessageCommand');
47
49
  this._checks(command);
50
+ commands.push(command.id);
48
51
  }
49
- new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Message Commands.`);
52
+ new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Message Commands: ${commands.map((command) => Style.log(command, { color: Style.TextColor.LightYellow })).join(', ')}`);
50
53
  this.emit({
51
54
  name: 'messageCreate',
52
55
  filetype: 'MessageCommand',
@@ -64,9 +67,10 @@ export default class CommandHandler extends Handler {
64
67
  });
65
68
  }
66
69
  // public reloadMessageCommands() {
67
- // return reload(this.client, 'message');
70
+ // return reload(this.client, 'message');
68
71
  // }
69
- loadSlashCommands(options) {
72
+ async loadSlashCommands(options) {
73
+ const commands = [];
70
74
  if (!this.client.settings.local)
71
75
  new XernerxLog(this.client).warn(`Slash commands might not work as you haven't specified a local guild ID.`);
72
76
  options = z
@@ -94,16 +98,18 @@ export default class CommandHandler extends Handler {
94
98
  const files = this.readdir(options.directory);
95
99
  for (const file of files) {
96
100
  const filepath = `${path.resolve(options.directory)}\\${file}`;
97
- this.load(filepath, 'SlashCommand');
101
+ const command = await this.load(filepath, 'SlashCommand');
102
+ commands.push(command.id);
98
103
  }
99
- new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Slash Commands.`);
104
+ new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Slash Commands: ${commands.map((command) => Style.log(command, { color: Style.TextColor.LightYellow })).join(', ')}`);
100
105
  this.emit({
101
106
  name: 'interactionCreate',
102
107
  filetype: 'SlashCommand',
103
108
  run: (interaction) => this.slashCommandRun(interaction),
104
109
  });
105
110
  }
106
- loadContextCommands(options) {
111
+ async loadContextCommands(options) {
112
+ const commands = [];
107
113
  if (!this.client.settings.local)
108
114
  new XernerxLog(this.client).warn(`Context commands might not work as you haven't specified a local guild ID.`);
109
115
  options = z
@@ -131,9 +137,10 @@ export default class CommandHandler extends Handler {
131
137
  const files = this.readdir(options.directory);
132
138
  for (const file of files) {
133
139
  const filepath = `${path.resolve(options.directory)}\\${file}`;
134
- this.load(filepath, 'ContextCommand');
140
+ const command = await this.load(filepath, 'ContextCommand');
141
+ commands.push(command.id);
135
142
  }
136
- new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Context Commands.`);
143
+ new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Context Commands: ${commands.map((command) => Style.log(command, { color: Style.TextColor.LightYellow })).join(', ')}`);
137
144
  this.emit({
138
145
  name: 'interactionCreate',
139
146
  filetype: 'ContextCommand',
@@ -231,12 +238,15 @@ export default class CommandHandler extends Handler {
231
238
  return;
232
239
  if (!cmd)
233
240
  return await this.client.emit('commandNotFound', message, commandName, filetype);
241
+ await this.client.emit('commandStart', message, cmd);
242
+ const args = await messageArguments(message, cmd, commandPrefix);
234
243
  message.util.parsed = {
235
244
  alias: commandAlias,
236
245
  prefix: commandPrefix,
246
+ args: args.args,
237
247
  };
238
- this.client.emit('commandStart', message, cmd, filetype);
239
- return await this.exec(cmd, message, await messageArguments(message, cmd, commandPrefix), filetype);
248
+ cmd.util = message.util;
249
+ return await this.exec(cmd, message, args, filetype);
240
250
  }
241
251
  }
242
252
  async slashCommandRun(interaction) {
@@ -260,8 +270,14 @@ export default class CommandHandler extends Handler {
260
270
  resolve(true);
261
271
  })
262
272
  .then(async () => {
263
- this.client.emit('commandStart', interaction, filetype);
264
- return await this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
273
+ await this.client.emit('commandStart', interaction);
274
+ const args = await interactionArguments(interaction, cmd);
275
+ interaction.util.parsed = {
276
+ alias: [interaction.commandName, args.group || '', args.subcommand || ''].join(' '),
277
+ args: args.args,
278
+ };
279
+ cmd.util = interaction.util;
280
+ return await this.exec(cmd, interaction, args, filetype);
265
281
  })
266
282
  .catch((error) => this.client.emit('commandError', interaction, error, cmd, filetype));
267
283
  }
@@ -276,8 +292,14 @@ export default class CommandHandler extends Handler {
276
292
  cmd = this.client.commands.context.get(interaction.commandName);
277
293
  if (!cmd)
278
294
  return this.client.emit('commandNotFound', interaction, interaction.commandName, filetype);
279
- this.client.emit('commandStart', interaction, filetype);
280
- return await this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
295
+ await this.client.emit('commandStart', interaction);
296
+ const args = await interactionArguments(interaction, cmd);
297
+ interaction.util.parsed = {
298
+ alias: interaction.commandName,
299
+ args: args,
300
+ };
301
+ cmd.util = interaction.util;
302
+ return await this.exec(cmd, interaction, args, filetype);
281
303
  }
282
304
  async exec(cmd, event, args, type) {
283
305
  try {
@@ -299,7 +321,7 @@ export default class CommandHandler extends Handler {
299
321
  return;
300
322
  await cmd.exec(event, args);
301
323
  await inhibitorValidation(event, args, cmd, 'post');
302
- return await this.client.emit('commandFinish', event, type);
324
+ return await this.client.emit('commandFinish', event, cmd);
303
325
  }
304
326
  catch (error) {
305
327
  new XernerxLog(this.client).error(`An error occurred executing ${Style.log(cmd.name, { color: Style.TextColor.Blue })}`, error);
@@ -3,6 +3,7 @@ import XernerxClient from '../client/XernerxClient.js';
3
3
  import { EventHandlerOptions } from '../types/interfaces.js';
4
4
  import Handler from './Handler.js';
5
5
  export default class EventHandler extends Handler {
6
+ readonly readyTimestamp: number;
6
7
  constructor(client: XernerxClient);
7
8
  loadEvents(options: EventHandlerOptions): Promise<void>;
8
9
  }
@@ -7,8 +7,10 @@ import { Style } from 'dumfunctions';
7
7
  export default class EventHandler extends Handler {
8
8
  constructor(client) {
9
9
  super(client);
10
+ this.readyTimestamp = Number(Date.now());
10
11
  }
11
12
  async loadEvents(options) {
13
+ const events = [];
12
14
  options = z
13
15
  .object({
14
16
  directory: z.string(),
@@ -18,9 +20,10 @@ export default class EventHandler extends Handler {
18
20
  const files = this.readdir(options.directory);
19
21
  for (const file of files) {
20
22
  const filepath = `${path.resolve(options.directory)}\\${file}`;
21
- const data = await this.load(filepath, 'Event');
22
- this.emit(data);
23
+ const event = await this.load(filepath, 'Event');
24
+ this.emit(event);
25
+ events.push(event.id);
23
26
  }
24
- new XernerxLog(this.client).info(`Loaded ${Style.log(String(this.client.events.size), { color: Style.TextColor.Cyan })} Events.`);
27
+ new XernerxLog(this.client).info(`Loaded ${Style.log(String(this.client.events.size), { color: Style.TextColor.Cyan })} Events: ${events.map((event) => Style.log(event, { color: Style.TextColor.LightYellow })).join(', ')}`);
25
28
  }
26
29
  }
@@ -3,6 +3,7 @@ import XernerxExtensionBuilder from 'xernerx-extension-builder';
3
3
  import XernerxClient from '../client/XernerxClient.js';
4
4
  import Handler from './Handler.js';
5
5
  export default class ExtensionHandler extends Handler {
6
+ readonly readyTimestamp: number;
6
7
  constructor(client: XernerxClient);
7
8
  loadExtensions(...extensions: Array<XernerxExtensionBuilder>): void;
8
9
  }
@@ -5,6 +5,7 @@ import { Style } from 'dumfunctions';
5
5
  export default class ExtensionHandler extends Handler {
6
6
  constructor(client) {
7
7
  super(client);
8
+ this.readyTimestamp = Number(Date.now());
8
9
  }
9
10
  loadExtensions(...extensions) {
10
11
  const active = extensions.map((extension) => {
@@ -17,9 +18,12 @@ export default class ExtensionHandler extends Handler {
17
18
  return extension.name;
18
19
  }
19
20
  catch (error) {
20
- return new XernerxLog(this.client).error(`An error occurred while loading ${Style.log(extension.name, { color: Style.TextColor.Blue })}`, error);
21
+ return new XernerxLog(this.client).error(`An error occurred while loading ${Style.log(extension.name, { color: Style.TextColor.Red })}`, error);
21
22
  }
22
23
  });
23
- new XernerxLog(this.client).info(`Loaded ${Style.log(String(extensions.length), { color: Style.TextColor.Cyan })} Extensions: ${active.filter((e) => e).join(', ')}`);
24
+ new XernerxLog(this.client).info(`Loaded ${Style.log(String(extensions.length), { color: Style.TextColor.Cyan })} Extensions: ${active
25
+ .filter((e) => e)
26
+ .map((event) => Style.log(event, { color: Style.TextColor.LightYellow }))
27
+ .join(', ')}`);
24
28
  }
25
29
  }
@@ -7,7 +7,6 @@ import { filetype } from '../types/types.js';
7
7
  export default class Handler {
8
8
  readonly client: XernerxClient;
9
9
  readonly files: Array<MessageCommandBuilder | XernerxSlashCommand | XernerxContextCommand>;
10
- readonly readyTimestamp: number;
11
10
  constructor(client: XernerxClient);
12
11
  readdir(dir: string): string[];
13
12
  load(filepath: string, type: filetype): Promise<any>;
@@ -5,11 +5,9 @@ import load from '../functions/load.js';
5
5
  export default class Handler {
6
6
  client;
7
7
  files;
8
- readyTimestamp;
9
8
  constructor(client) {
10
9
  this.client = client;
11
10
  this.files = [];
12
- this.readyTimestamp = Number(Date.now());
13
11
  }
14
12
  readdir(dir) {
15
13
  try {
@@ -3,6 +3,7 @@ import XernerxClient from '../client/XernerxClient.js';
3
3
  import Handler from './Handler.js';
4
4
  import { InhibitorHandlerOptions } from '../types/interfaces.js';
5
5
  export default class InhibitorHandler extends Handler {
6
+ readonly readyTimestamp: number;
6
7
  constructor(client: XernerxClient);
7
8
  loadInhibitors(options: InhibitorHandlerOptions): Promise<void>;
8
9
  }
@@ -7,8 +7,10 @@ import { Style } from 'dumfunctions';
7
7
  export default class InhibitorHandler extends Handler {
8
8
  constructor(client) {
9
9
  super(client);
10
+ this.readyTimestamp = Number(Date.now());
10
11
  }
11
12
  async loadInhibitors(options) {
13
+ const inhibitors = [];
12
14
  options = z
13
15
  .object({
14
16
  directory: z.string(),
@@ -18,9 +20,12 @@ export default class InhibitorHandler extends Handler {
18
20
  const files = this.readdir(options.directory);
19
21
  for (const file of files) {
20
22
  const filepath = `${path.resolve(options.directory)}\\${file}`;
21
- const data = await this.load(filepath, 'Inhibitor');
22
- this.emit(data);
23
+ const inhibitor = await this.load(filepath, 'Inhibitor');
24
+ this.emit(inhibitor);
25
+ inhibitors.push(inhibitor.id);
23
26
  }
24
- new XernerxLog(this.client).info(`Loaded ${Style.log(String(this.client.inhibitors.size), { color: Style.TextColor.Cyan })} Inhibitors.`);
27
+ new XernerxLog(this.client).info(`Loaded ${Style.log(String(this.client.inhibitors.size), { color: Style.TextColor.Cyan })} Inhibitors: ${inhibitors
28
+ .map((inhibitor) => Style.log(inhibitor, { color: Style.TextColor.LightYellow }))
29
+ .join(', ')}`);
25
30
  }
26
31
  }
@@ -2,6 +2,7 @@
2
2
  import XernerxClient from '../client/XernerxClient.js';
3
3
  import Handler from './Handler.js';
4
4
  export default class WebhookHandler extends Handler {
5
+ readonly readyTimestamp: number;
5
6
  constructor(client: XernerxClient);
6
7
  loadWebhooks(options: {
7
8
  token: string;
@@ -4,6 +4,7 @@ import Handler from './Handler.js';
4
4
  export default class WebhookHandler extends Handler {
5
5
  constructor(client) {
6
6
  super(client);
7
+ this.readyTimestamp = Number(Date.now());
7
8
  }
8
9
  async loadWebhooks(options) {
9
10
  this.client.once('ready', async (client) => {
@@ -1,12 +1,16 @@
1
1
  /** @format */
2
2
  import { EmbedBuilder, InteractionEditReplyOptions, InteractionReplyOptions, MessagePayload } from 'discord.js';
3
3
  import XernerxClient from '../client/XernerxClient.js';
4
- import { PaginatorOptions } from '../types/interfaces.js';
4
+ import { ContextCommandArguments, PaginatorOptions, SlashCommandArguments } from '../types/interfaces.js';
5
5
  import { XernerxInteraction } from '../types/types.js';
6
6
  import Util from './Util.js';
7
7
  import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
8
8
  export default class InteractionUtil extends Util {
9
- private interaction;
9
+ private readonly interaction;
10
+ parsed: {
11
+ alias: string | null;
12
+ args: (SlashCommandArguments | ContextCommandArguments<'message' | 'user'>) | null;
13
+ };
10
14
  constructor(client: XernerxClient, interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>);
11
15
  send(content: any): Promise<import("discord.js").Message<false> | import("discord.js").Message<true> | undefined>;
12
16
  reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions): Promise<import("discord.js").InteractionResponse<boolean> | import("discord.js").Message<boolean>>;
@@ -3,10 +3,13 @@ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder }
3
3
  import Util from './Util.js';
4
4
  import XernerxError from '../tools/XernerxError.js';
5
5
  export default class InteractionUtil extends Util {
6
- interaction;
7
6
  constructor(client, interaction) {
8
7
  super(client);
9
8
  this.interaction = interaction;
9
+ this.parsed = {
10
+ alias: null,
11
+ args: null,
12
+ };
10
13
  }
11
14
  async send(content) {
12
15
  if (!content)
@@ -7,8 +7,9 @@ import { PaginatorOptions } from '../main.js';
7
7
  export default class MessageUtil extends Util {
8
8
  private readonly message;
9
9
  parsed: {
10
- alias: null | string;
11
- prefix: null | string;
10
+ alias: string | null;
11
+ prefix: string | null;
12
+ args: Record<string, unknown> | null;
12
13
  };
13
14
  constructor(client: XernerxClient, message: XernerxMessage);
14
15
  send(content: any): Promise<import("discord.js").Message<boolean> | null>;
@@ -4,13 +4,13 @@ import Util from './Util.js';
4
4
  import sendWebhook from '../functions/sendWebhook.js';
5
5
  import XernerxError from '../tools/XernerxError.js';
6
6
  export default class MessageUtil extends Util {
7
- message;
8
7
  constructor(client, message) {
9
8
  super(client);
10
9
  this.message = message;
11
10
  this.parsed = {
12
11
  alias: null,
13
12
  prefix: null,
13
+ args: null,
14
14
  };
15
15
  }
16
16
  async send(content) {
@@ -89,25 +89,25 @@ export default async function commandValidation(event, command) {
89
89
  message: `\`${command.name}\` can't be used in a DM Channel`,
90
90
  }, command);
91
91
  if (userPermissions) {
92
- const missing = userPermissions.map(permission => (event.member?.permissions).has(toBigInt([permission])) ? null : permission).filter(x => x);
92
+ const missing = userPermissions.map((permission) => ((event.member?.permissions).has(toBigInt([permission])) ? null : permission)).filter((x) => x);
93
93
  const desired = (event.member?.permissions).has(toBigInt(userPermissions));
94
94
  if (!desired)
95
95
  return await emit(event, {
96
96
  reason: 'missingUserPermissions',
97
- message: `You are missing the following permissions to run \`${command.name}\`:\n${missing.map(permission => `> - ${permission}`).join('\n')}`,
97
+ message: `You are missing the following permissions to run \`${command.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
98
98
  required: userPermissions,
99
- missing
99
+ missing,
100
100
  }, command);
101
101
  }
102
102
  if (clientPermissions) {
103
- const missing = clientPermissions.map(permission => event.guild?.members.me?.permissions.has(toBigInt([permission])) ? null : permission).filter(x => x);
104
- const desired = (event.guild?.members.me?.permissions)?.has(toBigInt(clientPermissions));
103
+ const missing = clientPermissions.map((permission) => (event.guild?.members.me?.permissions.has(toBigInt([permission])) ? null : permission)).filter((x) => x);
104
+ const desired = event.guild?.members.me?.permissions?.has(toBigInt(clientPermissions));
105
105
  if (!desired)
106
106
  return await emit(event, {
107
107
  reason: 'missingClientPermissions',
108
- message: `I am missing the following permissions to run \`${command.name}\`:\n${missing.map(permission => `> - ${permission}`).join('\n')}`,
108
+ message: `I am missing the following permissions to run \`${command.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
109
109
  required: clientPermissions,
110
- missing
110
+ missing,
111
111
  }, command);
112
112
  }
113
113
  if ((!command.global || !client.settings.global) && client.settings.local !== event.guild?.id)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "4.7.1",
3
+ "version": "4.8.1",
4
4
  "description": "A bot framework for discord.js.",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",
@@ -1,43 +0,0 @@
1
- import { ContextMenuCommandBuilder } from 'discord.js';
2
- import XernerxClient from '../client/XernerxClient.js';
3
- import { XernerxMessageContextInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
4
- import { ContextCommandArguments, ContextCommandOptions } from '../types/interfaces.js';
5
- export default class ContextCommandBuilder {
6
- readonly id: string;
7
- readonly data: ContextMenuCommandBuilder;
8
- readonly name: string;
9
- readonly type: 'user' | 'message';
10
- readonly description: string | null | undefined;
11
- readonly usage: string | null | undefined;
12
- readonly info: string | null | undefined;
13
- readonly category: string | null | undefined;
14
- readonly cooldown: number | null | undefined;
15
- readonly ignore: {
16
- owner?: boolean | undefined;
17
- users?: string[] | undefined;
18
- channels?: string[] | undefined;
19
- guilds?: string[] | undefined;
20
- } | undefined;
21
- readonly strict: {
22
- owner?: boolean | undefined;
23
- users?: string[] | undefined;
24
- channels?: string[] | undefined;
25
- guilds?: string[] | undefined;
26
- } | undefined;
27
- readonly permissions: {
28
- user?: string[] | import("../main.js").PermissionNames[] | undefined;
29
- client?: string[] | import("../main.js").PermissionNames[] | undefined;
30
- dm?: boolean | undefined;
31
- } | undefined;
32
- readonly defer: {
33
- reply?: boolean | undefined;
34
- ephemeral?: boolean | undefined;
35
- fetchReply?: boolean | undefined;
36
- } | undefined;
37
- readonly fileType: 'ContextCommand';
38
- readonly filePath: string;
39
- readonly client: typeof XernerxClient;
40
- constructor(id: string, options: ContextCommandOptions);
41
- exec<T>(interaction: XernerxUserContextInteraction | XernerxMessageContextInteraction, args: ContextCommandArguments<'user' | 'message'>): Promise<void | any | T>;
42
- }
43
- //# sourceMappingURL=ContextCommandBuilder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContextCommandBuilder.d.ts","sourceRoot":"","sources":["../../src/build/ContextCommandBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAGvD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,gCAAgC,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAExF,MAAM,CAAC,OAAO,OAAO,qBAAqB;IACtC,SAAwB,EAAE,SAAC;IAC3B,SAAwB,IAAI,4BAAC;IAC7B,SAAwB,IAAI,SAAC;IAC7B,SAAwB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACjD,SAAwB,WAAW,4BAAC;IACpC,SAAwB,KAAK,4BAAC;IAC9B,SAAwB,IAAI,4BAAC;IAC7B,SAAwB,QAAQ,4BAAC;IACjC,SAAwB,QAAQ,4BAAC;IACjC,SAAwB,MAAM;;;;;kBAAC;IAC/B,SAAwB,MAAM;;;;;kBAAC;IAC/B,SAAwB,WAAW;;;;kBAAC;IACpC,SAAwB,KAAK;;;;kBAAC;IAC9B,SAAwB,QAAQ,EAAE,gBAAgB,CAAC;IACnD,SAAwB,QAAQ,EAAE,MAAM,CAAC;IACzC,SAAwB,MAAM,uBAAC;gBAEZ,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB;IAgFhD,IAAI,CAAC,CAAC,EAAE,WAAW,EAAE,6BAA6B,GAAG,gCAAgC,EAAE,IAAI,EAAE,uBAAuB,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC;CAClL"}