xernerx 4.4.17 → 4.4.18

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.
Files changed (72) hide show
  1. package/dist/build/ContextCommandBuilder.d.ts +23 -31
  2. package/dist/build/ContextCommandBuilder.js +39 -39
  3. package/dist/build/EventBuilder.d.ts +1 -1
  4. package/dist/build/EventBuilder.js +2 -2
  5. package/dist/build/InhibitorBuilder.d.ts +2 -11
  6. package/dist/build/InhibitorBuilder.js +2 -2
  7. package/dist/build/MessageCommandBuilder.d.ts +20 -26
  8. package/dist/build/MessageCommandBuilder.js +34 -34
  9. package/dist/build/SlashCommandBuilder.d.ts +25 -39
  10. package/dist/build/SlashCommandBuilder.js +48 -48
  11. package/dist/client/XernerxClient.d.ts +22 -30
  12. package/dist/client/XernerxClient.js +33 -33
  13. package/dist/client/XernerxShardClient.d.ts +1 -1
  14. package/dist/client/XernerxShardClient.js +13 -15
  15. package/dist/functions/delay.d.ts +1 -1
  16. package/dist/functions/delay.js +1 -1
  17. package/dist/functions/deploy.d.ts +1 -1
  18. package/dist/functions/deploy.js +20 -15
  19. package/dist/functions/isOwner.d.ts +1 -1
  20. package/dist/functions/isOwner.js +1 -1
  21. package/dist/functions/isVoter.d.ts +1 -1
  22. package/dist/functions/isVoter.js +1 -1
  23. package/dist/functions/load.d.ts +1 -1
  24. package/dist/functions/load.js +3 -2
  25. package/dist/functions/reload.d.ts +1 -1
  26. package/dist/functions/reload.js +12 -9
  27. package/dist/functions/sendWebhook.d.ts +1 -1
  28. package/dist/functions/sendWebhook.js +3 -2
  29. package/dist/functions/setPresence.d.ts +2 -2
  30. package/dist/functions/setPresence.js +11 -12
  31. package/dist/functions/xernerxUser.d.ts +1 -1
  32. package/dist/functions/xernerxUser.js +1 -1
  33. package/dist/handlers/CommandHandler.d.ts +1 -1
  34. package/dist/handlers/CommandHandler.js +109 -86
  35. package/dist/handlers/CommandHandler.js.map +1 -1
  36. package/dist/handlers/EventHandler.d.ts +1 -1
  37. package/dist/handlers/EventHandler.js +3 -3
  38. package/dist/handlers/ExtensionHandler.d.ts +1 -1
  39. package/dist/handlers/ExtensionHandler.js +5 -3
  40. package/dist/handlers/Handler.d.ts +1 -1
  41. package/dist/handlers/Handler.js +16 -6
  42. package/dist/handlers/InhibitorHandler.d.ts +1 -1
  43. package/dist/handlers/InhibitorHandler.js +3 -3
  44. package/dist/handlers/WebhookHandler.d.ts +4 -2
  45. package/dist/handlers/WebhookHandler.js +6 -9
  46. package/dist/main.d.ts +22 -29
  47. package/dist/main.js +22 -29
  48. package/dist/models/Arguments.d.ts +2 -5
  49. package/dist/models/Arguments.js +63 -48
  50. package/dist/tools/XernerxError.d.ts +1 -1
  51. package/dist/tools/XernerxError.js +1 -1
  52. package/dist/tools/XernerxLog.d.ts +1 -1
  53. package/dist/tools/XernerxLog.js +2 -7
  54. package/dist/types/extenders.d.ts +9 -5
  55. package/dist/types/extenders.js +1 -1
  56. package/dist/types/interfaces.d.ts +6 -9
  57. package/dist/types/interfaces.js +1 -1
  58. package/dist/types/types.d.ts +7 -179
  59. package/dist/types/types.js +1 -1
  60. package/dist/utils/ClientUtil.d.ts +4 -4
  61. package/dist/utils/ClientUtil.js +14 -8
  62. package/dist/utils/InteractionUtil.d.ts +2 -2
  63. package/dist/utils/InteractionUtil.js +1 -1
  64. package/dist/utils/MessageUtil.d.ts +2 -2
  65. package/dist/utils/MessageUtil.js +9 -5
  66. package/dist/utils/Util.d.ts +1 -1
  67. package/dist/utils/Util.js +1 -1
  68. package/dist/validators/commandValidation.d.ts +2 -5
  69. package/dist/validators/commandValidation.js +29 -19
  70. package/dist/validators/inhibitorValidations.d.ts +3 -19
  71. package/dist/validators/inhibitorValidations.js +2 -2
  72. package/package.json +1 -1
