xernerx 4.15.3 → 4.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,6 +31,7 @@ export default class XernerxClient extends Client {
31
31
  ready: boolean;
32
32
  info: boolean;
33
33
  table: string[] | null;
34
+ config: string[] | null;
34
35
  } | undefined;
35
36
  cooldown?: {
36
37
  command: number;
@@ -44,6 +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
48
  })
48
49
  .or(z.boolean())
49
50
  .optional(),
@@ -9,6 +9,7 @@ export default class XernerxLog {
9
9
  private readonly warnLog;
10
10
  private readonly readyLog;
11
11
  private readonly tableLog;
12
+ private readonly config;
12
13
  private readonly time;
13
14
  private readonly ram;
14
15
  private shard;
@@ -1,5 +1,10 @@
1
1
  /** @format */
2
2
  import { Style } from 'dumfunctions';
3
+ import * as fs from 'fs';
4
+ import Discord from 'discord.js';
5
+ import { version } from '../main.js';
6
+ const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
7
+ let i = 0;
3
8
  export default class XernerxLog {
4
9
  constructor(client) {
5
10
  this.client = client;
@@ -14,15 +19,34 @@ export default class XernerxLog {
14
19
  this.warnLog = client.settings.log?.warn;
15
20
  this.readyLog = client.settings.log?.ready;
16
21
  this.tableLog = client.settings.log?.table;
22
+ this.config = client.settings.log?.config || ['ram', 'time'];
17
23
  }
18
- this.time = () => String(new Date()).split(/ +/)[4];
19
- this.ram = () => Math.round(process.memoryUsage().rss / 1000000);
20
- this.shard = '';
24
+ const config = {
25
+ name: this.blue(pkg.name),
26
+ node: this.green(process.version),
27
+ xernerx: this.cyan(version),
28
+ discordjs: this.cyan(Discord.version),
29
+ platform: this.green(process.platform),
30
+ time: () => this.cyan(new Date().toLocaleTimeString()),
31
+ date: () => this.cyan(new Date().toLocaleDateString()),
32
+ ram: () => `${this.cyan(Math.round(process.memoryUsage().rss / 1000000))}mb`,
33
+ version: this.cyan(pkg.version),
34
+ author: this.blue(pkg.author),
35
+ shard: this.cyan(''),
36
+ index: () => {
37
+ i++;
38
+ return i;
39
+ },
40
+ };
41
+ this.config;
21
42
  process.on('message', (message) => {
22
43
  if (message.type == 'xernerx')
23
- this.shard = message?.data?.sharded ? `| ${message?.data?.shardId} |` : '';
44
+ config.shard = message?.data?.sharded ? `| ${message?.data?.shardId} |` : '';
24
45
  });
25
- this.base = (type, message) => `${type == 'info' ? `✔️ | ${this.purple('Xernerx')}` : type == `error` ? `❗ | ${this.red('Xernerx')}` : type == `update` ? `⬆️ | ${this.blue('Xernerx')}` : `⚠️ | ${this.yellow('Xernerx')}`} | ${this.cyan(this.time())} | ${this.cyan(this.ram())}mb | ${this.client.stats?.shardCount > 1 ? `${this.cyan(this.client.stats.shardId)} | ` : ''}${message}`;
46
+ this.base = (type, message) => `${type == 'info' ? `✔️ | ${this.purple('Xernerx')}` : type == `error` ? `❗ | ${this.red('Xernerx')}` : type == `update` ? `⬆️ | ${this.blue('Xernerx')}` : `⚠️ | ${this.yellow('Xernerx')}`} | ${this.config
47
+ ?.map((c) => (typeof config[c] == 'function' ? config[c]() : config[c]) || null)
48
+ .filter((x) => x)
49
+ .join(' | ')} | ${message}`;
26
50
  }
27
51
  info(message, force = false) {
28
52
  return this.infoLog || force ? console.info(this.base('info', message)) : null;
@@ -35,6 +35,7 @@ export interface XernerxOptions {
35
35
  warn?: boolean;
36
36
  error?: boolean;
37
37
  table?: Array<'name' | 'aliases' | 'description' | 'filetype' | 'category'>;
38
+ config?: Array<'name' | 'node' | 'xernerx' | 'discordjs' | 'platform' | 'time' | 'date' | 'ram' | 'version' | 'author' | 'shard' | 'index'>;
38
39
  };
39
40
  cooldown?: {
40
41
  command?: number;
@@ -6,7 +6,7 @@ import { Style } from 'dumfunctions';
6
6
  export default class MessageUtil extends Util {
7
7
  constructor(client, message) {
8
8
  super(client);
9
- this.message = message;
9
+ this.message = message?.message || message;
10
10
  this.parsed = {
11
11
  alias: null,
12
12
  prefix: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "4.15.3",
3
+ "version": "4.16.0",
4
4
  "description": "A bot framework for discord.js.",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",