xernerx 3.4.3 → 3.5.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.
Files changed (66) hide show
  1. package/README.md +10 -10
  2. package/dist/build/ContextCommandBuilder.d.ts +60 -42
  3. package/dist/build/ContextCommandBuilder.js +93 -86
  4. package/dist/build/EventBuilder.d.ts +21 -17
  5. package/dist/build/EventBuilder.js +34 -35
  6. package/dist/build/InhibitorBuilder.d.ts +19 -20
  7. package/dist/build/InhibitorBuilder.js +27 -27
  8. package/dist/build/MessageCommandBuilder.d.ts +53 -42
  9. package/dist/build/MessageCommandBuilder.js +90 -78
  10. package/dist/build/SlashCommandBuilder.d.ts +58 -40
  11. package/dist/build/SlashCommandBuilder.js +125 -118
  12. package/dist/client/XernerxClient.d.ts +28 -28
  13. package/dist/client/XernerxClient.js +101 -83
  14. package/dist/handlers/CommandHandler.d.ts +27 -27
  15. package/dist/handlers/CommandHandler.js +42 -42
  16. package/dist/handlers/EventHandler.d.ts +13 -13
  17. package/dist/handlers/EventHandler.js +16 -16
  18. package/dist/handlers/Handler.d.ts +57 -57
  19. package/dist/handlers/Handler.js +250 -250
  20. package/dist/handlers/InhibitorHandler.d.ts +18 -18
  21. package/dist/handlers/InhibitorHandler.js +21 -21
  22. package/dist/main.cjs +2023 -0
  23. package/dist/main.d.ts +30 -30
  24. package/dist/main.js +42 -42
  25. package/dist/models/CommandArguments.d.ts +17 -17
  26. package/dist/models/CommandArguments.js +121 -123
  27. package/dist/models/Events.d.ts +24 -24
  28. package/dist/models/Events.js +294 -304
  29. package/dist/models/Extensions.d.ts +7 -7
  30. package/dist/models/Extensions.js +23 -23
  31. package/dist/tools/XernerxError.d.ts +5 -5
  32. package/dist/tools/XernerxError.js +8 -8
  33. package/dist/tools/package.d.ts +49 -38
  34. package/dist/tools/package.js +48 -41
  35. package/dist/types/enums.d.ts +35 -35
  36. package/dist/types/enums.js +35 -35
  37. package/dist/types/interfaces.d.ts +25 -25
  38. package/dist/types/interfaces.js +1 -1
  39. package/dist/types/options.d.ts +241 -206
  40. package/dist/types/options.js +1 -1
  41. package/dist/types/types.d.ts +34 -32
  42. package/dist/types/types.js +1 -1
  43. package/dist/utils/ClientUtil.d.ts +25 -25
  44. package/dist/utils/ClientUtil.js +222 -218
  45. package/dist/utils/CommandUtil.d.ts +56 -56
  46. package/dist/utils/CommandUtil.js +248 -260
  47. package/dist/validators/CommandValidations.d.ts +7 -7
  48. package/dist/validators/CommandValidations.js +183 -185
  49. package/dist/validators/InhibitorValidations.d.ts +11 -11
  50. package/dist/validators/InhibitorValidations.js +42 -42
  51. package/dist/validators/Shapes.js +1 -0
  52. package/package.json +54 -39
  53. package/dist/build/XContextCommandBuilder.d.ts +0 -40
  54. package/dist/build/XContextCommandBuilder.js +0 -84
  55. package/dist/build/XEventBuilder.d.ts +0 -17
  56. package/dist/build/XEventBuilder.js +0 -35
  57. package/dist/build/XInhibitorBuilder.d.ts +0 -20
  58. package/dist/build/XInhibitorBuilder.js +0 -28
  59. package/dist/build/XMessageCommandBuilder.d.ts +0 -42
  60. package/dist/build/XMessageCommandBuilder.js +0 -80
  61. package/dist/build/XSlashCommandBuilder.d.ts +0 -36
  62. package/dist/build/XSlashCommandBuilder.js +0 -114
  63. package/dist/models/CommandValidations.d.ts +0 -4
  64. package/dist/models/CommandValidations.js +0 -183
  65. package/dist/models/InhibitorValidations.d.ts +0 -12
  66. package/dist/models/InhibitorValidations.js +0 -42