@@ -8,24 +8,30 @@ export default class ClientUtil extends Util {
8
8
  return setPresence(this.client, options);
9
9
  }
10
10
  async resolveChannel(query) {
11
- if (typeof query == 'object') query = query.id;
11
+ if (typeof query == 'object')
12
+ query = query.id;
12
13
  try {
13
- let channel = this.client.channels.cache.find((channel) => (channel.name == query.toLowerCase() || channel.id == query.toLowerCase() ? channel : null)) || null;
14
- if (!channel) channel = (await this.client.channels.fetch(query)) || null;
14
+ let channel = this.client.channels.cache.find((channel) => channel.name == query.toLowerCase() || channel.id == query.toLowerCase() ? channel : null) || null;
15
+ if (!channel)
16
+ channel = (await this.client.channels.fetch(query)) || null;
15
17
  return channel;
16
- } catch {
18
+ }
19
+ catch {
17
20
  return null;
18
21
  }
19
22
  }
20
23
  async resolveGuild(query) {
21
- if (typeof query == 'object') query = query.id;
24
+ if (typeof query == 'object')
25
+ query = query.id;
22
26
  try {
23
27
  let guild = this.client.guilds.cache.find((guild) => guild.name.toLowerCase() == query.toLowerCase()) || null;
24
- if (!guild) guild = (await this.client.guilds.fetch(query)) || null;
28
+ if (!guild)
29
+ guild = (await this.client.guilds.fetch(query)) || null;
25
30
  return guild;
26
- } catch {
31
+ }
32
+ catch {
27
33
  return null;
28
34
  }
29
35
  }
30
36
  }
31
- //# sourceMappingURL=ClientUtil.js.map
37
+ //# sourceMappingURL=ClientUtil.js.map
@@ -6,7 +6,7 @@ import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserC
6
6
  export default class InteractionUtil extends Util {
7
7
  private interaction;
8
8
  constructor(client: XernerxClient, interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>);
9
- reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions): Promise<import('discord.js').Message<boolean> | import('discord.js').InteractionResponse<boolean>>;
9
+ reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions): Promise<import("discord.js").Message<boolean> | import("discord.js").InteractionResponse<boolean>>;
10
10
  delay(time: number): Promise<unknown>;
11
11
  }
12
- //# sourceMappingURL=InteractionUtil.d.ts.map
12
+ //# sourceMappingURL=InteractionUtil.d.ts.map
@@ -13,4 +13,4 @@ export default class InteractionUtil extends Util {
13
13
  return await delay(time);
14
14
  }
15
15
  }
16
- //# sourceMappingURL=InteractionUtil.js.map
16
+ //# sourceMappingURL=InteractionUtil.js.map
@@ -9,8 +9,8 @@ export default class MessageUtil extends Util {
9
9
  prefix: null | string;
10
10
  };
11
11
  constructor(client: XernerxClient, message: XernerxMessage);
12
- reply(content: string | MessagePayload | MessageReplyOptions | MessageEditOptions): Promise<import('discord.js').Message<boolean> | null>;
12
+ reply(content: string | MessagePayload | MessageReplyOptions | MessageEditOptions): Promise<import("discord.js").Message<boolean> | null>;
13
13
  webhookReply(content: MessagePayload, url?: URL, user?: User): Promise<void>;
14
14
  delay(time: number): Promise<unknown>;
15
15
  }
16
- //# sourceMappingURL=MessageUtil.d.ts.map
16
+ //# sourceMappingURL=MessageUtil.d.ts.map
@@ -16,7 +16,8 @@ export default class MessageUtil extends Util {
16
16
  async reply(content) {
17
17
  if (this.client.cache.messages.has(this.message.id)) {
18
18
  const id = this.client.cache.messages.get(this.message.id);
19
- if (!id) return null;
19
+ if (!id)
20
+ return null;
20
21
  const msg = await this.message.channel.messages.fetch(id);
21
22
  msg.edit(content);
22
23
  return msg;
@@ -26,7 +27,8 @@ export default class MessageUtil extends Util {
26
27
  return msg;
27
28
  }
28
29
  async webhookReply(content, url, user) {
29
- if (this.message.channel.type === ChannelType.DM) throw new XernerxError(`Can't use this method in DM Channels`);
30
+ if (this.message.channel.type === ChannelType.DM)
31
+ throw new XernerxError(`Can't use this method in DM Channels`);
30
32
  const channel = this.message.channel;
31
33
  let webhook;
32
34
  if (!url) {
@@ -35,13 +37,15 @@ export default class MessageUtil extends Util {
35
37
  avatar: user?.avatarURL() || this.client.user?.avatarURL(),
36
38
  });
37
39
  }
38
- if (!webhook) webhook = { url };
40
+ if (!webhook)
41
+ webhook = { url };
39
42
  await sendWebhook(webhook.url, content);
40
- if (!url) webhook.delete();
43
+ if (!url)
44
+ webhook.delete();
41
45
  return;
42
46
  }
43
47
  async delay(time) {
44
48
  return await delay(time);
45
49
  }
46
50
  }
47
- //# sourceMappingURL=MessageUtil.js.map
51
+ //# sourceMappingURL=MessageUtil.js.map
@@ -3,4 +3,4 @@ export default class Util {
3
3
  client: XernerxClient;
4
4
  constructor(client: XernerxClient);
5
5
  }
6
- //# sourceMappingURL=Util.d.ts.map
6
+ //# sourceMappingURL=Util.d.ts.map
@@ -4,4 +4,4 @@ export default class Util {
4
4
  this.client = client;
5
5
  }
6
6
  }
