xernerx 4.16.0 → 4.17.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.
@@ -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
@@ -1,25 +1,21 @@
1
1
  /** @format */
2
2
  import { XernerxEventOptions } from '../types/interfaces.js';
3
- import { XernerxEventType } from '../types/types.js';
4
- import { XernerxClientType } from '../types/extenders.js';
3
+ import { XernerxClientEvents, XernerxClientType } from '../types/extenders.js';
4
+ import { Awaitable, RestEvents } from 'discord.js';
5
5
  /**
6
6
  * @description - The event builder for events.
7
7
  * @param {String} id - The unique ID of the event.
8
8
  * @param {EventOptions} options - The event options.
9
9
  */
10
- export default class XernerxEvent {
10
+ export default class XernerxEvent<Event extends keyof XernerxClientEvents> {
11
11
  readonly id: string;
12
- readonly name: XernerxEventType | string;
13
- readonly emitter?: 'client' | 'process' | string;
14
- readonly type?: 'discord' | string;
12
+ readonly name: Event | keyof RestEvents | string;
13
+ readonly emitter?: 'client' | 'process' | 'rest' | string;
14
+ readonly type?: 'discord' | 'node' | string;
15
15
  readonly once?: boolean;
16
16
  readonly filetype: 'Event';
17
17
  readonly filepath: string;
18
18
  readonly client: XernerxClientType;
19
19
  constructor(id: string, options: XernerxEventOptions);
20
- /**
21
- * @description run your custom event here.
22
- * @param any - there can be all kinds of parameters on events.
23
- */
24
- run(...args: any): Promise<any>;
20
+ run(...args: XernerxClientEvents[Event]): Promise<Awaitable<any>>;
25
21
  }
@@ -21,10 +21,6 @@ export default class XernerxEvent {
21
21
  this.once = options.once || false;
22
22
  this.client = this.client;
23
23
  }
24
- /**
25
- * @description run your custom event here.
26
- * @param any - there can be all kinds of parameters on events.
27
- */
28
24
  async run(...args) {
29
25
  return new XernerxLog(this.client).error(`${this.id} doesn't have a run rule.`);
30
26
  }
@@ -40,6 +40,7 @@ export default class XernerxMessageCommand {
40
40
  readonly filetype: 'MessageCommand';
41
41
  readonly filepath: string;
42
42
  readonly client: XernerxClientType;
43
+ snowflake: string | null;
43
44
  util: MessageUtil;
44
45
  constructor(id: string, options: MessageCommandOptions);
45
46
  /**
@@ -114,6 +114,6 @@ export default class XernerxMessageCommand {
114
114
  */
115
115
  async exec(message, { args, flags }) {
116
116
  new XernerxLog(this.client).error(`${this.id} doesn't have an execution rule.`);
117
- return await this.client.emit('commandError', message, `${this.id} doesn't have an execution rule.`, this, this.filetype);
117
+ return await this.client.emit('commandError', message, `${this.id} doesn't have an execution rule.`, this);
118
118
  }
119
119
  }
@@ -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
  /**
@@ -27,6 +27,7 @@ export default class XernerxSlashCommand {
27
27
  usage: z.string().or(z.null()).default(null),
28
28
  info: z.string().or(z.null()).default(null),
29
29
  category: z.string().or(z.null()).default(null),
30
+ cooldown: z.number().or(z.null()).default(null),
30
31
  number: z.number().or(z.null()).default(null),
31
32
  global: z.boolean().default(true),
32
33
  channel: z
@@ -137,7 +138,7 @@ export default class XernerxSlashCommand {
137
138
  */
138
139
  async exec(interaction, { args, subcommand, group }) {
139
140
  new XernerxLog(this.client).error(`${this.id} doesn't have an execution rule.`);
140
- return await this.client.emit('commandError', interaction, `${this.id} doesn't have an execution rule.`, this, this.filetype);
141
+ return await this.client.emit('commandError', interaction, `${this.id} doesn't have an execution rule.`, this);
141
142
  }
142
143
  addArguments(command, args) {
143
144
  for (const argument of args) {
@@ -1,11 +1,12 @@
1
1
  /** @format */
2
2
  import { Client, ClientOptions, Collection } from 'discord.js';
3
3
  import { XernerxOptions, ModuleOptions, XernerxCommands, XernerxCache } from '../types/interfaces.js';
4
+ import { XernerxClientEvents } from '../types/extenders.js';
4
5
  import ClientUtil from '../utils/ClientUtil.js';
5
6
  import XernerxInhibitor from '../build/XernerxInhibitor.js';
6
7
  import XernerxEvent from '../build/XernerxEvent.js';
7
8
  import Cooldowns from '../models/Cooldowns.js';
8
- export default class XernerxClient extends Client {
9
+ export default class XernerxClient<T = unknown> extends Client {
9
10
  readonly settings: {
10
11
  ownerId: (string | string[]) & (string | string[] | undefined);
11
12
  local: string;
@@ -39,9 +40,9 @@ export default class XernerxClient extends Client {
39
40
  collections: string[];
40
41
  } | undefined;
41
42
  };
42
- readonly config: {} | null;
43
+ readonly config: T;
43
44
  readonly commands: XernerxCommands;
44
- readonly events: Collection<string, XernerxEvent>;
45
+ readonly events: Collection<string, XernerxEvent<keyof XernerxClientEvents>>;
45
46
  readonly inhibitors: Collection<string, XernerxInhibitor>;
46
47
  readonly modules: ModuleOptions;
47
48
  readonly util: ClientUtil;
@@ -49,6 +50,6 @@ export default class XernerxClient extends Client {
49
50
  readonly cache: XernerxCache;
50
51
  readonly cooldowns: Cooldowns;
51
52
  readonly dbl: any;
52
- constructor(discordOptions: ClientOptions, xernerxOptions: XernerxOptions, config?: unknown);
53
+ constructor(discordOptions: ClientOptions, xernerxOptions: XernerxOptions, config?: T);
53
54
  connect(token: string): Promise<string>;
54
55
  }
@@ -57,7 +57,7 @@ export default class XernerxClient extends Client {
57
57
  .optional(),
58
58
  })
59
59
  .parse(xernerxOptions);
60
- this.config = config || null;
60
+ this.config = config;
61
61
  this.commands = {
62
62
  message: new Collection(),
63
63
  slash: new Collection(),
@@ -87,7 +87,6 @@ export default class XernerxClient extends Client {
87
87
  integrationHandler: new IntegrationHandler(this),
88
88
  extensionHandler: new ExtensionHandler(this),
89
89
  };
90
- return this;
91
90
  }
92
91
  async connect(token) {
93
92
  const login = this.login(token);
@@ -291,7 +291,7 @@ export default class CommandHandler extends Handler {
291
291
  cmd.util = interaction.util;
292
292
  return await this.exec(cmd, interaction, args, filetype);
293
293
  })
294
- .catch((error) => this.client.emit('commandError', interaction, error, cmd, filetype));
294
+ .catch((error) => this.client.emit('commandError', interaction, error, cmd));
295
295
  }
296
296
  async contextCommandRun(interaction) {
297
297
  const filetype = 'ContextCommand';
@@ -337,7 +337,7 @@ export default class CommandHandler extends Handler {
337
337
  }
338
338
  catch (error) {
339
339
  new XernerxLog(this.client).error(`An error occurred executing ${Style.log(cmd.name, { color: Style.TextColor.Blue })}`, error);
340
- return await this.client.emit('commandError', event, error, cmd, type);
340
+ return await this.client.emit('commandError', event, error, cmd);
341
341
  }
342
342
  }
343
343
  _checks(command) {
@@ -4,11 +4,20 @@ import MessageCommandBuilder from '../build/XernerxMessageCommand.js';
4
4
  import XernerxSlashCommand from '../build/XernerxSlashCommand.js';
5
5
  import XernerxContextCommand from '../build/XernerxContextCommand.js';
6
6
  import { filetype } from '../types/types.js';
7
+ import { XernerxClientEvents, XernerxEvent, XernerxInhibitor } from '../main.js';
7
8
  export default class Handler {
8
- readonly client: XernerxClient;
9
+ readonly client: XernerxClient<unknown>;
9
10
  readonly files: Array<MessageCommandBuilder | XernerxSlashCommand | XernerxContextCommand>;
10
11
  constructor(client: XernerxClient);
11
12
  readdir(dir: string): string[];
12
13
  load(filepath: string, type: filetype): Promise<any>;
13
- emit<T extends Record<string, string | boolean | Function | void>>(event: T): Promise<void>;
14
+ /**
15
+ * Emits a file that has been loaded into the handler.
16
+ * @param file - The file to emit.
17
+ */
18
+ emit<File extends {
19
+ name: string;
20
+ filetype: 'MessageCommand' | 'SlashCommand' | 'ContextCommand';
21
+ run: Function;
22
+ } | XernerxInhibitor | XernerxEvent<keyof XernerxClientEvents>>(file: File): Promise<void>;
14
23
  }
@@ -23,23 +23,32 @@ export default class Handler {
23
23
  this.files.push(file);
24
24
  return file;
25
25
  }
26
- async emit(event) {
27
- if (!event?.filetype)
26
+ /**
27
+ * Emits a file that has been loaded into the handler.
28
+ * @param file - The file to emit.
29
+ */
30
+ async emit(file) {
31
+ if (!file?.filetype)
28
32
  return;
29
- if (event.filetype === 'Event') {
30
- if (event.emitter === 'client')
31
- event.once
32
- ? this.client.once(event.name, (...args) => event.run(...args))
33
- : this.client.on(event.name, (...args) => event.run(...args));
34
- else if (event.emitter === 'process')
35
- event.once
36
- ? process.once(event.name, (...args) => event.run(...args))
37
- : process.on(event.name, (...args) => event.run(...args));
33
+ if (file.filetype === 'Inhibitor')
34
+ return;
35
+ if (file.filetype === 'Event' && file.emitter) {
36
+ if (file.emitter === 'client') {
37
+ this.client[file.once ? 'once' : 'on'](file.name, (...args) => file.run(...args));
38
+ }
39
+ else if (file.emitter === 'process') {
40
+ process[file.once ? 'once' : 'on'](file.name, (...args) => file.run(...args));
41
+ }
42
+ else if (file.emitter === 'rest') {
43
+ this.client.rest[file.once ? 'once' : 'on'](file.name, (...args) => file.run(...args));
44
+ }
45
+ else {
46
+ // @ts-expect-error
47
+ this.client[file.emitter][file.once ? 'once' : 'on'](file.name, (...args) => file.run(...args));
48
+ }
38
49
  }
39
- if (['MessageCommand', 'SlashCommand', 'ContextCommand'].includes(event.filetype)) {
40
- event.once
41
- ? this.client.once(event.name, (...args) => event.run(...args))
42
- : this.client.on(event.name, (...args) => event.run(...args));
50
+ else {
51
+ this.client.on(file.name, (...args) => file.run(...args));
43
52
  }
44
53
  }
45
54
  }
@@ -1,5 +1,6 @@
1
1
  /** @format */
2
+ import { GatewayIntentBits } from 'discord.js';
2
3
  export declare const XernerxIntents: {
3
- Default: string[];
4
- All: string[];
4
+ Default: GatewayIntentBits[];
5
+ All: GatewayIntentBits[];
5
6
  };
@@ -1,24 +1,26 @@
1
1
  /** @format */
2
+ import { GatewayIntentBits } from 'discord.js';
2
3
  export const XernerxIntents = {
3
4
  Default: [
4
- 'Guilds',
5
- 'GuildModeration',
6
- 'GuildBans',
7
- 'GuildEmojisAndStickers',
8
- 'GuildIntegrations',
9
- 'GuildWebhooks',
10
- 'GuildInvites',
11
- 'GuildVoiceStates',
12
- 'GuildMessages',
13
- 'GuildMessageReactions',
14
- 'GuildMessageTyping',
15
- 'DirectMessages',
16
- 'DirectMessageReactions',
17
- 'DirectMessageTyping',
18
- 'GuildScheduledEvents',
19
- 'AutoModerationConfiguration',
20
- 'AutoModerationExecution',
5
+ GatewayIntentBits.Guilds,
6
+ GatewayIntentBits.GuildModeration,
7
+ GatewayIntentBits.GuildBans,
8
+ GatewayIntentBits.GuildModeration,
9
+ GatewayIntentBits.GuildEmojisAndStickers,
10
+ GatewayIntentBits.GuildIntegrations,
11
+ GatewayIntentBits.GuildWebhooks,
12
+ GatewayIntentBits.GuildInvites,
13
+ GatewayIntentBits.GuildVoiceStates,
14
+ GatewayIntentBits.GuildMessages,
15
+ GatewayIntentBits.GuildMessageReactions,
16
+ GatewayIntentBits.GuildMessageTyping,
17
+ GatewayIntentBits.DirectMessages,
18
+ GatewayIntentBits.DirectMessageReactions,
19
+ GatewayIntentBits.DirectMessageTyping,
20
+ GatewayIntentBits.GuildScheduledEvents,
21
+ GatewayIntentBits.AutoModerationConfiguration,
22
+ GatewayIntentBits.AutoModerationExecution,
21
23
  ],
22
- All: [''],
24
+ All: [GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildPresences, GatewayIntentBits.MessageContent],
23
25
  };
24
- XernerxIntents.All = [...XernerxIntents.Default, 'GuildMembers', 'GuildPresences', 'MessageContent'];
26
+ XernerxIntents.All.push(...XernerxIntents.Default);
@@ -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);
@@ -1,5 +1,5 @@
1
1
  /** @format */
2
- import { ChatInputCommandInteraction, Collection, DMChannel, Guild, GuildChannel, GuildMember, Message, MessageContextMenuCommandInteraction, User, UserContextMenuCommandInteraction } from 'discord.js';
2
+ import { ChatInputCommandInteraction, Collection, DMChannel, Guild, GuildChannel, GuildMember, Message, MessageContextMenuCommandInteraction, User, UserContextMenuCommandInteraction, ClientEvents } from 'discord.js';
3
3
  import InteractionUtil from '../utils/InteractionUtil.js';
4
4
  import MessageUtil from '../utils/MessageUtil.js';
5
5
  import { ModuleOptions, XernerxCache, XernerxCommands } from '../types/interfaces.js';
@@ -7,6 +7,8 @@ import XernerxEvent from '../build/XernerxEvent.js';
7
7
  import XernerxInhibitor from '../build/XernerxInhibitor.js';
8
8
  import XernerxClient from '../client/XernerxClient.js';
9
9
  import ClientUtil from '../utils/ClientUtil.js';
10
+ import { XernerxContextCommand, XernerxMessageCommand, XernerxSlashCommand } from '../main.js';
11
+ import XernerxError from '../tools/XernerxError.js';
10
12
  export interface XernerxUser extends User {
11
13
  owner: boolean;
12
14
  voted: boolean | null;
@@ -40,7 +42,7 @@ export interface XernerxMessageContextInteraction extends MessageContextMenuComm
40
42
  }
41
43
  export interface XernerxClientType extends XernerxClient {
42
44
  commands: XernerxCommands;
43
- events: Collection<string, XernerxEvent>;
45
+ events: Collection<string, XernerxEvent<keyof XernerxClientEvents>>;
44
46
  inhibitors: Collection<string, XernerxInhibitor>;
45
47
  modules: ModuleOptions;
46
48
  util: ClientUtil;
@@ -58,4 +60,17 @@ export interface XernerxClientType extends XernerxClient {
58
60
  cache: XernerxCache;
59
61
  connect: () => Promise<string>;
60
62
  }
63
+ interface CommandBlockInfo {
64
+ reason: string;
65
+ message: string;
66
+ required: Array<string> | string;
67
+ missing: Array<string> | string;
68
+ }
69
+ export interface XernerxClientEvents extends ClientEvents {
70
+ commandBlock: [event: XernerxMessage | XernerxSlashInteraction, info: CommandBlockInfo, command: XernerxSlashCommand | XernerxMessageCommand | XernerxContextCommand];
71
+ commandError: [event: XernerxMessage | XernerxSlashInteraction, error: XernerxError, command: XernerxSlashCommand | XernerxMessageCommand | XernerxContextCommand];
72
+ commandStart: [event: XernerxMessage | XernerxSlashInteraction, command: XernerxSlashCommand | XernerxMessageCommand | XernerxContextCommand];
73
+ commandFinish: [event: XernerxMessage | XernerxSlashInteraction, command: XernerxSlashCommand | XernerxMessageCommand | XernerxContextCommand];
74
+ commandNotFound: [event: XernerxMessage | XernerxSlashInteraction, commandName: string, filetype: 'MessageCommand' | 'SlashCommand' | 'ContextCommand'];
75
+ }
61
76
  export {};
@@ -7,9 +7,9 @@ import IntegrationHandler from '../handlers/IntegrationHandler.js';
7
7
  import XernerxContextCommand from '../build/XernerxContextCommand.js';
8
8
  import MessageCommandBuilder from '../build/XernerxMessageCommand.js';
9
9
  import XernerxSlashCommand from '../build/XernerxSlashCommand.js';
10
- import { Locales, MessageCommandArgumentType, PermissionNames, SlashCommandArgumentType, XernerxEventType, InhibitorType } from './types.js';
10
+ import { Locales, MessageCommandArgumentType, PermissionNames, SlashCommandArgumentType, InhibitorType } from './types.js';
11
11
  import ExtensionHandler from '../handlers/ExtensionHandler.js';
12
- import { XernerxMessage, XernerxUser } from './extenders.js';
12
+ import { XernerxClientEvents, XernerxMessage, XernerxUser } from './extenders.js';
13
13
  export interface XernerxOptions {
14
14
  local: string;
15
15
  global?: boolean;
@@ -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;
@@ -223,7 +223,7 @@ export interface SlashCommandArguments<T = SlashCommandArgumentType> {
223
223
  group: string;
224
224
  }
225
225
  export interface XernerxEventOptions {
226
- name: XernerxEventType;
226
+ name: keyof XernerxClientEvents;
227
227
  emitter?: 'client' | 'process';
228
228
  type?: 'discord' | 'node';
229
229
  once?: boolean;
@@ -7,8 +7,6 @@ export type SlashCommandArgumentType = 'attachment' | 'boolean' | 'channel' | 'i
7
7
  export type SlashCommandOptionChoices = SlashCommandStringOption | SlashCommandNumberOption | SlashCommandIntegerOption;
8
8
  export type SlashCommandOption = SlashCommandOptionChoices | SlashCommandBooleanOption | SlashCommandUserOption | SlashCommandChannelOption | SlashCommandRoleOption | SlashCommandMentionableOption;
9
9
  export type MessageCommandArgumentType = 'string' | 'number' | 'boolean' | 'confirm' | 'channel' | 'guild' | 'integer' | 'mentionable' | 'role' | 'user' | 'message' | 'member' | 'list' | 'option' | 'rest';
10
- export type DiscordEventType = 'applicationCommandPermissionsUpdate' | 'autoModerationActionExecution' | 'autoModerationRuleCreate' | 'autoModerationRuleDelete' | 'autoModerationRuleUpdate' | 'ready' | 'guildCreate' | 'guildDelete' | 'guildUpdate' | 'guildUnavailable' | 'guildMemberAdd' | 'guildMemberRemove' | 'guildMemberUpdate' | 'guildMemberAvailable' | 'guildMembersChunk' | 'guildIntegrationsUpdate' | 'roleCreate' | 'roleDelete' | 'inviteCreate' | 'inviteDelete' | 'roleUpdate' | 'emojiCreate' | 'emojiDelete' | 'emojiUpdate' | 'guildBanAdd' | 'guildBanRemove' | 'channelCreate' | 'channelDelete' | 'channelUpdate' | 'channelPinsUpdate' | 'messageCreate' | 'messageDelete' | 'messageUpdate' | 'messageDeleteBulk' | 'messageReactionAdd' | 'messageReactionRemove' | 'messageReactionRemoveAll' | 'messageReactionRemoveEmoji' | 'threadCreate' | 'threadDelete' | 'threadUpdate' | 'threadListSync' | 'threadMemberUpdate' | 'threadMembersUpdate' | 'userUpdate' | 'presenceUpdate' | 'voiceServerUpdate' | 'voiceStateUpdate' | 'typingStart' | 'webhookUpdate' | 'interactionCreate' | 'error' | 'warn' | 'debug' | 'cacheSweep' | 'shardDisconnect' | 'shardError' | 'shardReconnecting' | 'shardReady' | 'shardResume' | 'invalidated' | 'raw' | 'stageInstanceCreate' | 'stageInstanceUpdate' | 'stageInstanceDelete' | 'stickerCreate' | 'stickerDelete' | 'stickerUpdate' | 'guildScheduledEventCreate' | 'guildScheduledEventUpdate' | 'guildScheduledEventDelete' | 'guildScheduledEventUserAdd' | 'guildScheduledEventUserRemove';
11
- export type XernerxEventType = DiscordEventType | 'webhookCreate' | 'webhookError' | 'commandBlock' | 'commandError' | 'commandStart' | 'commandFinish' | 'commandCooldown';
12
10
  export type XernerxInteraction<T extends XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction> = T extends XernerxSlashInteraction ? XernerxSlashInteraction : T extends XernerxUserContextInteraction ? XernerxUserContextInteraction : XernerxMessageContextInteraction;
13
11
  export type PermissionNames = 'create instant invite' | 'kick members' | 'ban members' | 'administrator' | 'manage channels' | 'manage guild' | 'add reactions' | 'view audit log' | 'priority speaker' | 'stream' | 'view channel' | 'send messages' | 'send tts messages' | 'manage messages' | 'embed links' | 'attach files' | 'read message history' | 'mention everyone' | 'use external emojis' | 'view guild insights' | 'connect' | 'speak' | 'mute members' | 'deafen members' | 'move members' | 'use vad' | 'change nickname' | 'manage nicknames' | 'manage roles' | 'manage webhooks' | 'manage emojis and stickers' | 'use application commands' | 'request to speak' | 'manage events' | 'manage threads' | 'create public threads' | 'create private threads' | 'use external stickers' | 'send messages in threads' | 'start embedded activities' | 'moderate members';
14
12
  export type InhibitorType = '*' | 'message' | 'interaction' | 'command' | 'channel' | 'user' | 'member' | 'guild' | 'contextCommand' | 'messageCommand' | 'slashCommand';
@@ -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
  }
@@ -2,7 +2,7 @@
2
2
  import XernerxClient from '../client/XernerxClient.js';
3
3
  import XernerxText from '../tools/XernerxText.js';
4
4
  export default class Util {
5
- readonly client: XernerxClient;
5
+ readonly client: XernerxClient<unknown>;
6
6
  readonly text: XernerxText;
7
7
  constructor(client: XernerxClient);
8
8
  delay(time: number): Promise<unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "4.16.0",
3
+ "version": "4.17.1",
4
4
  "description": "A bot framework for discord.js.",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",