xernerx 4.17.4 → 4.17.6

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 (62) hide show
  1. package/dist/build/XernerxContextCommand.d.ts +75 -47
  2. package/dist/build/XernerxContextCommand.js +119 -115
  3. package/dist/build/XernerxEvent.d.ts +10 -10
  4. package/dist/build/XernerxEvent.js +17 -17
  5. package/dist/build/XernerxInhibitor.d.ts +39 -15
  6. package/dist/build/XernerxInhibitor.js +18 -18
  7. package/dist/build/XernerxMessageCommand.d.ts +78 -52
  8. package/dist/build/XernerxMessageCommand.js +118 -114
  9. package/dist/build/XernerxSlashCommand.d.ts +97 -63
  10. package/dist/build/XernerxSlashCommand.js +176 -172
  11. package/dist/client/XernerxClient.d.ts +61 -47
  12. package/dist/client/XernerxClient.js +92 -88
  13. package/dist/client/XernerxShardClient.d.ts +14 -14
  14. package/dist/client/XernerxShardClient.js +61 -47
  15. package/dist/functions/deploy.js +45 -52
  16. package/dist/functions/load.js +28 -29
  17. package/dist/functions/reload.js +23 -24
  18. package/dist/functions/setPresence.d.ts +1 -1
  19. package/dist/functions/setPresence.js +17 -16
  20. package/dist/functions/xernerxUser.js +5 -6
  21. package/dist/handlers/CommandHandler.d.ts +10 -10
  22. package/dist/handlers/CommandHandler.js +311 -336
  23. package/dist/handlers/EventHandler.d.ts +3 -3
  24. package/dist/handlers/EventHandler.js +48 -21
  25. package/dist/handlers/ExtensionHandler.d.ts +3 -3
  26. package/dist/handlers/ExtensionHandler.js +23 -23
  27. package/dist/handlers/Handler.d.ts +22 -14
  28. package/dist/handlers/Handler.js +46 -50
  29. package/dist/handlers/InhibitorHandler.d.ts +3 -3
  30. package/dist/handlers/InhibitorHandler.js +25 -23
  31. package/dist/handlers/IntegrationHandler.d.ts +6 -6
  32. package/dist/handlers/IntegrationHandler.js +20 -20
  33. package/dist/main.d.ts +28 -21
  34. package/dist/main.js +28 -21
  35. package/dist/models/Arguments.d.ts +4 -1
  36. package/dist/models/Arguments.js +134 -149
  37. package/dist/models/Cooldowns.d.ts +6 -6
  38. package/dist/models/Cooldowns.js +25 -29
  39. package/dist/tools/XernerxError.d.ts +4 -4
  40. package/dist/tools/XernerxError.js +8 -8
  41. package/dist/tools/XernerxIntents.d.ts +2 -2
  42. package/dist/tools/XernerxIntents.js +21 -21
  43. package/dist/tools/XernerxLog.d.ts +25 -23
  44. package/dist/tools/XernerxLog.js +139 -110
  45. package/dist/tools/XernerxText.d.ts +23 -23
  46. package/dist/tools/XernerxText.js +79 -89
  47. package/dist/types/extenders.d.ts +55 -47
  48. package/dist/types/interfaces.d.ts +195 -189
  49. package/dist/types/types.d.ts +104 -5
  50. package/dist/utils/ClientUtil.d.ts +12 -9
  51. package/dist/utils/ClientUtil.js +96 -79
  52. package/dist/utils/InteractionUtil.d.ts +13 -13
  53. package/dist/utils/InteractionUtil.js +148 -147
  54. package/dist/utils/MessageUtil.d.ts +14 -14
  55. package/dist/utils/MessageUtil.js +162 -161
  56. package/dist/utils/Util.d.ts +7 -4
  57. package/dist/utils/Util.js +7 -7
  58. package/dist/validators/commandValidation.d.ts +4 -1
  59. package/dist/validators/commandValidation.js +157 -114
  60. package/dist/validators/inhibitorValidations.d.ts +21 -2
  61. package/dist/validators/inhibitorValidations.js +39 -39
  62. package/package.json +6 -3