7
- //# sourceMappingURL=Util.js.map
7
+ //# sourceMappingURL=Util.js.map
@@ -3,8 +3,5 @@ import MessageCommandBuilder from '../build/MessageCommandBuilder.js';
3
3
  import SlashCommandBuilder from '../build/SlashCommandBuilder.js';
4
4
  import { XernerxMessage, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
5
5
  import { XernerxInteraction } from '../types/types.js';
6
- export default function commandValidation(
7
- event: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxUserContextInteraction> | XernerxMessage,
8
- command: MessageCommandBuilder | SlashCommandBuilder | ContextCommandBuilder
9
- ): Promise<boolean>;
10
- //# sourceMappingURL=commandValidation.d.ts.map
6
+ export default function commandValidation(event: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxUserContextInteraction> | XernerxMessage, command: MessageCommandBuilder | SlashCommandBuilder | ContextCommandBuilder): Promise<boolean>;
7
+ //# sourceMappingURL=commandValidation.d.ts.map
@@ -1,7 +1,8 @@
1
1
  import { ChannelType, PermissionFlagsBits } from 'discord.js';
2
2
  export default async function commandValidation(event, command) {
3
3
  const client = event.client;
4
- if (command.ignore?.owner && client.settings.ownerId.includes(event.user.id)) return false;
4
+ if (command.ignore?.owner && client.settings.ownerId.includes(event.user.id))
5
+ return false;
5
6
  if (!client.cache.cooldowns.has(`${event.user.id}-${command.name}`)) {
6
7
  client.cache.cooldowns.set(`${event.user.id}-${command.name}`, {
7
8
  id: event.user.id,
@@ -11,21 +12,31 @@ export default async function commandValidation(event, command) {
11
12
  setTimeout(() => {
12
13
  client.cache.cooldowns.delete(`${event.user.id}-${command.name}`);
13
14
  }, command.cooldown || 0);
14
- } else {
15
+ }
16
+ else {
15
17
  const user = client.cache.cooldowns.get(`${event.user.id}-${command.name}`);
16
18
  const time = (user?.createdTimestamp || 0) - Number(Date.now());
17
19
  return emit(event, `Command on cooldown, ${time}`);
18
20
  }
19
- if ((command.ignore?.channels?.length || 0) > 0 && command.ignore?.channels?.includes(event.channel?.id)) return true;
20
- if ((command.ignore?.guilds?.length || 0) > 0 && command.ignore?.guilds?.includes(event.guild?.id)) return true;
21
- if ((command.ignore?.users?.length || 0) > 0 && command.ignore?.users?.includes(event.user.id)) return true;
22
- if (command.strict?.owner && !client.settings.ownerId.includes(event.user.id)) return await emit(event, 'Command is a developer command');
23
- if ((command.strict?.channels?.length || 0) > 0 && !command.strict?.channels?.includes(event.channel?.id)) return await emit(event, 'Command cannot be ran in this channel');
24
- if ((command.strict?.guilds?.length || 0) > 0 && !command.strict?.guilds?.includes(event.guild?.id)) return await emit(event, 'Command cannot be ran in this guild');
25
- if ((command.strict?.users?.length || 0) > 0 && !command.strict?.users?.includes(event.user.id)) return await emit(event, 'Command cannot be ran by you');
26
- if (command.permissions?.dm == false && event.channel?.type === ChannelType.DM) return await emit(event, "Can't use in a DM Channel");
21
+ if ((command.ignore?.channels?.length || 0) > 0 && command.ignore?.channels?.includes(event.channel?.id))
22
+ return true;
23
+ if ((command.ignore?.guilds?.length || 0) > 0 && command.ignore?.guilds?.includes(event.guild?.id))
24
+ return true;
25
+ if ((command.ignore?.users?.length || 0) > 0 && command.ignore?.users?.includes(event.user.id))
26
+ return true;
27
+ if (command.strict?.owner && !client.settings.ownerId.includes(event.user.id))
28
+ return await emit(event, 'Command is a developer command');
29
+ if ((command.strict?.channels?.length || 0) > 0 && !command.strict?.channels?.includes(event.channel?.id))
30
+ return await emit(event, 'Command cannot be ran in this channel');
31
+ if ((command.strict?.guilds?.length || 0) > 0 && !command.strict?.guilds?.includes(event.guild?.id))
32
+ return await emit(event, 'Command cannot be ran in this guild');
33
+ if ((command.strict?.users?.length || 0) > 0 && !command.strict?.users?.includes(event.user.id))
34
+ return await emit(event, 'Command cannot be ran by you');
35
+ if (command.permissions?.dm == false && event.channel?.type === ChannelType.DM)
36
+ return await emit(event, "Can't use in a DM Channel");
27
37
  if (command.permissions?.user) {
28
- if (!(event.member?.permissions).has(toBigInt(command.permissions.user))) return await emit(event, 'Missing User Permissions');
38
+ if (!(event.member?.permissions).has(toBigInt(command.permissions.user)))
39
+ return await emit(event, 'Missing User Permissions');
29
40
  }
30
41
  return false;
31
42
  }
@@ -37,14 +48,13 @@ function toBigInt(permissions) {
37
48
  let bigIntPermissions = 0n;
38
49
  permissions.map((permission) => {
39
50
  permission =
40
- PermissionFlagsBits[
41
- permission
42
- .split(/ +/)
43
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
44
- .join('')
45
- ];
46
- if (typeof permission === 'bigint') bigIntPermissions += permission;
51
+ PermissionFlagsBits[permission
52
+ .split(/ +/)
53
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
54
+ .join('')];
55
+ if (typeof permission === 'bigint')
56
+ bigIntPermissions += permission;
47
57
  });
48
58
  return bigIntPermissions;
49
59
  }
50
- //# sourceMappingURL=commandValidation.js.map
60
+ //# sourceMappingURL=commandValidation.js.map
@@ -1,22 +1,6 @@
1
1
  import { ContextCommandBuilder, MessageCommandBuilder, SlashCommandBuilder } from '../main.js';
2
2
  import { XernerxMessage, XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
3
3
  import { InhibitorType, XernerxInteraction } from '../types/types.js';
4
- export declare function inhibitorValidation(
5
- event: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>,
6
- cmd?: ContextCommandBuilder | MessageCommandBuilder | SlashCommandBuilder
7
- ): Promise<boolean>;
8
- export declare function inhibitorArguments(
9
- event: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>,
10
- cmd: ContextCommandBuilder | MessageCommandBuilder | SlashCommandBuilder | null,
11
- type: InhibitorType
12
- ):
13
- | import('../main.js').XernerxUser
14
- | import('discord.js').Guild
15
- | import('discord.js').GuildMember
16
- | import('discord.js').TextBasedChannel
17
- | SlashCommandBuilder
18
- | ContextCommandBuilder
19
- | MessageCommandBuilder
20
- | import('../main.js').APIInteractionGuildMember
21
- | null;
22
- //# sourceMappingURL=inhibitorValidations.d.ts.map
4
+ export declare function inhibitorValidation(event: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, cmd?: ContextCommandBuilder | MessageCommandBuilder | SlashCommandBuilder): Promise<boolean>;
5
+ export declare function inhibitorArguments(event: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, cmd: ContextCommandBuilder | MessageCommandBuilder | SlashCommandBuilder | null, type: InhibitorType): import("../main.js").XernerxUser | import("discord.js").Guild | import("discord.js").GuildMember | import("discord.js").TextBasedChannel | SlashCommandBuilder | ContextCommandBuilder | MessageCommandBuilder | import("../main.js").APIInteractionGuildMember | null;
6
+ //# sourceMappingURL=inhibitorValidations.d.ts.map
@@ -2,7 +2,7 @@ export async function inhibitorValidation(event, cmd) {
2
2
  const client = event.client;
3
3
  const inhibits = [];
4
4
  for (const [name, inhibitor] of client.inhibitors) {
5
- if (Boolean(await inhibitor.check(event, await inhibitorArguments(event, cmd || null, inhibitor.type)))) {
5
+ if (Boolean(await inhibitor.check(event, (await inhibitorArguments(event, cmd || null, inhibitor.type))))) {
6
6
  inhibits.push(name);
7
7
  }
8
8
  }
@@ -32,4 +32,4 @@ export function inhibitorArguments(event, cmd, type) {
32
32
  return event.user;
33
33
  }
34
34
  }
35
- //# sourceMappingURL=inhibitorValidations.js.map
35
+ //# sourceMappingURL=inhibitorValidations.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "4.4.17",
3
+ "version": "4.4.18",
4
4
  "description": "A bot framework for discord.js.",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",