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
@@ -13,39 +13,39 @@ export default class XernerxClient extends Client {
13
13
  super(discordOptions);
14
14
  this.settings = z
15
15
  .object({
16
- local: z.string().or(z.undefined()).optional(),
17
- global: z.boolean().default(false).optional(),
18
- ownerId: z.string().or(z.array(z.string())).default([]),
19
- permissions: z
20
- .object({
21
- client: z.array(z.string()).default([]),
22
- user: z.array(z.string()).default([]),
23
- dm: z.boolean().default(false),
24
- })
25
- .optional(),
26
- ignore: z
27
- .object({
28
- owner: z.boolean().default(false),
29
- users: z.array(z.string()).default([]),
30
- channels: z.array(z.string()).default([]),
31
- guilds: z.array(z.string()).default([]),
32
- })
33
- .optional(),
34
- log: z
35
- .object({
36
- ready: z.boolean().default(false),
37
- info: z.boolean().default(false),
38
- error: z.boolean().default(false),
39
- table: z.array(z.string()).or(z.null()).default(null),
40
- })
41
- .optional(),
42
- cooldown: z
43
- .object({
44
- command: z.number().default(0),
45
- cache: z.number().default(0),
46
- })
47
- .optional(),
16
+ local: z.string().or(z.undefined()).optional(),
17
+ global: z.boolean().default(false).optional(),
18
+ ownerId: z.string().or(z.array(z.string())).default([]),
19
+ permissions: z
20
+ .object({
21
+ client: z.array(z.string()).default([]),
22
+ user: z.array(z.string()).default([]),
23
+ dm: z.boolean().default(false),
48
24
  })
25
+ .optional(),
26
+ ignore: z
27
+ .object({
28
+ owner: z.boolean().default(false),
29
+ users: z.array(z.string()).default([]),
30
+ channels: z.array(z.string()).default([]),
31
+ guilds: z.array(z.string()).default([]),
32
+ })
33
+ .optional(),
34
+ log: z
35
+ .object({
36
+ ready: z.boolean().default(false),
37
+ info: z.boolean().default(false),
38
+ error: z.boolean().default(false),
39
+ table: z.array(z.string()).or(z.null()).default(null),
40
+ })
41
+ .optional(),
42
+ cooldown: z
43
+ .object({
44
+ command: z.number().default(0),
45
+ cache: z.number().default(0),
46
+ })
47
+ .optional(),
48
+ })
49
49
  .parse(xernerxOptions);
50
50
  this.config = config || null;
51
51
  this.commands = {
@@ -82,4 +82,4 @@ export default class XernerxClient extends Client {
82
82
  new XernerxLog(this).ready();
83
83
  }
84
84
  }
85
- //# sourceMappingURL=XernerxClient.js.map
85
+ //# sourceMappingURL=XernerxClient.js.map
@@ -14,4 +14,4 @@ export default class XernerxShardClient extends ShardingManager {
14
14
  constructor(file: string, discordOptions: ShardingManagerOptions, xernerxOptions?: XernerxOptions);
15
15
  }
16
16
  export {};
17
- //# sourceMappingURL=XernerxShardClient.d.ts.map
17
+ //# sourceMappingURL=XernerxShardClient.d.ts.map
@@ -8,27 +8,25 @@ export default class XernerxShardClient extends ShardingManager {
8
8
  this.on('shardCreate', async (shard) => {
9
9
  shard
10
10
  .on('ready', async () => {
11
- const guilds = await shard.fetchClientValue('guilds.cache');
12
- const guildCount = guilds.length;
13
- const userCount = guilds.map((guild) => guild.memberCount).length ? guilds.map((guild) => guild.memberCount).reduce((a, b) => (a += b)) : 0;
14
- this.stats.guildCount += Number(guildCount);
15
- this.stats.userCount += Number(userCount);
16
- this.stats.shardCount++;
17
- this.user = await shard.fetchClientValue('user');
18
- await new XernerxLog({ settings: xernerxOptions }).info(`Launched shard ${shard.id} for ${this.user?.tag}!`);
19
- })
11
+ const guilds = (await shard.fetchClientValue('guilds.cache'));
12
+ const guildCount = guilds.length;
13
+ const userCount = guilds.map((guild) => guild.memberCount).length ? guilds.map((guild) => guild.memberCount).reduce((a, b) => (a += b)) : 0;
14
+ this.stats.guildCount += Number(guildCount);
15
+ this.stats.userCount += Number(userCount);
16
+ this.stats.shardCount++;
17
+ this.user = (await shard.fetchClientValue('user'));
18
+ await new XernerxLog({ settings: xernerxOptions }).info(`Launched shard ${shard.id} for ${this.user?.tag}!`);
19
+ })
20
20
  .on('error', (error) => {
21
- new XernerxLog({ settings: xernerxOptions }).info(`An error occurred in ${shard.id} for ${this.user?.tag}! ${error}`);
22
- });
21
+ new XernerxLog({ settings: xernerxOptions }).info(`An error occurred in ${shard.id} for ${this.user?.tag}! ${error}`);
22
+ });
23
23
  });