@@ -1,6 +1,7 @@
1
1
  /** @format */
2
2
  import { Client, Collection } from 'discord.js';
3
3
  import { z } from 'zod';
4
+ import * as clack from '@clack/prompts';
4
5
  import CommandHandler from '../handlers/CommandHandler.js';
5
6
  import EventHandler from '../handlers/EventHandler.js';
6
7
  import InhibitorHandler from '../handlers/InhibitorHandler.js';
@@ -11,92 +12,95 @@ import ExtensionHandler from '../handlers/ExtensionHandler.js';
11
12
  import deploy from '../functions/deploy.js';
12
13
  import Cooldowns from '../models/Cooldowns.js';
13
14
  export default class XernerxClient extends Client {
14
- constructor(discordOptions, xernerxOptions, config) {
15
- super(discordOptions);
16
- this.settings = z
17
- .object({
18
- local: z.string(),
19
- global: z.boolean().default(false).optional(),
20
- ownerId: z.string().or(z.array(z.string())).default([]),
21
- ceaseless: z.boolean().default(false),
22
- permissions: z
23
- .object({
24
- client: z.array(z.string()).or(z.null()).default(null),
25
- user: z.array(z.string()).or(z.null()).default(null),
26
- dm: z.boolean().default(false),
27
- })
28
- .optional(),
29
- ignore: z
30
- .object({
31
- owner: z.boolean().default(false),
32
- self: z.boolean().default(true),
33
- bots: z.boolean().default(true),
34
- system: z.boolean().default(true),
35
- users: z.array(z.string()).default([]),
36
- channels: z.array(z.string()).default([]),
37
- guilds: z.array(z.string()).default([]),
38
- })
39
- .optional(),
40
- log: z
41
- .object({
42
- ready: z.boolean().default(false),
43
- info: z.boolean().default(false),
44
- warn: z.boolean().default(false),
45
- error: z.boolean().default(false),
46
- table: z.array(z.string()).or(z.null()).default(null),
47
- format: z.array(z.string()).or(z.null()).default(null),
48
- })
49
- .or(z.boolean())
50
- .optional(),
51
- cooldown: z
52
- .object({
53
- command: z.number().default(0),
54
- cache: z.number().default(0),
55
- collections: z.array(z.string()).default(['commands']),
56
- })
57
- .optional(),
58
- })
59
- .parse(xernerxOptions);
60
- this.config = config;
61
- this.commands = {
62
- message: new Collection(),
63
- slash: new Collection(),
64
- context: new Collection(),
65
- };
66
- this.events = new Collection();
67
- this.inhibitors = new Collection();
68
- this.util = new ClientUtil(this);
69
- this.stats = {
70
- guildCount: this.guilds.cache.size,
71
- userCount: 0,
72
- shardId: 0,
73
- shardCount: this.options.shardCount || 1,
74
- voteCount: 0,
75
- };
76
- this.dbl = {};
77
- this.cache = {
78
- messages: new Collection(),
79
- cooldowns: new Collection(),
80
- };
81
- this.cooldowns = new Cooldowns(this, xernerxOptions.cooldown?.collections);
82
- this.modules = {
83
- options: {},
84
- commandHandler: new CommandHandler(this),
85
- eventHandler: new EventHandler(this),
86
- inhibitorHandler: new InhibitorHandler(this),
87
- integrationHandler: new IntegrationHandler(this),
88
- extensionHandler: new ExtensionHandler(this),
89
- };
90
- }
91
- async connect(token) {
92
- const login = this.login(token); // TODO add thing to catch and have better error message
93
- deploy(this);
94
- if (this.settings.ceaseless) {
95
- process.on('unhandledRejection', (error) => {
96
- new XernerxLog(this).error('An uncaught error happpened, this is triggered from the ceaseless setting.', error);
97
- });
98
- }
99
- new XernerxLog(this).ready();
100
- return login;
101
- }
15
+ constructor(discordOptions, xernerxOptions, config) {
16
+ super(discordOptions);
17
+ clack.intro('Xernerx');
18
+ this.settings = z
19
+ .object({
20
+ local: z.string(),
21
+ global: z.boolean().default(false).optional(),
22
+ debug: z.boolean().default(false).optional(),
23
+ ownerId: z.string().or(z.array(z.string())).default([]),
24
+ ceaseless: z.boolean().default(false),
25
+ permissions: z
26
+ .object({
27
+ client: z.array(z.string()).or(z.null()).default(null),
28
+ user: z.array(z.string()).or(z.null()).default(null),
29
+ dm: z.boolean().default(false),
30
+ })
31
+ .optional(),
32
+ ignore: z
33
+ .object({
34
+ owner: z.boolean().default(false),
35
+ self: z.boolean().default(true),
36
+ bots: z.boolean().default(true),
37
+ system: z.boolean().default(true),
38
+ users: z.array(z.string()).default([]),
39
+ channels: z.array(z.string()).default([]),
40
+ guilds: z.array(z.string()).default([]),
41
+ })
42
+ .optional(),
43
+ log: z
44
+ .object({
45
+ ready: z.boolean().default(false),
46
+ info: z.boolean().default(false),
47
+ warn: z.boolean().default(false),
48
+ error: z.boolean().default(false),
49
+ table: z.array(z.string()).or(z.null()).default(null),
50
+ format: z.array(z.string()).or(z.null()).default(null),
51
+ })
52
+ .or(z.boolean())
53
+ .optional(),
54
+ cooldown: z
55
+ .object({
56
+ command: z.number().default(0),
57
+ cache: z.number().default(0),
58
+ collections: z.array(z.string()).default(['commands']),
59
+ })
60
+ .optional(),
61
+ })
62
+ .parse(xernerxOptions);
63
+ this.config = config;
64
+ this.commands = {
65
+ message: new Collection(),
66
+ slash: new Collection(),
67
+ context: new Collection(),
68
+ };
69
+ this.events = new Collection();
70
+ this.inhibitors = new Collection();
71
+ this.util = new ClientUtil(this);
72
+ this.stats = {
73
+ guildCount: this.guilds.cache.size,
74
+ userCount: 0,
75
+ shardId: 0,
76
+ shardCount: this.options.shardCount || 1,
77
+ voteCount: 0,
78
+ };
79
+ this.dbl = {};
80
+ this.cache = {
81
+ messages: new Collection(),
82
+ cooldowns: new Collection(),
83
+ };
84
+ this.cooldowns = new Cooldowns(this, xernerxOptions.cooldown?.collections);
85
+ this.modules = {
86
+ options: {},
87
+ commandHandler: new CommandHandler(this),
88
+ eventHandler: new EventHandler(this),
89
+ inhibitorHandler: new InhibitorHandler(this),
90
+ integrationHandler: new IntegrationHandler(this),
91
+ extensionHandler: new ExtensionHandler(this),
92
+ };
93
+ }
94
+ async connect(token) {
95
+ if (this.settings.debug) new XernerxLog(this).debug(`Connecting to discord using token ${token}...`);
96
+ const login = await this.login(token).catch(() => {
97
+ new XernerxLog(this).error('An invalid token was provided. Please make sure to provide a valid Discord bot token.');
98
+ });
99
+ if (this.settings.debug) new XernerxLog(this).debug(`Connected to discord using token ${token}`);
100
+ deploy(this);
101
+ new XernerxLog(this).ready();
102
+ const spinner = clack.spinner();
103
+ spinner.start();
104
+ return login;
105
+ }
102
106
  }
