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
@@ -3,176 +3,180 @@ import Discord, { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuil
3
3
  import { z } from 'zod';
4
4
  import XernerxLog from '../tools/XernerxLog.js';
5
5
  export default class XernerxSlashCommand {
6
- constructor(id, options) {
7
- this.id = id;
8
- this.data = new Discord.SlashCommandBuilder();
9
- this.data.setName(options.name);
10
- this.data.setNameLocalizations(options.nameLocalizations || null);
11
- this.data.setDescription(options.description);
12
- this.data.setDescriptionLocalizations(options.descriptionLocalizations || null);
13
- this.data.setDMPermission(options.permissions?.dm || null);
14
- if (options.args && options?.args?.length > 0) {
15
- this.addArguments(this.data, options.args);
16
- }
17
- if (options.subcommands && options?.subcommands?.length > 0) {
18
- this.addSubcommands(this.data, options.subcommands);
19
- }
20
- if (options.groups && options?.groups?.length > 0) {
21
- this.addSubcommandGroups(options.groups);
22
- }
23
- options = z
24
- .object({
25
- name: z.string(),
26
- description: z.string(),
27
- usage: z.string().or(z.null()).default(null),
28
- info: z.string().or(z.null()).default(null),
29
- category: z.string().or(z.null()).default(null),
30
- cooldown: z.number().or(z.null()).default(null),
31
- number: z.number().or(z.null()).default(null),
32
- global: z.boolean().default(true),
33
- channel: z
34
- .array(z.enum([
35
- 'GuildText',
36
- 'DM',
37
- 'GuildVoice',
38
- 'GroupDM',
39
- 'GuildCategory',
40
- 'GuildAnnouncement',
41
- 'AnnouncementThread',
42
- 'PublicThread',
43
- 'PrivateThread',
44
- 'GuildStageVoice',
45
- 'GuildDirectory',
46
- 'GuildForum',
47
- 'GuildNews',
48
- 'GuildNewsThread',
49
- 'GuildPublicThread',
50
- 'GuildPrivateThread',
51
- ]))
52
- .or(z.enum([
53
- 'GuildText',
54
- 'DM',
55
- 'GuildVoice',
56
- 'GroupDM',
57
- 'GuildCategory',
58
- 'GuildAnnouncement',
59
- 'AnnouncementThread',
60
- 'PublicThread',
61
- 'PrivateThread',
62
- 'GuildStageVoice',
63
- 'GuildDirectory',
64
- 'GuildForum',
65
- 'GuildNews',
66
- 'GuildNewsThread',
67
- 'GuildPublicThread',
68
- 'GuildPrivateThread',
69
- ]))
70
- .or(z.null())
71
- .default(null),
72
- ignore: z
73
- .object({
74
- owner: z.boolean().default(false),
75
- users: z.array(z.string()).default([]),
76
- channels: z.array(z.string()).default([]),
77
- guilds: z.array(z.string()).default([]),
78
- voice: z.boolean().default(false),
79
- })
80
- .default({}),
81
- strict: z
82
- .object({
83
- owner: z.boolean().default(false),
84
- users: z.array(z.string()).default([]),
85
- channels: z.array(z.string()).default([]),
86
- guilds: z.array(z.string()).default([]),
87
- voice: z.boolean().default(false),
88
- })
89
- .default({}),
90
- permissions: z
91
- .object({
92
- user: z.array(z.string()).or(z.null()).default(null),
93
- client: z.array(z.string()).or(z.null()).default(null),
94
- dm: z.boolean().default(true),
95
- })
96
- .default({}),
97
- defer: z
98
- .object({
99
- reply: z.boolean().optional(),
100
- ephemeral: z.boolean().optional(),
101
- fetch: z.boolean().optional(),
102
- })
103
- .default({}),
104
- })
105
- .parse(options);
106
- this.name = options.name;
107
- this.description = options.description;
108
- this.usage = options.usage;
109
- this.info = options.info;
110
- this.category = options.category;
111
- this.cooldown = options.cooldown;
112
- this.channel = options.channel ? (Array.isArray(options.channel) ? options.channel : [options.channel]) : null;
113
- this.global = options.global;
114
- this.ignore = options.ignore;
115
- this.strict = options.strict;
116
- this.permissions = options.permissions;
117
- this.defer = options.defer;
118
- this.client = this.client;
119
- this.util = this.util;
120
- }
121
- /**
122
- * @description autocomplete let's you add choices to string option arguments
123
- * @param interaction - The interaction event emitted on this command
124
- * @param focused - The command option that is in focus
125
- * @param options - The full list of options on the command
126
- */
127
- async autocomplete(interaction, focused, options) { }
128
- /**
129
- * @description Checks for conditions before running the command
130
- * @param interaction - The interaction event emitted on this command
131
- * @param options - The args, group and subcommand parsed on this command
132
- */
133
- async conditions(interaction, { args, subcommand, group }) { }
134
- /**
135
- * @description Runs the execution rule
136
- * @param interaction - The interaction event emitted on this command
137
- * @param options - The args, group and subcommand parsed on this command
138
- */
139
- async exec(interaction, { args, subcommand, group }) {
140
- new XernerxLog(this.client).error(`${this.id} doesn't have an execution rule.`);
141
- return await this.client.emit('commandError', interaction, `${this.id} doesn't have an execution rule.`, this);
142
- }
143
- addArguments(command, args) {
144
- for (const argument of args) {
145
- let slashCommandArgumentType = `${argument.type.charAt(0).toUpperCase()}${argument.type.slice(1).toLowerCase()}`;
146
- command[`add${slashCommandArgumentType}Option`]((option) => {
147
- option
148
- .setName(argument.name)
149
- .setDescription(argument.description)
150
- .setRequired(argument.required || false);
151
- if (slashCommandArgumentType === 'String') {
152
- if (argument.choices)
153
- option.setChoices(...argument.choices.map((choices) => {
154
- return { name: Object.keys(choices).at(0), value: Object.values(choices).at(0) };
155
- }));
156
- option.setAutocomplete(argument.autocomplete || false);
157
- }
158
- return option;
159
- });
160
- }
161
- }
162
- addSubcommands(method, subcommands) {
163
- for (const subcommand of subcommands) {
164
- let sub = new SlashCommandSubcommandBuilder().setName(subcommand.name).setDescription(subcommand.description);
165
- if (subcommand.args && subcommand?.args?.length > 0)
166
- this.addArguments(sub, subcommand.args);
167
- method.addSubcommand(sub);
168
- }
169
- }
170
- addSubcommandGroups(groups) {
171
- for (const group of groups) {
172
- let subcommandGroup = new SlashCommandSubcommandGroupBuilder().setName(group.name).setDescription(group.description);
173
- if (group.subcommands?.length > 0)
174
- this.addSubcommands(subcommandGroup, group.subcommands);
175
- this.data.addSubcommandGroup(subcommandGroup);
176
- }
177
- }
6
+ constructor(id, options) {
7
+ this.id = id;
8
+ this.data = new Discord.SlashCommandBuilder();
9
+ this.data.setName(options.name);
10
+ this.data.setNameLocalizations(options.nameLocalizations || null);
11
+ this.data.setDescription(options.description);
12
+ this.data.setDescriptionLocalizations(options.descriptionLocalizations || null);
13
+ this.data.setDMPermission(options.permissions?.dm || null);
14
+ if (options.args && options?.args?.length > 0) {
15
+ this.addArguments(this.data, options.args);
16
+ }
17
+ if (options.subcommands && options?.subcommands?.length > 0) {
18
+ this.addSubcommands(this.data, options.subcommands);
19
+ }
20
+ if (options.groups && options?.groups?.length > 0) {
21
+ this.addSubcommandGroups(options.groups);
22
+ }
23
+ options = z
24
+ .object({
25
+ name: z.string(),
26
+ description: z.string(),
27
+ usage: z.string().or(z.null()).default(null),
28
+ info: z.string().or(z.null()).default(null),
29
+ category: z.string().or(z.null()).default(null),
30
+ cooldown: z.number().or(z.null()).default(null),
31
+ number: z.number().or(z.null()).default(null),
32
+ global: z.boolean().default(true),
33
+ channel: z
34
+ .array(
35
+ z.enum([
36
+ 'GuildText',
37
+ 'DM',
38
+ 'GuildVoice',
39
+ 'GroupDM',
40
+ 'GuildCategory',
41
+ 'GuildAnnouncement',
42
+ 'AnnouncementThread',
43
+ 'PublicThread',
44
+ 'PrivateThread',
45
+ 'GuildStageVoice',
46
+ 'GuildDirectory',
47
+ 'GuildForum',
48
+ 'GuildNews',
49
+ 'GuildNewsThread',
50
+ 'GuildPublicThread',
51
+ 'GuildPrivateThread',
52
+ ])
53
+ )
54
+ .or(
55
+ z.enum([
56
+ 'GuildText',
57
+ 'DM',
58
+ 'GuildVoice',
59
+ 'GroupDM',
60
+ 'GuildCategory',
61
+ 'GuildAnnouncement',
62
+ 'AnnouncementThread',
63
+ 'PublicThread',
64
+ 'PrivateThread',
65
+ 'GuildStageVoice',
66
+ 'GuildDirectory',
67
+ 'GuildForum',
68
+ 'GuildNews',
69
+ 'GuildNewsThread',
70
+ 'GuildPublicThread',
71
+ 'GuildPrivateThread',
72
+ ])
73
+ )
74
+ .or(z.null())
75
+ .default(null),
76
+ ignore: z
77
+ .object({
78
+ owner: z.boolean().default(false),
79
+ users: z.array(z.string()).default([]),
80
+ channels: z.array(z.string()).default([]),
81
+ guilds: z.array(z.string()).default([]),
82
+ voice: z.boolean().default(false),
83
+ })
84
+ .default({}),
85
+ strict: z
86
+ .object({
87
+ owner: z.boolean().default(false),
88
+ users: z.array(z.string()).default([]),
89
+ channels: z.array(z.string()).default([]),
90
+ guilds: z.array(z.string()).default([]),
91
+ voice: z.boolean().default(false),
92
+ })
93
+ .default({}),
94
+ permissions: z
95
+ .object({
96
+ user: z.array(z.string()).or(z.null()).default(null),
97
+ client: z.array(z.string()).or(z.null()).default(null),
98
+ dm: z.boolean().default(true),
99
+ })
100
+ .default({}),
101
+ defer: z
102
+ .object({
103
+ reply: z.boolean().optional(),
104
+ ephemeral: z.boolean().optional(),
105
+ fetch: z.boolean().optional(),
106
+ })
107
+ .default({}),
108
+ })
109
+ .parse(options);
110
+ this.name = options.name;
111
+ this.description = options.description;
112
+ this.usage = options.usage;
113
+ this.info = options.info;
114
+ this.category = options.category;
115
+ this.cooldown = options.cooldown;
116
+ this.channel = options.channel ? (Array.isArray(options.channel) ? options.channel : [options.channel]) : null;
117
+ this.global = options.global;
118
+ this.ignore = options.ignore;
119
+ this.strict = options.strict;
120
+ this.permissions = options.permissions;
121
+ this.defer = options.defer;
122
+ this.client = this.client;
123
+ this.util = this.util;
124
+ }
125
+ /**
126
+ * @description autocomplete let's you add choices to string option arguments
127
+ * @param interaction - The interaction event emitted on this command
128
+ * @param focused - The command option that is in focus
129
+ * @param options - The full list of options on the command
130
+ */
131
+ async autocomplete(interaction, focused, options) {}
132
+ /**
133
+ * @description Checks for conditions before running the command
134
+ * @param interaction - The interaction event emitted on this command
135
+ * @param options - The args, group and subcommand parsed on this command
136
+ */
137
+ async conditions(interaction, { args, subcommand, group }) {}
138
+ /**
139
+ * @description Runs the execution rule
140
+ * @param interaction - The interaction event emitted on this command
141
+ * @param options - The args, group and subcommand parsed on this command
142
+ */
143
+ async exec(interaction, { args, subcommand, group }) {
144
+ new XernerxLog(this.client).error(`${this.id} doesn't have an execution rule.`);
145
+ return await this.client.emit('commandError', interaction, `${this.id} doesn't have an execution rule.`, this);
146
+ }
147
+ addArguments(command, args) {
148
+ for (const argument of args) {
149
+ let slashCommandArgumentType = `${argument.type.charAt(0).toUpperCase()}${argument.type.slice(1).toLowerCase()}`;
150
+ command[`add${slashCommandArgumentType}Option`]((option) => {
151
+ option
152
+ .setName(argument.name)
153
+ .setDescription(argument.description)
154
+ .setRequired(argument.required || false);
155
+ if (slashCommandArgumentType === 'String') {
156
+ if (argument.choices)
157
+ option.setChoices(
158
+ ...argument.choices.map((choices) => {
159
+ return { name: Object.keys(choices).at(0), value: Object.values(choices).at(0) };
160
+ })
161
+ );
162
+ option.setAutocomplete(argument.autocomplete || false);
163
+ }
164
+ return option;
165
+ });
166
+ }
167
+ }
168
+ addSubcommands(method, subcommands) {
169
+ for (const subcommand of subcommands) {
170
+ let sub = new SlashCommandSubcommandBuilder().setName(subcommand.name).setDescription(subcommand.description);
171
+ if (subcommand.args && subcommand?.args?.length > 0) this.addArguments(sub, subcommand.args);
172
+ method.addSubcommand(sub);
173
+ }
174
+ }
175
+ addSubcommandGroups(groups) {
176
+ for (const group of groups) {
177
+ let subcommandGroup = new SlashCommandSubcommandGroupBuilder().setName(group.name).setDescription(group.description);
178
+ if (group.subcommands?.length > 0) this.addSubcommands(subcommandGroup, group.subcommands);
179
+ this.data.addSubcommandGroup(subcommandGroup);
180
+ }
181
+ }
178
182
  }
@@ -6,51 +6,65 @@ import ClientUtil from '../utils/ClientUtil.js';
6
6
  import XernerxInhibitor from '../build/XernerxInhibitor.js';
7
7
  import XernerxEvent from '../build/XernerxEvent.js';
8
8
  import Cooldowns from '../models/Cooldowns.js';
9
- export default class XernerxClient<T = unknown> extends Client {
10
- readonly settings: {
11
- ownerId: (string | string[]) & (string | string[] | undefined);
12
- local: string;
13
- ceaseless: boolean;
14
- global?: boolean | undefined;
15
- permissions?: {
16
- user: string[] | null;
17
- client: string[] | null;
18
- dm: boolean;
19
- } | undefined;
20
- ignore?: {
21
- system: boolean;
22
- users: string[];
23
- owner: boolean;
24
- self: boolean;
25
- bots: boolean;
26
- channels: string[];
27
- guilds: string[];
28
- } | undefined;
29
- log?: boolean | {
30
- warn: boolean;
31
- error: boolean;
32
- ready: boolean;
33
- info: boolean;
34
- table: string[] | null;
35
- format: string[] | null;
36
- } | undefined;
37
- cooldown?: {
38
- command: number;
39
- cache: number;
40
- collections: string[];
41
- } | undefined;
42
- };
43
- readonly config: T;
44
- readonly commands: XernerxCommands;
45
- readonly events: Collection<string, XernerxEvent<keyof XernerxClientEvents>>;
46
- readonly inhibitors: Collection<string, XernerxInhibitor>;
47
- readonly modules: ModuleOptions;
48
- readonly util: ClientUtil;
49
- readonly stats: Record<string, number>;
50
- readonly cache: XernerxCache;
51
- readonly cooldowns: Cooldowns;
52
- readonly dbl: any;
53
- readonly [index: string]: unknown;
54
- constructor(discordOptions: ClientOptions, xernerxOptions: XernerxOptions, config?: T);
55
- connect(token: string): Promise<string>;
9
+ export default class XernerxClient<
10
+ T extends object = {
11
+ [index: string | number]: any;
12
+ },
13
+ > extends Client {
14
+ readonly settings: {
15
+ ownerId: (string | string[]) & (string | string[] | undefined);
16
+ local: string;
17
+ ceaseless: boolean;
18
+ global?: boolean | undefined;
19
+ debug?: boolean | undefined;
20
+ permissions?:
21
+ | {
22
+ user: string[] | null;
23
+ client: string[] | null;
24
+ dm: boolean;
25
+ }
26
+ | undefined;
27
+ ignore?:
28
+ | {
29
+ system: boolean;
30
+ users: string[];
31
+ owner: boolean;
32
+ self: boolean;
33
+ bots: boolean;
34
+ channels: string[];
35
+ guilds: string[];
36
+ }
37
+ | undefined;
38
+ log?:
39
+ | boolean
40
+ | {
41
+ warn: boolean;
42
+ error: boolean;
43
+ ready: boolean;
44
+ info: boolean;
45
+ table: string[] | null;
46
+ format: string[] | null;
47
+ }
48
+ | undefined;
49
+ cooldown?:
50
+ | {
51
+ command: number;
52
+ cache: number;
53
+ collections: string[];
54
+ }
55
+ | undefined;
56
+ };
57
+ readonly config: T;
58
+ readonly commands: XernerxCommands;
59
+ readonly events: Collection<string, XernerxEvent<keyof XernerxClientEvents>>;
60
+ readonly inhibitors: Collection<string, XernerxInhibitor>;
61
+ readonly modules: ModuleOptions;
62
+ readonly util: ClientUtil;
63
+ readonly stats: Record<string, number>;
64
+ readonly cache: XernerxCache;
65
+ readonly cooldowns: Cooldowns;
66
+ readonly dbl: any;
67
+ readonly [index: string]: unknown;
68
+ constructor(discordOptions: ClientOptions, xernerxOptions: XernerxOptions, config?: T);
69
+ connect(token: string): Promise<string | void>;
56
70
  }