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.
- package/dist/build/XernerxContextCommand.d.ts +75 -47
- package/dist/build/XernerxContextCommand.js +119 -115
- package/dist/build/XernerxEvent.d.ts +10 -10
- package/dist/build/XernerxEvent.js +17 -17
- package/dist/build/XernerxInhibitor.d.ts +39 -15
- package/dist/build/XernerxInhibitor.js +18 -18
- package/dist/build/XernerxMessageCommand.d.ts +78 -52
- package/dist/build/XernerxMessageCommand.js +118 -114
- package/dist/build/XernerxSlashCommand.d.ts +97 -63
- package/dist/build/XernerxSlashCommand.js +176 -172
- package/dist/client/XernerxClient.d.ts +61 -47
- package/dist/client/XernerxClient.js +92 -88
- package/dist/client/XernerxShardClient.d.ts +14 -14
- package/dist/client/XernerxShardClient.js +61 -47
- package/dist/functions/deploy.js +45 -52
- package/dist/functions/load.js +28 -29
- package/dist/functions/reload.js +23 -24
- package/dist/functions/setPresence.d.ts +1 -1
- package/dist/functions/setPresence.js +17 -16
- package/dist/functions/xernerxUser.js +5 -6
- package/dist/handlers/CommandHandler.d.ts +10 -10
- package/dist/handlers/CommandHandler.js +311 -336
- package/dist/handlers/EventHandler.d.ts +3 -3
- package/dist/handlers/EventHandler.js +48 -21
- package/dist/handlers/ExtensionHandler.d.ts +3 -3
- package/dist/handlers/ExtensionHandler.js +23 -23
- package/dist/handlers/Handler.d.ts +22 -14
- package/dist/handlers/Handler.js +46 -50
- package/dist/handlers/InhibitorHandler.d.ts +3 -3
- package/dist/handlers/InhibitorHandler.js +25 -23
- package/dist/handlers/IntegrationHandler.d.ts +6 -6
- package/dist/handlers/IntegrationHandler.js +20 -20
- package/dist/main.d.ts +28 -21
- package/dist/main.js +28 -21
- package/dist/models/Arguments.d.ts +4 -1
- package/dist/models/Arguments.js +134 -149
- package/dist/models/Cooldowns.d.ts +6 -6
- package/dist/models/Cooldowns.js +25 -29
- package/dist/tools/XernerxError.d.ts +4 -4
- package/dist/tools/XernerxError.js +8 -8
- package/dist/tools/XernerxIntents.d.ts +2 -2
- package/dist/tools/XernerxIntents.js +21 -21
- package/dist/tools/XernerxLog.d.ts +25 -23
- package/dist/tools/XernerxLog.js +139 -110
- package/dist/tools/XernerxText.d.ts +23 -23
- package/dist/tools/XernerxText.js +79 -89
- package/dist/types/extenders.d.ts +55 -47
- package/dist/types/interfaces.d.ts +195 -189
- package/dist/types/types.d.ts +104 -5
- package/dist/utils/ClientUtil.d.ts +12 -9
- package/dist/utils/ClientUtil.js +96 -79
- package/dist/utils/InteractionUtil.d.ts +13 -13
- package/dist/utils/InteractionUtil.js +148 -147
- package/dist/utils/MessageUtil.d.ts +14 -14
- package/dist/utils/MessageUtil.js +162 -161
- package/dist/utils/Util.d.ts +7 -4
- package/dist/utils/Util.js +7 -7
- package/dist/validators/commandValidation.d.ts +4 -1
- package/dist/validators/commandValidation.js +157 -114
- package/dist/validators/inhibitorValidations.d.ts +21 -2
- package/dist/validators/inhibitorValidations.js +39 -39
- 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
}
|