@@ -1,21 +1,21 @@
1
1
  /** @format */
2
2
  import { ShardingManager, ShardingManagerOptions, ClientUser } from 'discord.js';
3
3
  interface XernerxOptions {
4
- log?: {
5
- info?: boolean;
6
- };
7
- timeout?: number;
4
+ log?: {
5
+ info?: boolean;
6
+ };
7
+ timeout?: number;
8
8
  }
9
9
  export default class XernerxShardClient extends ShardingManager {
10
- readonly stats: {
11
- guildCount: number;
12
- userCount: number;
13
- shardCount: number;
14
- voteCount: number;
15
- shards: {};
16
- };
17
- user: ClientUser | null;
18
- spawner: Promise<import("@discordjs/collection").Collection<number, import("discord.js").Shard>>;
19
- constructor(file: string, discordOptions: ShardingManagerOptions, xernerxOptions?: XernerxOptions, data?: unknown);
10
+ readonly stats: {
11
+ guildCount: number;
12
+ userCount: number;
13
+ shardCount: number;
14
+ voteCount: number;
15
+ shards: {};
16
+ };
17
+ user: ClientUser | null;
18
+ spawner: Promise<import('discord.js').Collection<number, import('discord.js').Shard>>;
19
+ constructor(file: string, discordOptions: ShardingManagerOptions, xernerxOptions?: XernerxOptions, data?: unknown);
20
20
  }