24
24
  const spawn = this.spawn();
25
25
  spawn.then(async (shards) => {
26
26
  const collector = setInterval(() => {
27
27
  const index = shards.size - 1;
28
28
  if (shards.get(index)?.ready) {
29
- new XernerxLog({ settings: xernerxOptions }).info(
30
- `Launched all ${this.stats.shardCount} shards for ${this.user?.tag}, watching ${this.stats.guildCount} guilds, and ${this.stats.userCount} users!`
31
- );
29
+ new XernerxLog({ settings: xernerxOptions }).info(`Launched all ${this.stats.shardCount} shards for ${this.user?.tag}, watching ${this.stats.guildCount} guilds, and ${this.stats.userCount} users!`);
32
30
  clearInterval(collector);
33
31
  }
34
32
  }, 1000);
@@ -39,4 +37,4 @@ export default class XernerxShardClient extends ShardingManager {
39
37
  };
40
38
  }
41
39
  }
42
- //# sourceMappingURL=XernerxShardClient.js.map
40
+ //# sourceMappingURL=XernerxShardClient.js.map
@@ -1,2 +1,2 @@
1
1
  export default function delay(time: number): Promise<unknown>;
2
- //# sourceMappingURL=delay.d.ts.map
2
+ //# sourceMappingURL=delay.d.ts.map
@@ -1,4 +1,4 @@
1
1
  export default async function delay(time) {
2
2
  return await new Promise((resolve) => setTimeout(resolve, time));
3
3
  }
4
- //# sourceMappingURL=delay.js.map
4
+ //# sourceMappingURL=delay.js.map
@@ -1,3 +1,3 @@
1
1
  import XernerxClient from '../client/XernerxClient.js';
2
2
  export default function deploy(client: XernerxClient): void;
3
- //# sourceMappingURL=deploy.d.ts.map
3
+ //# sourceMappingURL=deploy.d.ts.map
@@ -4,32 +4,37 @@ import XernerxError from '../tools/XernerxError.js';
4
4
  const commands = [];
5
5
  export default function deploy(client) {
6
6
  client.prependOnceListener('ready', (client) => {
7
- if (client.commands.slash.size) client.commands.slash.map((command) => commands.push(command.data.toJSON()));
8
- if (client.commands.context.size) client.commands.context.map((command) => commands.push(command.data.toJSON()));
9
- if (commands.length <= 0) return;
7
+ if (client.commands.slash.size)
8
+ client.commands.slash.map((command) => commands.push(command.data.toJSON()));
9
+ if (client.commands.context.size)
10
+ client.commands.context.map((command) => commands.push(command.data.toJSON()));
11
+ if (commands.length <= 0)
12
+ return;
10
13
  try {
11
14
  if (client.settings.global) {
12
15
  put(client, client.settings.global, commands);
13
16
  put(client, !client.settings.global, []);
14
- } else {
17
+ }
18
+ else {
15
19
  put(client, !client.settings.global, commands);
16
20
  put(client, client.settings.global, []);
17
21
  }
18
- } catch (error) {
22
+ }
23
+ catch (error) {
19
24
  new XernerxLog(client).error(`An error occurred while deploying the interaction commands!`, error);
20
- } finally {
21
- new XernerxLog(client).info(
22
- `Deployed ${[client.commands.message.size, client.commands.slash.size, client.commands.context.size].reduce((a, b) => (a += b))} Commands ${
23
- client.settings.global ? 'globally' : `locally in ${client.guilds.cache.get(client.settings.local).name}`
24
- }.`
25
- );
25
+ }
26
+ finally {
27
+ new XernerxLog(client).info(`Deployed ${[client.commands.message.size, client.commands.slash.size, client.commands.context.size].reduce((a, b) => (a += b))} Commands ${client.settings.global ? 'globally' : `locally in ${client.guilds.cache.get(client.settings.local).name}`}.`);
26
28
  }
27
29
  });
28
30
  }
