xernerx 4.15.4 → 4.17.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.
@@ -43,6 +43,7 @@ export default class XernerxContextCommand {
43
43
  readonly filepath: string;
44
44
  readonly client: XernerxClientType;
45
45
  util: InteractionUtil;
46
+ snowflake: string | null;
46
47
  constructor(id: string, options: ContextCommandOptions);
47
48
  /**
48
49
  * @description the execution of the command
@@ -34,12 +34,17 @@ export default class XernerxMessageCommand {
34
34
  } | undefined;
35
35
  readonly permissions: {
36
36
  user?: string[] | import("../main.js").PermissionNames[] | null | undefined;
37
- client?: string[] | import("../main.js").PermissionNames[] | null | undefined;
37
+ client?: string[] | import("../main.js").PermissionNames[] | null | undefined; /**
38
+ * @description Checks for conditions before running the command
39
+ * @param message - The message event emitted on this command
40
+ * @param options - The args and flags parsed on this command
41
+ */
38
42
  dm?: boolean | undefined;
39
43
  } | undefined;
40
44
  readonly filetype: 'MessageCommand';
41
45
  readonly filepath: string;
42
46
  readonly client: XernerxClientType;
47
+ snowflake: string | null;
43
48
  util: MessageUtil;
44
49
  constructor(id: string, options: MessageCommandOptions);
45
50
  /**
@@ -42,6 +42,7 @@ export default class XernerxSlashCommand {
42
42
  readonly filetype: 'SlashCommand';
43
43
  readonly filepath: string;
44
44
  readonly client: XernerxClientType;
45
+ snowflake: string | null;
45
46
  util: InteractionUtil;
46
47
  constructor(id: string, options: SlashCommandOptions);
47
48
  /**
@@ -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 format;
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;
@@ -7,6 +12,7 @@ export default class XernerxLog {
7
12
  this.errorLog = true;
8
13
  this.infoLog = true;
9
14
  this.warnLog = true;
15
+ this.format = ['ram', 'time'];
10
16
  }
11
17
  else {
12
18
  this.errorLog = client.settings.log?.error;
@@ -14,15 +20,33 @@ export default class XernerxLog {
14
20
  this.warnLog = client.settings.log?.warn;
15
21
  this.readyLog = client.settings.log?.ready;
16
22
  this.tableLog = client.settings.log?.table;
23
+ this.format = client.settings.log?.format || ['ram', 'time'];
17
24
  }
18
- this.time = () => String(new Date()).split(/ +/)[4];
19
- this.ram = () => Math.round(process.memoryUsage().rss / 1000000);
20
- this.shard = '';
25
+ const format = {
26
+ name: this.blue(pkg.name),
27
+ node: this.green(process.version),
28
+ xernerx: this.cyan(version),
29
+ discordjs: this.cyan(Discord.version),
30
+ platform: this.green(process.platform),
31
+ time: () => this.cyan(new Date().toLocaleTimeString()),
32
+ date: () => this.cyan(new Date().toLocaleDateString()),
33
+ ram: () => `${this.cyan(Math.round(process.memoryUsage().rss / 1000000))}mb`,
34
+ version: this.cyan(pkg.version),
35
+ author: this.blue(pkg.author),
36
+ shard: this.cyan(''),
37
+ index: () => {
38
+ i++;
39
+ return i;
40
+ },
41
+ };
21
42
  process.on('message', (message) => {
22
43
  if (message.type == 'xernerx')
23
- this.shard = message?.data?.sharded ? `| ${message?.data?.shardId} |` : '';
44
+ format.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.format
47
+ ?.map((c) => (typeof format[c] == 'function' ? format[c]() : format[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;
@@ -7,6 +7,7 @@ export default class XernerxText {
7
7
  role(role: string | Role): string;
8
8
  emoji(emoji: string | Emoji, animated?: boolean): string;
9
9
  member(member: string | XernerxMember): string;
10
+ command(id: string, name: string): string | null;
10
11
  timestamp(timestamp?: number | Date, format?: 't' | 'T' | 'd' | 'D' | 'f' | 'F' | 'R'): string;
11
12
  codeBlock(code: string, language: string): string;
12
13
  iCodeBlock(code: string): string;
@@ -25,6 +25,11 @@ export default class XernerxText {
25
25
  member = member.id;
26
26
  return `<@!${member}>`;
27
27
  }
28
+ command(id, name) {
29
+ if (typeof id !== 'string')
30
+ return null;
31
+ return `</${name}:${id}>`;
32
+ }
28
33
  timestamp(timestamp = Date.now(), format = 'R') {
29
34
  if (typeof timestamp == 'string')
30
35
  timestamp = Number(timestamp);
@@ -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
+ format?: Array<'name' | 'node' | 'xernerx' | 'discordjs' | 'platform' | 'time' | 'date' | 'ram' | 'version' | 'author' | 'shard' | 'index'>;
38
39
  };
39
40
  cooldown?: {
40
41
  command?: number;
@@ -11,7 +11,7 @@ export default class ClientUtil extends Util {
11
11
  constructor(client: XernerxClient);
12
12
  setPresence(options: PresenceOptions): import("discord.js").ClientPresence | undefined;
13
13
  private resolveCooldown;
14
- resolveCommand(options: ResolveCommandOptions): XernerxSlashCommand | XernerxContextCommand | XernerxMessageCommand | Collection<string, XernerxSlashCommand | XernerxContextCommand | XernerxMessageCommand>;
14
+ resolveCommand(options: ResolveCommandOptions): Promise<XernerxSlashCommand | XernerxContextCommand | XernerxMessageCommand | Collection<string, XernerxSlashCommand | XernerxContextCommand | XernerxMessageCommand>>;
15
15
  resolveChannel(query: string | Record<string, string>): Promise<import("discord.js").Channel | null>;
16
16
  resolveGuild(query: string | Record<string, string>): Promise<import("discord.js").Guild | null>;
17
17
  uptime(timestamp?: number | null): string;
@@ -11,7 +11,8 @@ export default class ClientUtil extends Util {
11
11
  }
12
12
  // @ts-ignore
13
13
  resolveCooldown() { }
14
- resolveCommand(options) {
14
+ async resolveCommand(options) {
15
+ const interCommands = await this.client.application?.commands.fetch();
15
16
  const commands = [], collection = new Collection();
16
17
  if (options?.type == 'MessageCommand' || !options?.type)
17
18
  commands.push(...this.client.commands.message);
@@ -19,7 +20,10 @@ export default class ClientUtil extends Util {
19
20
  commands.push(...this.client.commands.slash);
20
21
  if (options?.type == 'Interaction' || options?.type == 'ContextCommand' || !options?.type)
21
22
  commands.push(...this.client.commands.context);
22
- commands.map(([name, command]) => collection.set(name, command));
23
+ commands.map(([name, command]) => {
24
+ command.snowflake = interCommands?.find((cmd) => command.name === cmd.name)?.id || null;
25
+ collection.set(name, command);
26
+ });
23
27
  if (options?.name) {
24
28
  return collection.get(options.name) || null;
25
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "4.15.4",
3
+ "version": "4.17.0",
4
4
  "description": "A bot framework for discord.js.",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",