21
21
  export {};
@@ -3,51 +3,65 @@ import { ShardingManager } from 'discord.js';
3
3
  import { Style } from 'dumfunctions';
4
4
  import XernerxLog from '../tools/XernerxLog.js';
5
5
  export default class XernerxShardClient extends ShardingManager {
6
- constructor(file, discordOptions, xernerxOptions, data = {}) {
7
- super(file, discordOptions);
8
- this.stats = { guildCount: 0, userCount: 0, shardCount: 0, voteCount: 0, shards: {} };
9
- this.user = null;
10
- this.on('shardCreate', async (shard) => {
11
- shard
12
- .on('ready', async () => {
13
- await new Promise((resolve) => setTimeout(resolve, 250));
14
- const stats = (await shard.fetchClientValue('stats'));
15
- this.stats.shards[String(shard.id)] = stats;
16
- this.user = (await shard.fetchClientValue('user'));
17
- this.stats.guildCount += stats.guildCount;
18
- this.stats.userCount += stats.userCount;
19
- this.stats.shardCount++;
20
- this.stats.voteCount = stats.voteCount;
21
- shard.send({ type: 'xernerx', data: { shardId: shard.id, sharded: true } });
22
- shard.send({ type: 'client', data });
23
- await new XernerxLog({ settings: xernerxOptions }).info(`Launched shard ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} for ${Style.log(this.user?.tag, { color: Style.TextColor.Blue })}! ${xernerxOptions?.timeout ? `Automatically killing in ${Style.log(String(xernerxOptions.timeout), { color: Style.TextColor.Cyan })}ms.` : ''}`);
24
- })
25
- .on('error', (error) => {
26
- new XernerxLog({ settings: xernerxOptions }).info(`An error occurred in ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} for ${Style.log(String(this.user?.tag), { color: Style.TextColor.Blue })}! ${error}`);
27
- });
28
- if (xernerxOptions?.timeout)
29
- setTimeout(() => {
30
- new XernerxLog({ settings: xernerxOptions }).warn(`Automatically killing shard ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} on ${Style.log(String(shard.manager.user?.tag), {
31
- color: Style.TextColor.Blue,
32
- })}!`);
33
- shard.kill();
34
- }, xernerxOptions.timeout);
35
- });
36
- const spawn = this.spawn();
37
- this.spawner = spawn;
38
- spawn.then(async (shards) => {
39
- const collector = setInterval(() => {
40
- const index = shards.size - 1;
41
- if (shards.get(index)?.ready) {
42
- clearInterval(collector);
43
- new XernerxLog({ settings: xernerxOptions }).info(`All Shards launched for ${Style.log(String(this.user?.tag), {
44
- color: Style.TextColor.Blue,
45
- })} with a total of ${Style.log(String(this.stats.shardCount), { color: Style.TextColor.Cyan })} shard${this.stats.shardCount > 1 ? 's' : ''}, watching ${Style.log(String(this.stats.guildCount), {
46
- color: Style.TextColor.Cyan,
47
- })} guild${this.stats.guildCount > 1 ? 's' : ''}, and ${Style.log(String(this.stats.userCount), { color: Style.TextColor.Cyan })} user${this.stats.userCount > 1 ? 's' : ''}!`);
48
- }
49
- }, 1000);
50
- });
51
- return this;
52
- }
6
+ constructor(file, discordOptions, xernerxOptions, data = {}) {
7
+ super(file, discordOptions);
8
+ this.stats = { guildCount: 0, userCount: 0, shardCount: 0, voteCount: 0, shards: {} };
9
+ this.user = null;
10
+ new XernerxLog(true).info('Starting sharding process...');
11
+ this.on('shardCreate', async (shard) => {
12
+ shard
13
+ .on('ready', async () => {
14
+ await new Promise((resolve) => setTimeout(resolve, 250));
15
+ const stats = await shard.fetchClientValue('stats');
16
+ this.stats.shards[String(shard.id)] = stats;
17
+ this.user = await shard.fetchClientValue('user');
18
+ this.stats.guildCount += stats.guildCount;
19
+ this.stats.userCount += stats.userCount;
20
+ this.stats.shardCount++;
21
+ this.stats.voteCount = stats.voteCount;
22
+ shard.send({ type: 'xernerx', data: { shardId: shard.id, sharded: true } });
23
+ shard.send({ type: 'client', data });
24
+ new XernerxLog({ settings: xernerxOptions }).info(
25
+ `Launched shard ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} for ${Style.log(this.user?.tag, { color: Style.TextColor.Blue })}! ${
26
+ xernerxOptions?.timeout ? `Automatically killing in ${Style.log(String(xernerxOptions.timeout), { color: Style.TextColor.Cyan })}ms.` : ''
27
+ }`
28
+ );
29
+ })
30
+ .on('error', (error) => {
31
+ new XernerxLog({ settings: xernerxOptions }).info(
32
+ `An error occurred in ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} for ${Style.log(String(this.user?.tag), { color: Style.TextColor.Blue })}! ${error}`
33
+ );
34
+ });
35
+ if (xernerxOptions?.timeout)
36
+ setTimeout(() => {
37
+ new XernerxLog({ settings: xernerxOptions }).warn(
38
+ `Automatically killing shard ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} on ${Style.log(String(shard.manager.user?.tag), {
39
+ color: Style.TextColor.Blue,
40
+ })}!`
41
+ );
42
+ shard.kill();
43
+ }, xernerxOptions.timeout);
44
+ });
45
+ const spawn = this.spawn();
46
+ this.spawner = spawn;
47
+ spawn.then(async (shards) => {
48
+ const collector = setInterval(() => {
49
+ const index = shards.size - 1;
50
+ if (shards.get(index)?.ready) {
51
+ clearInterval(collector);
52
+ new XernerxLog({ settings: xernerxOptions }).info(
53
+ `All Shards launched for ${Style.log(String(this.user?.tag), {
54
+ color: Style.TextColor.Blue,
55
+ })} with a total of ${Style.log(String(this.stats.shardCount), { color: Style.TextColor.Cyan })} shard${this.stats.shardCount > 1 ? 's' : ''}, watching ${Style.log(
56
+ String(this.stats.guildCount),
57
+ {
58
+ color: Style.TextColor.Cyan,
59
+ }
60
+ )} guild${this.stats.guildCount > 1 ? 's' : ''}, and ${Style.log(String(this.stats.userCount), { color: Style.TextColor.Cyan })} user${this.stats.userCount > 1 ? 's' : ''}!`
61
+ );
62
+ }
63
+ }, 1000);
64
+ });
65
+ return this;
66
+ }
53
67
  }