29
31
  function put(client, global, body) {
30
32
  const rest = new REST({ version: GatewayVersion }).setToken(client.token);
31
- if (!global && !client.settings?.local) throw new XernerxError(`No guild ID provided as local guild!`);
32
- if (!global && client.settings?.local) rest.put(Routes.applicationGuildCommands(client.user?.id, client.settings.local), { body });
33
- else rest.put(Routes.applicationCommands(client.user?.id), { body });
33
+ if (!global && !client.settings?.local)
34
+ throw new XernerxError(`No guild ID provided as local guild!`);
35
+ if (!global && client.settings?.local)
36
+ rest.put(Routes.applicationGuildCommands(client.user?.id, client.settings.local), { body });
37
+ else
38
+ rest.put(Routes.applicationCommands(client.user?.id), { body });
34
39
  }
35
- //# sourceMappingURL=deploy.js.map
40
+ //# sourceMappingURL=deploy.js.map
@@ -1,4 +1,4 @@
1
1
  import XernerxClient from '../client/XernerxClient.js';
2
2
  import { XernerxUser } from '../types/extenders.js';
3
3
  export default function isOwner(user: Pick<XernerxUser, 'id'>, client: XernerxClient): boolean;
4
- //# sourceMappingURL=isOwner.d.ts.map
4
+ //# sourceMappingURL=isOwner.d.ts.map
@@ -1,4 +1,4 @@
1
1
  export default function isOwner(user, client) {
2
2
  return client.settings.ownerId.includes(user.id);
3
3
  }
4
- //# sourceMappingURL=isOwner.js.map
4
+ //# sourceMappingURL=isOwner.js.map
@@ -1,4 +1,4 @@
1
1
  import XernerxClient from '../client/XernerxClient.js';
2
2
  import { XernerxUser } from '../types/extenders.js';
3
3
  export default function isVoter(user: XernerxUser, client: XernerxClient, token: string, host: 'top.gg'): Promise<void>;
4
- //# sourceMappingURL=isVoter.d.ts.map
4
+ //# sourceMappingURL=isVoter.d.ts.map
@@ -3,4 +3,4 @@ export default async function isVoter(user, client, token, host) {
3
3
  const x = await hasVoted(user.id, client.user?.id, token, host);
4
4
  console.log(x);
5
5
  }
6
- //# sourceMappingURL=isVoter.js.map
6
+ //# sourceMappingURL=isVoter.js.map
@@ -1,4 +1,4 @@
1
1
  import XernerxClient from '../client/XernerxClient.js';
2
2
  import { FileType } from '../types/types.js';
3
3
  export default function load(client: XernerxClient, path: string, type: FileType): Promise<any>;
4
- //# sourceMappingURL=load.d.ts.map
4
+ //# sourceMappingURL=load.d.ts.map
@@ -7,7 +7,8 @@ export default async function load(client, path, type) {
7
7
  file.client = client;
8
8
  fileSave(client, file, type);
9
9
  return file;
10
- } catch (error) {
10
+ }
11
+ catch (error) {
11
12
  new XernerxLog(client).error(`Couldn't load ${type} ${path.match(/\w*\.js$/gim)?.at(0) || path}`, error);
12
13
  }
13
14
  }
@@ -30,4 +31,4 @@ function fileSave(client, file, type) {
30
31
  break;
31
32
  }
32
33
  }
33
- //# sourceMappingURL=load.js.map
34
+ //# sourceMappingURL=load.js.map
@@ -1,3 +1,3 @@
1
1
  import XernerxClient from '../client/XernerxClient.js';
2
2
  export default function reload(client: XernerxClient, type: 'message' | 'slash' | 'context' | 'event' | 'inhibitor'): Promise<any>[];
3
- //# sourceMappingURL=reload.d.ts.map
3
+ //# sourceMappingURL=reload.d.ts.map
@@ -1,10 +1,10 @@
1
1
  var FileTypes;
2
2
  (function (FileTypes) {
3
- FileTypes['message'] = 'MessageCommand';
4
- FileTypes['slash'] = 'SlashCommand';
5
- FileTypes['context'] = 'ContextCommand';
6
- FileTypes['event'] = 'Event';
7
- FileTypes['inhibitor'] = 'Inhibitor';
3
+ FileTypes["message"] = "MessageCommand";
4
+ FileTypes["slash"] = "SlashCommand";
5
+ FileTypes["context"] = "ContextCommand";
6
+ FileTypes["event"] = "Event";
7
+ FileTypes["inhibitor"] = "Inhibitor";
8
8
  })(FileTypes || (FileTypes = {}));
