xernerx 4.17.1 → 4.17.3

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.
@@ -32,7 +32,7 @@ export default class XernerxClient<T = unknown> extends Client {
32
32
  ready: boolean;
33
33
  info: boolean;
34
34
  table: string[] | null;
35
- config: string[] | null;
35
+ format: string[] | null;
36
36
  } | undefined;
37
37
  cooldown?: {
38
38
  command: number;
@@ -44,7 +44,7 @@ export default class XernerxClient extends Client {
44
44
  warn: z.boolean().default(false),
45
45
  error: z.boolean().default(false),
46
46
  table: z.array(z.string()).or(z.null()).default(null),
47
- config: z.array(z.string()).or(z.null()).default(null),
47
+ format: z.array(z.string()).or(z.null()).default(null),
48
48
  })
49
49
  .or(z.boolean())
50
50
  .optional(),
@@ -89,7 +89,7 @@ export default class XernerxClient extends Client {
89
89
  };
90
90
  }
91
91
  async connect(token) {
92
- const login = this.login(token);
92
+ const login = this.login(token); // TODO add thing to catch and have better error message
93
93
  deploy(this);
94
94
  if (this.settings.ceaseless) {
95
95
  process.on('unhandledRejection', (error) => {
@@ -23,12 +23,12 @@ export default function deploy(client) {
23
23
  stats();
24
24
  client.commands.slash.map((command) => commands.push(command));
25
25
  client.commands.context.map((command) => commands.push(command));
26
- client.commands.slash.map((command) => commands.push(command));
26
+ client.commands.message.map((command) => commands.push(command));
27
27
  if (client.commands.slash.size)
28
28
  client.commands.slash.map((command) => (command.global ? globalCommands.push(command.data.toJSON()) : localCommands.push(command.data.toJSON())));
29
29
  if (client.commands.context.size)
30
30
  client.commands.context.map((command) => (command.global ? globalCommands.push(command.data.toJSON()) : localCommands.push(command.data.toJSON())));
31
- if (globalCommands.length <= 0 && localCommands.length <= 0)
31
+ if (!globalCommands.length && !localCommands.length && !client.commands.message.size)
32
32
  return;
33
33
  try {
34
34
  if (client.settings.global) {
@@ -42,7 +42,7 @@ export default class CommandHandler extends Handler {
42
42
  })
43
43
  .parse(options);
44
44
  this.client.modules.options.message = options;
45
- const files = this.readdir(options.directory);
45
+ const files = this.readdir(options.directory, 'MessageCommands');
46
46
  for (const file of files) {
47
47
  const filepath = `${path.resolve(options.directory)}\\${file}`;
48
48
  const command = await this.load(filepath, 'MessageCommand');
@@ -107,7 +107,7 @@ export default class CommandHandler extends Handler {
107
107
  })
108
108
  .parse(options);
109
109
  this.client.modules.options.slash = options;
110
- const files = this.readdir(options.directory);
110
+ const files = this.readdir(options.directory, 'SlashCommands');
111
111
  for (const file of files) {
112
112
  const filepath = `${path.resolve(options.directory)}\\${file}`;
113
113
  const command = await this.load(filepath, 'SlashCommand');
@@ -146,7 +146,7 @@ export default class CommandHandler extends Handler {
146
146
  })
147
147
  .parse(options);
148
148
  this.client.modules.options.context = options;
149
- const files = this.readdir(options.directory);
149
+ const files = this.readdir(options.directory, 'ContextCommands');
150
150
  for (const file of files) {
151
151
  const filepath = `${path.resolve(options.directory)}\\${file}`;
152
152
  const command = await this.load(filepath, 'ContextCommand');
@@ -17,7 +17,7 @@ export default class EventHandler extends Handler {
17
17
  })
18
18
  .parse(options);
19
19
  this.client.modules.options.events = options;
20
- const files = this.readdir(options.directory);
20
+ const files = this.readdir(options.directory, 'Events');
21
21
  for (const file of files) {
22
22
  const filepath = `${path.resolve(options.directory)}\\${file}`;
23
23
  const event = await this.load(filepath, 'Event');
@@ -9,7 +9,7 @@ export default class Handler {
9
9
  readonly client: XernerxClient<unknown>;
10
10
  readonly files: Array<MessageCommandBuilder | XernerxSlashCommand | XernerxContextCommand>;
11
11
  constructor(client: XernerxClient);
12
- readdir(dir: string): string[];
12
+ readdir(dir: string, type: string): string[];
13
13
  load(filepath: string, type: filetype): Promise<any>;
14
14
  /**
15
15
  * Emits a file that has been loaded into the handler.
@@ -2,6 +2,8 @@
2
2
  import * as fs from 'fs';
3
3
  import * as path from 'path';
4
4
  import load from '../functions/load.js';
5
+ import { Style } from '../main.js';
6
+ import XernerxLog from '../tools/XernerxLog.js';
5
7
  export default class Handler {
6
8
  client;
7
9
  files;
@@ -9,12 +11,12 @@ export default class Handler {
9
11
  this.client = client;
10
12
  this.files = [];
11
13
  }
12
- readdir(dir) {
14
+ readdir(dir, type) {
13
15
  try {
14
16
  return fs.readdirSync(path.resolve(dir)).filter((file) => file.endsWith('.js'));
15
17
  }
16
18
  catch (error) {
17
- console.error(error);
19
+ new XernerxLog(this.client).error(`Cannot load ${type.toLowerCase()}, there is no such directory ${Style.log(dir, { color: Style.BackgroundColor.Grey })}.`);
18
20
  }
19
21
  return [];
20
22
  }
@@ -17,7 +17,7 @@ export default class InhibitorHandler extends Handler {
17
17
  })
18
18
  .parse(options);
19
19
  this.client.modules.options.inhibitors = options;
20
- const files = this.readdir(options.directory);
20
+ const files = this.readdir(options.directory, 'Inhibitors');
21
21
  for (const file of files) {
22
22
  const filepath = `${path.resolve(options.directory)}\\${file}`;
23
23
  const inhibitor = await this.load(filepath, 'Inhibitor');
@@ -64,7 +64,7 @@ export default class XernerxLog {
64
64
  })} to update to the latest version.`));
65
65
  }
66
66
  error(message, error) {
67
- return this.errorLog ? console.error(this.base('error', message), error) : null;
67
+ return this.errorLog ? console.error(this.base('error', message), error || '') : null;
68
68
  }
69
69
  ready() {
70
70
  if (typeof this.client == 'boolean')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "4.17.1",
3
+ "version": "4.17.3",
4
4
  "description": "A bot framework for discord.js.",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",