@@ -6,58 +6,51 @@ import XernerxError from '../tools/XernerxError.js';
6
6
  const globalCommands = [];
7
7
  const localCommands = [];
8
8
  export default function deploy(client) {
9
- const commands = [];
10
- function stats() {
11
- client.stats.guildCount = client.guilds.cache.size;
12
- client.stats.userCount = client.guilds.cache.map((g) => g.memberCount || g.approximateMemberCount || 0).reduce((a, b) => (a += b), 0);
13
- }
14
- process.on('message', (message) => {
15
- if (message.type == 'xernerx')
16
- client.stats.shardId = message?.data?.shardId;
17
- if (message.type == 'client')
18
- client.data = message.data;
19
- });
20
- client.on('messageCreate', stats);
21
- client.on('interactionCreate', stats);
22
- client.prependOnceListener('ready', (client) => {
23
- stats();
24
- client.commands.slash.map((command) => commands.push(command));
25
- client.commands.context.map((command) => commands.push(command));
26
- client.commands.message.map((command) => commands.push(command));
27
- if (client.commands.slash.size)
28
- client.commands.slash.map((command) => (command.global ? globalCommands.push(command.data.toJSON()) : localCommands.push(command.data.toJSON())));
29
- if (client.commands.context.size)
30
- client.commands.context.map((command) => (command.global ? globalCommands.push(command.data.toJSON()) : localCommands.push(command.data.toJSON())));
31
- if (!globalCommands.length && !localCommands.length && !client.commands.message.size)
32
- return;
33
- try {
34
- if (client.settings.global) {
35
- put(client, client.settings.global, globalCommands);
36
- put(client, !client.settings.global, localCommands);
37
- }
38
- else {
39
- put(client, !client.settings.global, [...globalCommands, ...localCommands]);
40
- put(client, client.settings.global, []);
41
- }
42
- }
43
- catch (error) {
44
- new XernerxLog(client).error(`An error occurred while deploying the commands!`, error);
45
- }
46
- finally {
47
- new XernerxLog(client).info(`Deployed ${Style.log(String(commands.filter((command) => command.global).length), {
48
- color: Style.TextColor.Cyan,
49
- })} Commands ${client.settings.global
50
- ? Style.log('globally', { color: Style.TextColor.Green })
51
- : `${Style.log('locally', { color: Style.TextColor.Red })} in ${Style.log(client.guilds.cache.get(client.settings.local)?.name, { color: Style.TextColor.Blue })}`}.`);
52
- }
53
- });
9
+ const commands = [];
10
+ function stats() {
11
+ client.stats.guildCount = client.guilds.cache.size;
12
+ client.stats.userCount = client.guilds.cache.map((g) => g.memberCount || g.approximateMemberCount || 0).reduce((a, b) => (a += b), 0);
13
+ }
14
+ process.on('message', (message) => {
15
+ if (message.type == 'xernerx') client.stats.shardId = message?.data?.shardId;
16
+ if (message.type == 'client') client.data = message.data;
17
+ });
18
+ client.on('messageCreate', stats);
19
+ client.on('interactionCreate', stats);
20
+ client.once('ready', (client) => {
21
+ stats();
22
+ client.commands.slash.map((command) => commands.push(command));
23
+ client.commands.context.map((command) => commands.push(command));
24
+ client.commands.message.map((command) => commands.push(command));
25
+ if (client.commands.slash.size) client.commands.slash.map((command) => (command.global ? globalCommands.push(command.data.toJSON()) : localCommands.push(command.data.toJSON())));
26
+ if (client.commands.context.size) client.commands.context.map((command) => (command.global ? globalCommands.push(command.data.toJSON()) : localCommands.push(command.data.toJSON())));
27
+ if (!globalCommands.length && !localCommands.length && !client.commands.message.size) return;
28
+ try {
29
+ if (client.settings.global) {
30
+ put(client, client.settings.global, globalCommands);
31
+ put(client, !client.settings.global, localCommands);
32
+ } else {
33
+ put(client, !client.settings.global, [...globalCommands, ...localCommands]);
34
+ put(client, client.settings.global, []);
35
+ }
36
+ } catch (error) {
37
+ new XernerxLog(client).error(`An error occurred while deploying the commands!`, error);
38
+ } finally {
39
+ new XernerxLog(client).info(
40
+ `Deployed ${Style.log(String(commands.filter((command) => command.global).length), {
41
+ color: Style.TextColor.Cyan,
42
+ })} Commands ${
43
+ client.settings.global
44
+ ? Style.log('globally', { color: Style.TextColor.Green })
45
+ : `${Style.log('locally', { color: Style.TextColor.Red })} in ${Style.log(client.guilds.cache.get(client.settings.local)?.name, { color: Style.TextColor.Blue })}`
46
+ }.`
47
+ );
48
+ }
49
+ });
54
50
  }