9
9
  export default function reload(client, type) {
10
10
  const files = [];
@@ -31,10 +31,13 @@ export default function reload(client, type) {
31
31
  filedata.fileType = FileTypes[type];
32
32
  filedata.filePath = file;
33
33
  filedata.client = client;
34
- if (type === 'message' || type === 'slash' || type === 'context') client.commands[type].set(filedata.name, filedata);
35
- if (type === 'event') client.events.set(filedata.name, filedata);
36
- if (type === 'inhibitor') client.inhibitors.set(filedata.name, filedata);
34
+ if (type === 'message' || type === 'slash' || type === 'context')
35
+ client.commands[type].set(filedata.name, filedata);
36
+ if (type === 'event')
37
+ client.events.set(filedata.name, filedata);
38
+ if (type === 'inhibitor')
39
+ client.inhibitors.set(filedata.name, filedata);
37
40
  return filedata;
38
41
  });
39
42
  }
40
- //# sourceMappingURL=reload.js.map
43
+ //# sourceMappingURL=reload.js.map
@@ -1,3 +1,3 @@
1
1
  import { MessagePayload } from 'discord.js';
2
2
  export default function sendWebhook(url: URL, body: MessagePayload): Promise<any>;
3
- //# sourceMappingURL=sendWebhook.d.ts.map
3
+ //# sourceMappingURL=sendWebhook.d.ts.map
@@ -6,8 +6,9 @@ export default async function sendWebhook(url, body) {
6
6
  },
7
7
  body: JSON.stringify(body),
8
8
  });
9
- if (response.status === 204) return true;
9
+ if (response.status === 204)
10
+ return true;
10
11
  const data = await response.json();
11
12
  return data;
12
13
  }
13
- //# sourceMappingURL=sendWebhook.js.map
14
+ //# sourceMappingURL=sendWebhook.js.map
@@ -1,4 +1,4 @@
1
1
  import XernerxClient from '../main.js';
2
2
  import { PresenceOptions } from '../types/interfaces.js';
3
- export default function setPresence(client: XernerxClient, options: PresenceOptions): import('discord.js').ClientPresence | undefined;
4
- //# sourceMappingURL=setPresence.d.ts.map
3
+ export default function setPresence(client: XernerxClient, options: PresenceOptions): import("discord.js").ClientPresence | undefined;
4
+ //# sourceMappingURL=setPresence.d.ts.map
@@ -1,15 +1,14 @@
1
1
  export default function setPresence(client, options) {
2
- const presence = () =>
3
- client.user?.setPresence({
4
- activities: [
5
- {
6
- name: options.text,
7
- type: options.type,
8
- url: options.url,
9
- },
10
- ],
11
- status: options.status,
12
- });
2
+ const presence = () => client.user?.setPresence({
3
+ activities: [
4
+ {
5
+ name: options.text,
6
+ type: options.type,
7
+ url: options.url,
8
+ },
9
+ ],
10
+ status: options.status,
11
+ });
13
12
  let response = presence();
14
13
  if (options.interval)
15
14
  setInterval(() => {
@@ -17,4 +16,4 @@ export default function setPresence(client, options) {
17
16
  }, options.interval);
18
17
  return response;
19
18
  }
20
- //# sourceMappingURL=setPresence.js.map
19
+ //# sourceMappingURL=setPresence.js.map
@@ -1,4 +1,4 @@
1
1
  import XernerxClient from '../client/XernerxClient.js';
2
2
  import { XernerxMessage, XernerxSlashInteraction, XernerxUser, XernerxUserContextInteraction } from '../types/extenders.js';
3
3
  export declare function xernerxUser(event: XernerxMessage | XernerxSlashInteraction | XernerxUserContextInteraction | XernerxUserContextInteraction, client: XernerxClient): Promise<XernerxUser>;
4
- //# sourceMappingURL=xernerxUser.d.ts.map
4
+ //# sourceMappingURL=xernerxUser.d.ts.map
@@ -6,4 +6,4 @@ export async function xernerxUser(event, client) {
6
6
  'voted' in user ? null : (user.voted = client.util.hasVoted ? await client.util.hasVoted(user.id) : null);
7
7
  return user;
8
8
  }
9
- //# sourceMappingURL=xernerxUser.js.map
9
+ //# sourceMappingURL=xernerxUser.js.map
@@ -11,4 +11,4 @@ export default class CommandHandler extends Handler {
11
11
  private contextCommandRun;
12
12
  private exec;
13
13
  }
14
- //# sourceMappingURL=CommandHandler.d.ts.map
14
+ //# sourceMappingURL=CommandHandler.d.ts.map