xernerx 4.16.0 → 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
  /**
@@ -9,7 +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
+ private readonly format;
13
13
  private readonly time;
14
14
  private readonly ram;
15
15
  private shard;
@@ -12,6 +12,7 @@ export default class XernerxLog {
12
12
  this.errorLog = true;
13
13
  this.infoLog = true;
14
14
  this.warnLog = true;
15
+ this.format = ['ram', 'time'];
15
16
  }
16
17
  else {
17
18
  this.errorLog = client.settings.log?.error;
@@ -19,9 +20,9 @@ export default class XernerxLog {
19
20
  this.warnLog = client.settings.log?.warn;
20
21
  this.readyLog = client.settings.log?.ready;
21
22
  this.tableLog = client.settings.log?.table;
22
- this.config = client.settings.log?.config || ['ram', 'time'];
23
+ this.format = client.settings.log?.format || ['ram', 'time'];
23
24
  }
24
- const config = {
25
+ const format = {
25
26
  name: this.blue(pkg.name),
26
27
  node: this.green(process.version),
27
28
  xernerx: this.cyan(version),
@@ -38,13 +39,12 @@ export default class XernerxLog {
38
39
  return i;
39
40
  },
40
41
  };
41
- this.config;
42
42
  process.on('message', (message) => {
43
43
  if (message.type == 'xernerx')
44
- config.shard = message?.data?.sharded ? `| ${message?.data?.shardId} |` : '';
44
+ format.shard = message?.data?.sharded ? `| ${message?.data?.shardId} |` : '';
45
45
  });
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)
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
48
  .filter((x) => x)
49
49
  .join(' | ')} | ${message}`;
50
50
  }
@@ -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,7 +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
+ format?: Array<'name' | 'node' | 'xernerx' | 'discordjs' | 'platform' | 'time' | 'date' | 'ram' | 'version' | 'author' | 'shard' | 'index'>;
39
39
  };
40
40
  cooldown?: {
41
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.16.0",
3
+ "version": "4.17.0",
4
4
  "description": "A bot framework for discord.js.",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",