55
51
  function put(client, global, body) {
56
- const rest = new REST({ version: GatewayVersion }).setToken(client.token);
57
- if (!global && !client.settings?.local)
58
- throw new XernerxError(`No guild ID provided as local guild!`);
59
- if (!global && client.settings?.local)
60
- return rest.put(Routes.applicationGuildCommands(client.user?.id, client.settings.local), { body });
61
- else
62
- return rest.put(Routes.applicationCommands(client.user?.id), { body });
52
+ const rest = new REST({ version: GatewayVersion }).setToken(client.token);
53
+ if (!global && !client.settings?.local) throw new XernerxError(`No guild ID provided as local guild!`);
54
+ if (!global && client.settings?.local) return rest.put(Routes.applicationGuildCommands(client.user?.id, client.settings.local), { body });
55
+ else return rest.put(Routes.applicationCommands(client.user?.id), { body });
63
56
  }
@@ -1,35 +1,34 @@
1
1
  /** @format */
2
2
  import XernerxLog from '../tools/XernerxLog.js';
3
3
  export default async function load(client, path, type) {
4
- try {
5
- let file = new (await import(`file://${path}`)).default();
6
- file.filetype = type;
7
- file.filepath = path;
8
- file.client = client;
9
- file.util = {};
10
- fileSave(client, file, type);
11
- return file;
12
- }
13
- catch (error) {
14
- new XernerxLog(client).error(`Couldn't load ${type} ${path.match(/\w*\.js$/gim)?.at(0) || path}`, error);
15
- }
4
+ try {
5
+ let file = new (await import(`file://${path}`)).default();
6
+ file.filetype = type;
7
+ file.filepath = path;
8
+ file.client = client;
9
+ file.util = {};
10
+ fileSave(client, file, type);
11
+ return file;
12
+ } catch (error) {
13
+ new XernerxLog(client).error(`Couldn't load ${type} ${path.match(/\w*\.js$/gim)?.at(0) || path}`, error);
14
+ }
16
15
  }