@@ -1,83 +1,101 @@
1
- import { Client, Collection } from 'discord.js';
2
- import { s } from '@sapphire/shapeshift';
3
- import { Style } from 'dumfunctions';
4
- import { ClientUtil } from '../utils/ClientUtil.js';
5
- import CommandHandler from '../handlers/CommandHandler.js';
6
- import EventHandler from '../handlers/EventHandler.js';
7
- import InhibitorHandler from '../handlers/InhibitorHandler.js';
8
- import Extensions from '../models/Extensions.js';
9
- // TODO - Add logOnError as a setting to the client.
10
- // TODO - Add commandNotFound as an event to the client.
11
- /**
12
- * @description - The Client.
13
- * @param {DiscordOptions} discordOptions - The options for discord.js.
14
- * @param {ClientOptions} clientOptions - The options for the Xernerx Client.
15
- * @extends {Client}
16
- */
17
- export default class XernerxClient extends Client {
18
- settings;
19
- commands;
20
- cache;
21
- modules;
22
- util;
23
- handlerOptions;
24
- events;
25
- extensions;
26
- inhibitors;
27
- config;
28
- constructor(discordOptions, clientOptions, config) {
29
- super(discordOptions);
30
- this.settings = s
31
- .object({
32
- ownerId: s.union(s.array(s.string).unique, s.string).default([]),
33
- clientPermissions: s.array(s.bigint).default([]),
34
- userPermissions: s.array(s.bigint).default([]),
35
- ignoreOwner: s.boolean.default(false),
36
- logging: s.boolean.optional,
37
- cooldown: s.object({
38
- default: s.number.default(0),
39
- cache: s.number.default(0),
40
- }).optional,
41
- })
42
- .parse(clientOptions);
43
- this.config = config || {};
44
- this.commands = {
45
- message: new Collection(),
46
- slash: new Collection(),
47
- context: new Collection(),
48
- };
49
- this.events = new Collection();
50
- this.inhibitors = new Collection();
51
- this.cache = {
52
- messages: new Collection(),
53
- cooldowns: new Collection(),
54
- messageCommands: new Collection(),
55
- slashCommands: new Collection(),
56
- contextCommands: new Collection(),
57
- commands: new Collection(),
58
- };
59
- this.modules = {
60
- commandHandler: new CommandHandler(this),
61
- eventHandler: new EventHandler(this),
62
- inhibitorHandler: new InhibitorHandler(this),
63
- };
64
- this.extensions = {};
65
- this.util = new ClientUtil(this);
66
- this.handlerOptions = {};
67
- if (this.settings.logging) {
68
- this.once('ready', async (client) => {
69
- const size = (await client.guilds.fetch()).size;
70
- console.info(Style.log(`Xernerx | ${client.user.tag} signed in watching ${size} server${size > 1 ? 's' : ''}. ${(this.handlerOptions.slash || this.handlerOptions.context)?.guildId
71
- ? `Using ${(await this.guilds.fetch((this.handlerOptions.slash || this.handlerOptions.context)?.guildId || '0')).name} as local guild.`
72
- : ''}`, { color: Style.TextColor.Purple }));
73
- });
74
- }
75
- }
76
- register(token) {
77
- this.login(token);
78
- }
79
- loadAllExtensions(options) {
80
- const extensions = new Extensions(this);
81
- return extensions.load(options.extensions, options.logging || false);
82
- }
83
- }
1
+ import { Client, Collection } from 'discord.js';
2
+ import { z } from 'zod';
3
+ import { Style } from 'dumfunctions';
4
+ import { ClientUtil } from '../utils/ClientUtil.js';
5
+ import CommandHandler from '../handlers/CommandHandler.js';
6
+ import EventHandler from '../handlers/EventHandler.js';
7
+ import InhibitorHandler from '../handlers/InhibitorHandler.js';
8
+ import Extensions from '../models/Extensions.js';
9
+ // TODO - Add commandNotFound as an event to the client.
10
+ /**
11
+ * @description - The Client.
12
+ * @param {DiscordOptions} discordOptions - The options for discord.js.
13
+ * @param {ClientOptions} clientOptions - The options for the Xernerx Client.
14
+ * @extends {Client}
15
+ */
16
+ export default class XernerxClient extends Client {
17
+ settings;
18
+ commands;
19
+ cache;
20
+ modules;
21
+ util;
22
+ handlerOptions;
23
+ events;
24
+ extensions;
25
+ inhibitors;
26
+ config;
27
+ constructor(discordOptions, clientOptions, config) {
28
+ super(discordOptions);
29
+ this.settings = z
30
+ .object({
31
+ ownerId: z.string().or(z.array(z.string())).default([]),
32
+ permissions: z
33
+ .object({
34
+ client: z.array(z.string()).default([]),
35
+ user: z.array(z.string()).default([]),
36
+ dm: z.boolean().default(false),
37
+ })
38
+ .optional(),
39
+ ignore: z
40
+ .object({
41
+ owner: z.boolean().default(false),
42
+ users: z.array(z.string()),
43
+ channels: z.array(z.string()),
44
+ guilds: z.array(z.string()),
45
+ })
46
+ .optional(),
47
+ log: z
48
+ .object({
49
+ ready: z.boolean().default(false),
50
+ error: z.boolean().default(false),
51
+ })
52
+ .optional(),
53
+ cooldown: z
54
+ .object({
55
+ command: z.number().default(0),
56
+ cache: z.number().default(0),
57
+ })
58
+ .optional(),
59
+ })
60
+ .parse(clientOptions);
61
+ this.config = config || {};
62
+ this.commands = {
63
+ message: new Collection(),
64
+ slash: new Collection(),
65
+ context: new Collection(),
66
+ };
67
+ this.events = new Collection();
68
+ this.inhibitors = new Collection();
69
+ this.cache = {
70
+ messages: new Collection(),
71
+ cooldowns: new Collection(),
72
+ messageCommands: new Collection(),
73
+ slashCommands: new Collection(),
74
+ contextCommands: new Collection(),
75
+ commands: new Collection(),
76
+ };
77
+ this.modules = {
78
+ commandHandler: new CommandHandler(this),
79
+ eventHandler: new EventHandler(this),
80
+ inhibitorHandler: new InhibitorHandler(this),
81
+ };
82
+ this.extensions = {};
83
+ this.util = new ClientUtil(this);
84
+ this.handlerOptions = {};
85
+ if (this.settings?.log?.ready) {
86
+ this.once('ready', async (client) => {
87
+ const size = (await client.guilds.fetch()).size;
88
+ console.info(Style.log(`Xernerx | ${client.user.tag} signed in watching ${size} server${size > 1 ? 's' : ''}. ${(this.handlerOptions.slash || this.handlerOptions.context)?.guildId
89
+ ? `Using ${(await this.guilds.fetch((this.handlerOptions.slash || this.handlerOptions.context)?.guildId || '0')).name} as local guild.`
90
+ : ''}`, { color: Style.TextColor.Purple }));
91
+ });
92
+ }
93
+ }
94
+ register(token) {
95
+ this.login(token);
96
+ }
97
+ loadAllExtensions(options) {
98
+ const extensions = new Extensions(this);
99
+ return extensions.load(options.extensions, options.logging || false);
100
+ }
101
+ }
@@ -1,27 +1,27 @@
1
- import XernerxClient from '../client/XernerxClient.js';
2
- import { Handler } from './Handler.js';
3
- import { ContextCommandHandlerOptions, MessageCommandHandlerOptions, SlashCommandHandlerOptions } from '../types/options.js';
4
- /**
5
- * @description - The command handler.
6
- * @param {XernerxClient} client - The XernerxClient.
7
- */
8
- export default class CommandHandler {
9
- client: XernerxClient;
10
- handler: Handler;
11
- constructor(client: XernerxClient);
12
- /**
13
- * @description - The message command loader.
14
- * @param {MessageCommandOptions} options - message command loader options.
15
- */
16
- loadAllMessageCommands(options: MessageCommandHandlerOptions): void;
17
- /**
18
- * @description - The slash command loader.
19
- * @param {SlashCommandOptions} options - slash command loader options.
20
- */
21
- loadAllSlashCommands(options: SlashCommandHandlerOptions): void;
22
- /**
23
- * @description - The context command loader.
24
- * @param {ContextCommandOptions} options - context command loader options.
25
- */
26
- loadAllContextCommands(options: ContextCommandHandlerOptions): void;
27
- }
1
+ import XernerxClient from '../client/XernerxClient.js';
2
+ import { Handler } from './Handler.js';
3
+ import { ContextCommandHandlerOptions, MessageCommandHandlerOptions, SlashCommandHandlerOptions } from '../types/options.js';
4
+ /**
5
+ * @description - The command handler.
6
+ * @param {XernerxClient} client - The XernerxClient.
7
+ */
8
+ export default class CommandHandler {
9
+ client: XernerxClient;
10
+ handler: Handler;
11
+ constructor(client: XernerxClient);
12
+ /**
13
+ * @description - The message command loader.
14
+ * @param {MessageCommandOptions} options - message command loader options.
15
+ */
16
+ loadAllMessageCommands(options: MessageCommandHandlerOptions): void;
17
+ /**
18
+ * @description - The slash command loader.
19
+ * @param {SlashCommandOptions} options - slash command loader options.
20
+ */
21
+ loadAllSlashCommands(options: SlashCommandHandlerOptions): void;
22
+ /**
23
+ * @description - The context command loader.
24
+ * @param {ContextCommandOptions} options - context command loader options.
25
+ */
26
+ loadAllContextCommands(options: ContextCommandHandlerOptions): void;
27
+ }
@@ -1,42 +1,42 @@
1
- import { Handler } from './Handler.js';
2
- import { CommandsDeploy, ContextCommandEvents, MessageCommandEvents, SlashCommandEvents } from '../models/Events.js';
3
- /**
4
- * @description - The command handler.
5
- * @param {XernerxClient} client - The XernerxClient.
6
- */
7
- export default class CommandHandler {
8
- client;
9
- handler;
10
- constructor(client) {
11
- this.client = client;
12
- this.handler = new Handler(client);
13
- new CommandsDeploy(this.client).deploy();
14
- }
15
- /**
16
- * @description - The message command loader.
17
- * @param {MessageCommandOptions} options - message command loader options.
18
- */
19
- loadAllMessageCommands(options) {
20
- this.handler.loadAllMessageCommands(options);
21
- const events = new MessageCommandEvents(this.client);
22
- events.messageCreate();
23
- events.messageUpdate();
24
- events.messageDelete();
25
- }
26
- /**
27
- * @description - The slash command loader.
28
- * @param {SlashCommandOptions} options - slash command loader options.
29
- */
30
- loadAllSlashCommands(options) {
31
- this.handler.loadAllSlashCommands(options);
32
- new SlashCommandEvents(this.client).slashCreate();
33
- }
34
- /**
35
- * @description - The context command loader.
36
- * @param {ContextCommandOptions} options - context command loader options.
37
- */
38
- loadAllContextCommands(options) {
39
- this.handler.loadAllContextCommands(options);
40
- new ContextCommandEvents(this.client).contextCreate();
41
- }
42
- }
1
+ import { Handler } from './Handler.js';
2
+ import { CommandsDeploy, ContextCommandEvents, MessageCommandEvents, SlashCommandEvents } from '../models/Events.js';
3
+ /**
4
+ * @description - The command handler.
5
+ * @param {XernerxClient} client - The XernerxClient.
6
+ */
7
+ export default class CommandHandler {
8
+ client;
9
+ handler;
10
+ constructor(client) {
11
+ this.client = client;
12
+ this.handler = new Handler(client);
13
+ new CommandsDeploy(this.client).deploy();
14
+ }
15
+ /**
16
+ * @description - The message command loader.
17
+ * @param {MessageCommandOptions} options - message command loader options.
18
+ */
19
+ loadAllMessageCommands(options) {
20
+ this.handler.loadAllMessageCommands(options);
21
+ const events = new MessageCommandEvents(this.client);
22
+ events.messageCreate();
23
+ events.messageUpdate();
24
+ events.messageDelete();
25
+ }
26
+ /**
27
+ * @description - The slash command loader.
28
+ * @param {SlashCommandOptions} options - slash command loader options.
29
+ */
30
+ loadAllSlashCommands(options) {
31
+ this.handler.loadAllSlashCommands(options);
32
+ new SlashCommandEvents(this.client).slashCreate();
33
+ }
34
+ /**
35
+ * @description - The context command loader.
36
+ * @param {ContextCommandOptions} options - context command loader options.
37
+ */
38
+ loadAllContextCommands(options) {
39
+ this.handler.loadAllContextCommands(options);
40
+ new ContextCommandEvents(this.client).contextCreate();
41
+ }
42
+ }
@@ -1,13 +1,13 @@
1
- import XernerxClient from '../client/XernerxClient.js';
2
- import { EventHandlerOptions } from '../types/options.js';
3
- import { Handler } from './Handler.js';
4
- export default class EventHandler {
5
- client: XernerxClient;
6
- handler: Handler;
7
- constructor(client: XernerxClient);
8
- /**
9
- * @description - The event loader
10
- * @param {EventLoadOptions} options - message command options
11
- */
12
- loadAllEvents(options: EventHandlerOptions): void;
13
- }
1
+ import XernerxClient from '../client/XernerxClient.js';
2
+ import { EventHandlerOptions } from '../types/options.js';
3
+ import { Handler } from './Handler.js';
4
+ export default class EventHandler {
5
+ client: XernerxClient;
6
+ handler: Handler;
7
+ constructor(client: XernerxClient);
8
+ /**
9
+ * @description - The event loader
10
+ * @param {EventLoadOptions} options - message command options
11
+ */
12
+ loadAllEvents(options: EventHandlerOptions): void;
13
+ }
@@ -1,16 +1,16 @@
1
- import { Handler } from './Handler.js';
2
- export default class EventHandler {
3
- client;
4
- handler;
5
- constructor(client) {
6
- this.client = client;
7
- this.handler = new Handler(client);
8
- }
9
- /**
10
- * @description - The event loader
11
- * @param {EventLoadOptions} options - message command options
12
- */
13
- loadAllEvents(options) {
14
- return this.handler.loadAllEvents(options);
15
- }
16
- }
1
+ import { Handler } from './Handler.js';
2
+ export default class EventHandler {
3
+ client;
4
+ handler;
5
+ constructor(client) {
6
+ this.client = client;
7
+ this.handler = new Handler(client);
8
+ }
9
+ /**
10
+ * @description - The event loader
11
+ * @param {EventLoadOptions} options - message command options
12
+ */
13
+ loadAllEvents(options) {
14
+ return this.handler.loadAllEvents(options);
15
+ }
16
+ }
@@ -1,57 +1,57 @@
1
- import XernerxClient from '../client/XernerxClient.js';
2
- import { ContextCommandHandlerOptions, EventHandlerOptions, InhibitorHandlerOptions, MessageCommandHandlerOptions, SlashCommandHandlerOptions } from '../types/options.js';
3
- /**
4
- * @description - The Handler class.
5
- * @param {XernerxClient} client - The XernerxClient.
6
- */
7
- export declare class Handler {
8
- private client;
9
- commands: object[];
10
- readyTimestamp: number;
11
- constructor(client: XernerxClient);
12
- /**
13
- * @description - The loader for the message commands.
14
- * @param {MessageCommandOptions} options - The options for the message command loader.
15
- */
16
- loadAllMessageCommands(options: MessageCommandHandlerOptions): void;
17
- /**
18
- * @description - The loader for the slash commands.
19
- * @param {SlashCommandOptions} options - The options for the slash command loader.
20
- */
21
- loadAllSlashCommands(options: SlashCommandHandlerOptions): void;
22
- /**
23
- * @description - The loader for the context commands.
24
- * @param {ContextCommandOptions} options - The options for the context command loader.
25
- */
26
- loadAllContextCommands(options: ContextCommandHandlerOptions): void;
27
- /**
28
- * @description - The loader for the events.
29
- * @param {EventLoadOptions} options - The options for the event loader.
30
- */
31
- loadAllEvents(options: EventHandlerOptions): void;
32
- /**
33
- * @description - The loader for the inhibitors.
34
- * @param {InhibitorLoadOptions} options - The options for the inhibitor loader.
35
- */
36
- loadAllInhibitors(options: InhibitorHandlerOptions): void;
37
- /**
38
- * @description - a reader for directories
39
- * @param {string} dir - the directory to look for.
40
- * @returns array of files.
41
- */
42
- private readdir;
43
- /**
44
- * @description file loader.
45
- * @param {string} dir - the directory.
46
- * @param {string} file - the file in the directory.
47
- * @param {string} type - the type of file.
48
- * @returns undefined
49
- */
50
- private load;
51
- /**
52
- * @description the event emitter to emit all events.
53
- * @param {object} event - the event to be emitted.
54
- * @returns void
55
- */
56
- private emitter;
57
- }
1
+ import XernerxClient from '../client/XernerxClient.js';
2
+ import { ContextCommandHandlerOptions, EventHandlerOptions, InhibitorHandlerOptions, MessageCommandHandlerOptions, SlashCommandHandlerOptions } from '../types/options.js';
3
+ /**
4
+ * @description - The Handler class.
5
+ * @param {XernerxClient} client - The XernerxClient.
6
+ */
7
+ export declare class Handler {
8
+ private client;
9
+ commands: object[];
10
+ readyTimestamp: number;
11
+ constructor(client: XernerxClient);
12
+ /**
13
+ * @description - The loader for the message commands.
14
+ * @param {MessageCommandOptions} options - The options for the message command loader.
15
+ */
16
+ loadAllMessageCommands(options: MessageCommandHandlerOptions): void;
17
+ /**
18
+ * @description - The loader for the slash commands.
19
+ * @param {SlashCommandOptions} options - The options for the slash command loader.
20
+ */
21
+ loadAllSlashCommands(options: SlashCommandHandlerOptions): void;
22
+ /**
23
+ * @description - The loader for the context commands.
24
+ * @param {ContextCommandOptions} options - The options for the context command loader.
25
+ */
26
+ loadAllContextCommands(options: ContextCommandHandlerOptions): void;
27
+ /**
28
+ * @description - The loader for the events.
29
+ * @param {EventLoadOptions} options - The options for the event loader.
30
+ */
31
+ loadAllEvents(options: EventHandlerOptions): void;
32
+ /**
33
+ * @description - The loader for the inhibitors.
34
+ * @param {InhibitorLoadOptions} options - The options for the inhibitor loader.
35
+ */
36
+ loadAllInhibitors(options: InhibitorHandlerOptions): void;
37
+ /**
38
+ * @description - a reader for directories
39
+ * @param {string} dir - the directory to look for.
40
+ * @returns array of files.
41
+ */
42
+ private readdir;
43
+ /**
44
+ * @description file loader.
45
+ * @param {string} dir - the directory.
46
+ * @param {string} file - the file in the directory.
47
+ * @param {string} type - the type of file.
48
+ * @returns undefined
49
+ */
50
+ private load;
51
+ /**
52
+ * @description the event emitter to emit all events.
53
+ * @param {object} event - the event to be emitted.
54
+ * @returns void
55
+ */
56
+ private emitter;
57
+ }