17
16
  function fileSave(client, file, type) {
18
- switch (type) {
19
- case 'MessageCommand':
20
- client.commands.message.set(file.name, file);
21
- break;
22
- case 'SlashCommand':
23
- client.commands.slash.set(file.name, file);
24
- break;
25
- case 'ContextCommand':
26
- client.commands.context.set(file.name, file);
27
- break;
28
- case 'Inhibitor':
29
- client.inhibitors.set(file.name, file);
30
- break;
31
- case 'Event':
32
- client.events.set(file.name, file);
33
- break;
34
- }
17
+ switch (type) {
18
+ case 'MessageCommand':
19
+ client.commands.message.set(file.name, file);
20
+ break;
21
+ case 'SlashCommand':
22
+ client.commands.slash.set(file.name, file);
23
+ break;
24
+ case 'ContextCommand':
25
+ client.commands.context.set(file.name, file);
26
+ break;
27
+ case 'Inhibitor':
28
+ client.inhibitors.set(file.name, file);
29
+ break;
30
+ case 'Event':
31
+ client.events.set(file.name, file);
32
+ break;
33
+ }
35
34
  }
@@ -3,28 +3,27 @@ import * as path from 'path';
3
3
  import * as fs from 'fs';
4
4
  import load from './load.js';
5
5
  export default async function reload(client, type) {
6
- switch (type) {
7
- case 'message': {
8
- client.commands.message.clear();
9
- if (!client.modules.options.message)
10
- return null;
11
- const directory = path.resolve(client.modules.options.message?.directory);
12
- for (const file of fs.readdirSync(directory)) {
13
- load(client, `${directory}\\${file}`, 'MessageCommand');
14
- }
15
- return true;
16
- }
17
- case 'slash': {
18
- return client.commands.slash.clear();
19
- }
20
- case 'context': {
21
- return client.commands.context.clear();
22
- }
23
- case 'events': {
24
- return client.events.clear();
25
- }
26
- case 'inhibitors': {
27
- return client.inhibitors.clear();
28
- }
29
- }
6
+ switch (type) {
7
+ case 'message': {
8
+ client.commands.message.clear();
9
+ if (!client.modules.options.message) return null;
10
+ const directory = path.resolve(client.modules.options.message?.directory);
11
+ for (const file of fs.readdirSync(directory)) {
12
+ load(client, `${directory}\\${file}`, 'MessageCommand');
13
+ }
14
+ return true;
15
+ }
16
+ case 'slash': {
17
+ return client.commands.slash.clear();
18
+ }
19
+ case 'context': {
20
+ return client.commands.context.clear();
21
+ }
22
+ case 'events': {
23
+ return client.events.clear();
24
+ }
25
+ case 'inhibitors': {
26
+ return client.inhibitors.clear();
27
+ }
28
+ }
30
29
  }
@@ -1,4 +1,4 @@
1
1
  /** @format */
2
2
  import XernerxClient from '../client/XernerxClient.js';
3
3
  import { PresenceOptions } from '../types/interfaces.js';
4
- export default function setPresence(client: XernerxClient, options: PresenceOptions): import("discord.js").ClientPresence | undefined;
4
+ export default function setPresence(client: XernerxClient, options: PresenceOptions): import('discord.js').ClientPresence | undefined;
@@ -2,20 +2,21 @@
2
2
  import { ActivityType } from 'discord.js';
3
3
  import { Style } from 'dumfunctions';
4
4
  export default function setPresence(client, options) {
5
- const presence = () => client.user?.setPresence({
6
- activities: [
7
- {
8
- name: options.text,
9
- type: ActivityType[Style.titleCase(options.type || 'Custom')],
10
- url: options.url,
11
- },
12
- ],
13
- status: options.status,
14
- });
15
- let response = presence();
16
- if (options.interval)
17
- setInterval(() => {
18
- response = presence();
19
- }, options.interval);
20
- return response;
5
+ const presence = () =>
6
+ client.user?.setPresence({
7
+ activities: [
8
+ {
9
+ name: options.text,
10
+ type: ActivityType[Style.titleCase(options.type || 'Custom')],
11
+ url: options.url,
12
+ },
13
+ ],
14
+ status: options.status,
15
+ });
16
+ let response = presence();
17
+ if (options.interval)
18
+ setInterval(() => {
19
+ response = presence();
20
+ }, options.interval);
21
+ return response;
21
22
  }
@@ -1,11 +1,10 @@
1
1
  /** @format */
2
2
  export async function xernerxUser(event, client) {
3
- const author = event.author || event.user;
4
- author.owner = isOwner(client, author);
5
- if (client.dbl.validate)
6
- author.voted = await client?.dbl?.validate(author);
7
- return author;
3
+ const author = event.author || event.user;
4
+ author.owner = isOwner(client, author);
5
+ if (client.dbl.validate) author.voted = await client?.dbl?.validate(author);
6
+ return author;
8
7
  }
9
8
  function isOwner(client, user) {
10
- return client.settings.ownerId.includes(user.id);
9
+ return client.settings.ownerId.includes(user.id);
11
10
  }