xernerx 3.3.7 → 3.4.0
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/ContextCommandBuilder.d.ts +3 -1
- package/dist/build/ContextCommandBuilder.js +5 -1
- package/dist/build/EventBuilder.d.ts +1 -1
- package/dist/build/EventBuilder.js +1 -1
- package/dist/build/InhibitorBuilder.d.ts +2 -1
- package/dist/build/InhibitorBuilder.js +1 -1
- package/dist/build/MessageCommandBuilder.d.ts +1 -1
- package/dist/build/MessageCommandBuilder.js +1 -1
- package/dist/build/SlashCommandBuilder.d.ts +6 -2
- package/dist/build/SlashCommandBuilder.js +20 -12
- package/dist/build/XContextCommandBuilder.d.ts +40 -0
- package/dist/build/XContextCommandBuilder.js +84 -0
- package/dist/build/XEventBuilder.d.ts +17 -0
- package/dist/build/XEventBuilder.js +35 -0
- package/dist/build/XInhibitorBuilder.d.ts +20 -0
- package/dist/build/XInhibitorBuilder.js +28 -0
- package/dist/build/XMessageCommandBuilder.d.ts +42 -0
- package/dist/build/XMessageCommandBuilder.js +80 -0
- package/dist/build/XSlashCommandBuilder.d.ts +36 -0
- package/dist/build/XSlashCommandBuilder.js +114 -0
- package/dist/client/XernerxClient.d.ts +1 -1
- package/dist/client/XernerxClient.js +1 -2
- package/dist/handlers/CommandHandler.d.ts +4 -5
- package/dist/handlers/CommandHandler.js +2 -2
- package/dist/handlers/EventHandler.d.ts +4 -5
- package/dist/handlers/EventHandler.js +1 -1
- package/dist/handlers/Handler.d.ts +25 -6
- package/dist/handlers/Handler.js +41 -36
- package/dist/handlers/InhibitorHandler.d.ts +2 -3
- package/dist/main.d.ts +5 -71
- package/dist/main.js +6 -11
- package/dist/models/CommandArguments.d.ts +2 -2
- package/dist/models/CommandArguments.js +4 -2
- package/dist/models/Events.d.ts +5 -5
- package/dist/models/Events.js +69 -24
- package/dist/models/Extensions.d.ts +4 -3
- package/dist/models/Extensions.js +5 -3
- package/dist/tools/package.d.ts +3 -3
- package/dist/tools/package.js +31 -35
- package/dist/types/enums.js +4 -4
- package/dist/types/options.d.ts +3 -2
- package/dist/utils/ClientUtil.d.ts +1 -1
- package/dist/utils/ClientUtil.js +0 -11
- package/dist/utils/CommandUtil.d.ts +12 -6
- package/dist/utils/CommandUtil.js +26 -14
- package/dist/validators/CommandValidations.d.ts +7 -0
- package/dist/validators/CommandValidations.js +185 -0
- package/dist/validators/InhibitorValidations.d.ts +11 -0
- package/dist/validators/InhibitorValidations.js +42 -0
- package/package.json +1 -1
package/dist/models/Events.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { GatewayVersion, InteractionType, REST, Routes } from 'discord.js';
|
|
2
2
|
import { InteractionCommandUtil, MessageCommandUtil } from '../utils/CommandUtil.js';
|
|
3
3
|
import { InteractionArguments, messageArguments } from './CommandArguments.js';
|
|
4
|
-
import commandValidation from '
|
|
4
|
+
import commandValidation from '../validators/CommandValidations.js';
|
|
5
5
|
import { Style } from 'dumfunctions';
|
|
6
|
-
import { InhibitorValidation } from '
|
|
6
|
+
import { InhibitorValidation } from '../validators/InhibitorValidations.js';
|
|
7
7
|
export class MessageCommandEvents {
|
|
8
8
|
client;
|
|
9
9
|
constructor(client) {
|
|
@@ -28,7 +28,9 @@ export class MessageCommandEvents {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
if (this.client.handlerOptions.message?.prefix) {
|
|
31
|
-
const prefix = Array.isArray(this.client.handlerOptions.message.prefix)
|
|
31
|
+
const prefix = Array.isArray(this.client.handlerOptions.message.prefix)
|
|
32
|
+
? this.client.handlerOptions.message.prefix
|
|
33
|
+
: [this.client.handlerOptions.message.prefix];
|
|
32
34
|
prefix.map((prefix) => {
|
|
33
35
|
if (message.content.startsWith(prefix)) {
|
|
34
36
|
command = message.content.replace(prefix, '').split(/ +/).shift();
|
|
@@ -37,13 +39,17 @@ export class MessageCommandEvents {
|
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
if (this.client.handlerOptions.message?.allowMention) {
|
|
40
|
-
if (message.mentions.users.has(this.client.user?.id) ||
|
|
42
|
+
if (message.mentions.users.has(this.client.user?.id) ||
|
|
43
|
+
message.mentions.repliedUser?.id === this.client.user?.id) {
|
|
41
44
|
command = message.content.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift();
|
|
42
45
|
px = 'MentionPrefix';
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
|
-
const prefix = Array.isArray(this.client.handlerOptions.message?.prefix)
|
|
46
|
-
|
|
48
|
+
const prefix = Array.isArray(this.client.handlerOptions.message?.prefix)
|
|
49
|
+
? this.client.handlerOptions.message?.prefix
|
|
50
|
+
: [this.client.handlerOptions.message?.prefix];
|
|
51
|
+
if ((cmd.name.toLowerCase() == command?.toLowerCase() ||
|
|
52
|
+
cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
|
|
47
53
|
(cmd.prefix.includes(px) || prefix?.includes(px) || px === 'MentionPrefix')) {
|
|
48
54
|
try {
|
|
49
55
|
if (this.client.handlerOptions.message?.handleTyping)
|
|
@@ -53,7 +59,8 @@ export class MessageCommandEvents {
|
|
|
53
59
|
return;
|
|
54
60
|
if (await inhibitor.inhibit())
|
|
55
61
|
return;
|
|
56
|
-
if (cmd.conditions &&
|
|
62
|
+
if (cmd.conditions &&
|
|
63
|
+
(await cmd.conditions(message, (await messageArguments(message, cmd)))))
|
|
57
64
|
return;
|
|
58
65
|
await cmd.exec(message, (await messageArguments(message, cmd)));
|
|
59
66
|
this.client.emit('commandRun', message, cmd);
|
|
@@ -87,7 +94,9 @@ export class MessageCommandEvents {
|
|
|
87
94
|
});
|
|
88
95
|
}
|
|
89
96
|
if (this.client.handlerOptions.message?.prefix) {
|
|
90
|
-
const prefix = Array.isArray(this.client.handlerOptions.message.prefix)
|
|
97
|
+
const prefix = Array.isArray(this.client.handlerOptions.message.prefix)
|
|
98
|
+
? this.client.handlerOptions.message.prefix
|
|
99
|
+
: [this.client.handlerOptions.message.prefix];
|
|
91
100
|
prefix.map((prefix) => {
|
|
92
101
|
if (message?.content?.startsWith(prefix)) {
|
|
93
102
|
command = message.content.replace(prefix, '').split(/ +/).shift();
|
|
@@ -96,13 +105,17 @@ export class MessageCommandEvents {
|
|
|
96
105
|
});
|
|
97
106
|
}
|
|
98
107
|
if (this.client.handlerOptions.message?.allowMention) {
|
|
99
|
-
if (message.mentions.users.has(this.client.user?.id || '') ||
|
|
108
|
+
if (message.mentions.users.has(this.client.user?.id || '') ||
|
|
109
|
+
message.mentions.repliedUser?.id === this.client.user?.id) {
|
|
100
110
|
command = message?.content?.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift();
|
|
101
111
|
px = 'MentionPrefix';
|
|
102
112
|
}
|
|
103
113
|
}
|
|
104
|
-
const prefix = Array.isArray(this.client.handlerOptions.message?.prefix)
|
|
105
|
-
|
|
114
|
+
const prefix = Array.isArray(this.client.handlerOptions.message?.prefix)
|
|
115
|
+
? this.client.handlerOptions.message?.prefix
|
|
116
|
+
: [this.client.handlerOptions.message?.prefix];
|
|
117
|
+
if ((cmd.name.toLowerCase() == command?.toLowerCase() ||
|
|
118
|
+
cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
|
|
106
119
|
(cmd.prefix.includes(px) || prefix?.includes(px) || px === 'MentionPrefix')) {
|
|
107
120
|
try {
|
|
108
121
|
if (this.client.handlerOptions.message?.handleTyping)
|
|
@@ -113,7 +126,8 @@ export class MessageCommandEvents {
|
|
|
113
126
|
return;
|
|
114
127
|
if (await inhibitor.inhibit())
|
|
115
128
|
return;
|
|
116
|
-
if (cmd.conditions &&
|
|
129
|
+
if (cmd.conditions &&
|
|
130
|
+
(await cmd.conditions(message, (await messageArguments(message, cmd)))))
|
|
117
131
|
return;
|
|
118
132
|
await cmd.exec(message, (await messageArguments(message, cmd)));
|
|
119
133
|
this.client.emit('commandRun', message, cmd);
|
|
@@ -128,7 +142,8 @@ export class MessageCommandEvents {
|
|
|
128
142
|
}
|
|
129
143
|
messageDelete() {
|
|
130
144
|
this.client.on('messageDelete', async (message) => {
|
|
131
|
-
if (this.client.cache.messages.has(message.id) &&
|
|
145
|
+
if (this.client.cache.messages.has(message.id) &&
|
|
146
|
+
this.client.handlerOptions.message?.handleDeletes) {
|
|
132
147
|
try {
|
|
133
148
|
if (this.client.handlerOptions.message?.handleTyping)
|
|
134
149
|
message.channel.sendTyping();
|
|
@@ -163,12 +178,27 @@ export class SlashCommandEvents {
|
|
|
163
178
|
if (commandValidation(interaction, command, this.client))
|
|
164
179
|
return;
|
|
165
180
|
if (command.defer?.reply !== false && this.client.handlerOptions.slash?.defer?.reply)
|
|
166
|
-
await interaction.deferReply({
|
|
181
|
+
await interaction.deferReply({
|
|
182
|
+
ephemeral: this.client.handlerOptions.slash?.defer?.ephemeral,
|
|
183
|
+
fetchReply: this.client.handlerOptions.slash?.defer?.fetchReply,
|
|
184
|
+
});
|
|
167
185
|
if (!(interaction.deferred || interaction.replied) && command.defer?.reply)
|
|
168
|
-
await interaction.deferReply({
|
|
169
|
-
|
|
186
|
+
await interaction.deferReply({
|
|
187
|
+
ephemeral: command.defer?.ephemeral,
|
|
188
|
+
fetchReply: command.defer?.fetchReply,
|
|
189
|
+
});
|
|
190
|
+
if (command.conditions &&
|
|
191
|
+
(await command.conditions(interaction, {
|
|
192
|
+
group: argumentsInfo.group(),
|
|
193
|
+
subcommand: argumentsInfo.subcommand(),
|
|
194
|
+
args: await argumentsInfo.arguments(),
|
|
195
|
+
})))
|
|
170
196
|
return;
|
|
171
|
-
await command.exec(interaction, {
|
|
197
|
+
await command.exec(interaction, {
|
|
198
|
+
group: argumentsInfo.group(),
|
|
199
|
+
subcommand: argumentsInfo.subcommand(),
|
|
200
|
+
args: await argumentsInfo.arguments(),
|
|
201
|
+
});
|
|
172
202
|
this.client.emit('commandRun', interaction, command);
|
|
173
203
|
}
|
|
174
204
|
catch (error) {
|
|
@@ -200,9 +230,15 @@ export class ContextCommandEvents {
|
|
|
200
230
|
if (command.conditions && (await command.conditions(interaction)))
|
|
201
231
|
return;
|
|
202
232
|
if (command.defer?.reply !== false && this.client.handlerOptions.context?.defer?.reply)
|
|
203
|
-
await interaction.deferReply({
|
|
233
|
+
await interaction.deferReply({
|
|
234
|
+
ephemeral: this.client.handlerOptions.context?.defer?.ephemeral,
|
|
235
|
+
fetchReply: this.client.handlerOptions.context?.defer?.fetchReply,
|
|
236
|
+
});
|
|
204
237
|
if (!(interaction.deferred || interaction.replied) && command.defer?.reply)
|
|
205
|
-
await interaction.deferReply({
|
|
238
|
+
await interaction.deferReply({
|
|
239
|
+
ephemeral: command.defer?.ephemeral,
|
|
240
|
+
fetchReply: command.defer?.fetchReply,
|
|
241
|
+
});
|
|
206
242
|
await command.exec(interaction);
|
|
207
243
|
this.client.emit('commandRun', interaction, command);
|
|
208
244
|
}
|
|
@@ -222,11 +258,17 @@ export class CommandsDeploy {
|
|
|
222
258
|
deploy() {
|
|
223
259
|
this.client.once('ready', async (client) => {
|
|
224
260
|
const slashCommands = [], contextCommands = [];
|
|
225
|
-
this.client.commands.context.map((command) =>
|
|
261
|
+
this.client.commands.context.map((command) => command.data ? contextCommands.push(command.data.toJSON()) : null);
|
|
226
262
|
this.client.commands.slash.map((command) => (command.data ? slashCommands.push(command.data.toJSON()) : null));
|
|
227
263
|
try {
|
|
228
|
-
const global = {
|
|
229
|
-
|
|
264
|
+
const global = {
|
|
265
|
+
slash: this.client.handlerOptions.slash?.global,
|
|
266
|
+
context: this.client.handlerOptions.context?.global,
|
|
267
|
+
};
|
|
268
|
+
const guild = {
|
|
269
|
+
slash: this.client.handlerOptions.slash?.guildId,
|
|
270
|
+
context: this.client.handlerOptions.context?.guildId,
|
|
271
|
+
};
|
|
230
272
|
if (global.slash && global.context) {
|
|
231
273
|
if (guild.slash !== guild.context)
|
|
232
274
|
console.info(Style.log(`Xernerx | Warning: slash and context commands are both set to global, but don't have a matching guildId, using ${(await this.client.guilds.fetch(this.client.handlerOptions.slash?.guildId)).name}!`, { color: Style.TextColor.Red }));
|
|
@@ -242,10 +284,13 @@ export class CommandsDeploy {
|
|
|
242
284
|
if (global.slash === false && global.context === false) {
|
|
243
285
|
this.put('guild', guild.slash, [...contextCommands, ...slashCommands]);
|
|
244
286
|
}
|
|
245
|
-
|
|
287
|
+
if (this.client.handlerOptions.context?.logging || this.client.handlerOptions.slash?.logging)
|
|
288
|
+
console.info(Style.log(`Xernerx | Deployed ${slashCommands.length} slash commands ${global.slash ? 'globally' : 'locally'} and ${contextCommands.length} context commands ${global.context ? 'globally' : 'locally'}.`, { color: Style.TextColor.Purple }));
|
|
246
289
|
}
|
|
247
290
|
catch (error) {
|
|
248
|
-
console.error(Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, {
|
|
291
|
+
console.error(Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, {
|
|
292
|
+
color: Style.BackgroundColor.Red,
|
|
293
|
+
}));
|
|
249
294
|
}
|
|
250
295
|
});
|
|
251
296
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import XernerxExtensionBuilder from 'xernerx-extension-builder';
|
|
2
|
+
import XernerxClient from '../client/XernerxClient.js';
|
|
2
3
|
export default class Extensions {
|
|
3
|
-
client
|
|
4
|
+
private client;
|
|
4
5
|
constructor(client: XernerxClient);
|
|
5
|
-
load(extensions: Array<
|
|
6
|
+
load(extensions: Array<XernerxExtensionBuilder>, logging?: boolean): Promise<void>;
|
|
6
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Style } from
|
|
1
|
+
import { Style } from 'dumfunctions';
|
|
2
2
|
export default class Extensions {
|
|
3
3
|
client;
|
|
4
4
|
constructor(client) {
|
|
@@ -6,13 +6,15 @@ export default class Extensions {
|
|
|
6
6
|
}
|
|
7
7
|
async load(extensions, logging = false) {
|
|
8
8
|
const exts = [];
|
|
9
|
-
extensions.map(extension => {
|
|
9
|
+
extensions.map((extension) => {
|
|
10
10
|
try {
|
|
11
11
|
this.client.extensions[extension.name] = extension;
|
|
12
12
|
exts.push(extension.name);
|
|
13
13
|
}
|
|
14
14
|
catch (error) {
|
|
15
|
-
console.error(Style.log(`Xernerx | An error occurred trying to load ${extension.name}, error: <${error}>`, {
|
|
15
|
+
console.error(Style.log(`Xernerx | An error occurred trying to load ${extension.name}, error: <${error}>`, {
|
|
16
|
+
color: Style.BackgroundColor.Red,
|
|
17
|
+
}));
|
|
16
18
|
}
|
|
17
19
|
});
|
|
18
20
|
if (logging)
|
package/dist/tools/package.d.ts
CHANGED
|
@@ -26,10 +26,10 @@ declare const _default: {
|
|
|
26
26
|
url: string;
|
|
27
27
|
};
|
|
28
28
|
dependencies: {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
'@sapphire/shapeshift': string;
|
|
30
|
+
'discord.js': string;
|
|
31
31
|
dumfunctions: string;
|
|
32
|
-
|
|
32
|
+
'xernerx-extension-builder': string;
|
|
33
33
|
};
|
|
34
34
|
devDependencies: {
|
|
35
35
|
typescript: string;
|
package/dist/tools/package.js
CHANGED
|
@@ -1,41 +1,37 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"major": "git add . && npm run commit && npm version major && npm publish && git push",
|
|
21
|
-
"site": "git add docs && npm run commit && git push",
|
|
22
|
-
"commit": "node ../scripts/commit.js",
|
|
23
|
-
"package": "node ../scripts/rewritePackage.js"
|
|
2
|
+
name: 'xernerx',
|
|
3
|
+
version: '3.3.7',
|
|
4
|
+
type: 'module',
|
|
5
|
+
description: 'A bot framework for discord.js.',
|
|
6
|
+
main: 'dist/main.js',
|
|
7
|
+
keywords: ['discord.js', 'discord', 'framework'],
|
|
8
|
+
author: 'Dummi',
|
|
9
|
+
license: 'MIT',
|
|
10
|
+
homepage: 'https://xernerx.github.io/xernerx/home.html',
|
|
11
|
+
packageManager: 'npm@8.5.5',
|
|
12
|
+
scripts: {
|
|
13
|
+
start: 'npm i && npm fund && npm audit fix --force && npm link && npm run package && tsc -w',
|
|
14
|
+
patch: 'git add . && npm run commit && npm version patch && npm publish && git push',
|
|
15
|
+
minor: 'git add . && npm run commit && npm version minor && npm publish && git push',
|
|
16
|
+
major: 'git add . && npm run commit && npm version major && npm publish && git push',
|
|
17
|
+
site: 'git add docs && npm run commit && git push',
|
|
18
|
+
commit: 'node ../.scripts/commit.js',
|
|
19
|
+
package: 'node ../.scripts/rewritePackage.js',
|
|
24
20
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
repository: {
|
|
22
|
+
type: 'git',
|
|
23
|
+
url: 'git+https://github.com/xernerx/xernerx.git',
|
|
28
24
|
},
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
bugs: {
|
|
26
|
+
url: 'https://github.com/xernerx/xernerx/issues',
|
|
31
27
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
dependencies: {
|
|
29
|
+
'@sapphire/shapeshift': '^3.8.1',
|
|
30
|
+
'discord.js': '^14.7.0',
|
|
31
|
+
dumfunctions: '^2.0.0',
|
|
32
|
+
'xernerx-extension-builder': '^0.0.2',
|
|
33
|
+
},
|
|
34
|
+
devDependencies: {
|
|
35
|
+
typescript: '^4.9.4',
|
|
37
36
|
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"typescript": "^4.9.4"
|
|
40
|
-
}
|
|
41
37
|
};
|
package/dist/types/enums.js
CHANGED
|
@@ -10,7 +10,7 @@ export var InhibitorType;
|
|
|
10
10
|
InhibitorType["Message"] = "Message";
|
|
11
11
|
InhibitorType["Interaction"] = "Interaction";
|
|
12
12
|
InhibitorType["Channel"] = "Channel";
|
|
13
|
-
})(InhibitorType
|
|
13
|
+
})(InhibitorType || (InhibitorType = {}));
|
|
14
14
|
export var CommandType;
|
|
15
15
|
(function (CommandType) {
|
|
16
16
|
CommandType["Message"] = "MessageCommand";
|
|
@@ -21,15 +21,15 @@ export var CommandType;
|
|
|
21
21
|
CommandType["MessageCommand"] = "MessageCommand";
|
|
22
22
|
CommandType["SlashCommand"] = "SlashCommand";
|
|
23
23
|
CommandType["ContextCommand"] = "ContextCommand";
|
|
24
|
-
})(CommandType
|
|
24
|
+
})(CommandType || (CommandType = {}));
|
|
25
25
|
export var ContextCommandType;
|
|
26
26
|
(function (ContextCommandType) {
|
|
27
27
|
ContextCommandType[ContextCommandType["Message"] = 3] = "Message";
|
|
28
28
|
ContextCommandType[ContextCommandType["User"] = 2] = "User";
|
|
29
|
-
})(ContextCommandType
|
|
29
|
+
})(ContextCommandType || (ContextCommandType = {}));
|
|
30
30
|
export var EventEmitterType;
|
|
31
31
|
(function (EventEmitterType) {
|
|
32
32
|
EventEmitterType["Client"] = "client";
|
|
33
33
|
EventEmitterType["Rest"] = "rest";
|
|
34
34
|
EventEmitterType["Process"] = "process";
|
|
35
|
-
})(EventEmitterType
|
|
35
|
+
})(EventEmitterType || (EventEmitterType = {}));
|
package/dist/types/options.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CacheFactory, ChannelType, ContextMenuCommandType, MessageMentionOptions, Partials, PresenceData, RESTOptions, SweeperOptions, WebSocketOptions } from 'discord.js';
|
|
2
|
-
import
|
|
2
|
+
import XernerxExtensionBuilder from 'xernerx-extension-builder';
|
|
3
|
+
import { ContextCommandType, EventEmitterType, InhibitorType } from './enums.js';
|
|
3
4
|
import { MessageCommandArgsTypes } from './types.js';
|
|
4
5
|
export interface DiscordOptions {
|
|
5
6
|
shards?: number | number[] | 'auto';
|
|
@@ -36,7 +37,7 @@ export interface HandlerOptions {
|
|
|
36
37
|
inhibitors?: InhibitorHandlerOptions;
|
|
37
38
|
}
|
|
38
39
|
export interface ExtensionOptions {
|
|
39
|
-
extensions: Array<
|
|
40
|
+
extensions: Array<XernerxExtensionBuilder>;
|
|
40
41
|
logging?: boolean;
|
|
41
42
|
}
|
|
42
43
|
export interface MessageCommandOptions {
|
package/dist/utils/ClientUtil.js
CHANGED
|
@@ -3,17 +3,6 @@ export class ClientUtil {
|
|
|
3
3
|
client;
|
|
4
4
|
constructor(client) {
|
|
5
5
|
this.client = client;
|
|
6
|
-
this.uptime = this.uptime;
|
|
7
|
-
this.getSubcommands = this.getSubcommands;
|
|
8
|
-
this.isOwner = this.isOwner;
|
|
9
|
-
this.getAllCommands = this.getAllCommands;
|
|
10
|
-
this.getAllMessageCommands = this.getAllMessageCommands;
|
|
11
|
-
this.getAllSlashCommands = this.getAllSlashCommands;
|
|
12
|
-
this.getAllContextCommands = this.getAllContextCommands;
|
|
13
|
-
this.setPresence = this.setPresence;
|
|
14
|
-
this.getCooldowns = this.getCooldowns;
|
|
15
|
-
this.getCooldownTimers = this.getCooldownTimers;
|
|
16
|
-
this.defer = this.defer;
|
|
17
6
|
}
|
|
18
7
|
uptime(timestamp) {
|
|
19
8
|
if (!timestamp)
|
|
@@ -25,26 +25,32 @@ interface ButtonOptions {
|
|
|
25
25
|
ephemeral?: boolean;
|
|
26
26
|
}
|
|
27
27
|
export declare class MessageCommandUtil {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
message: XernerxMessage;
|
|
28
|
+
private client;
|
|
29
|
+
private message;
|
|
31
30
|
constructor(client: XernerxClient, message: Message & XernerxMessage);
|
|
32
31
|
reply(content: MessagePayload | string): Promise<Message<boolean> | undefined>;
|
|
33
32
|
send(content: MessagePayload | string): Promise<Message<true> | Message<false> | undefined>;
|
|
34
33
|
defer(time: number): Promise<unknown>;
|
|
35
34
|
getCommands(): import("@discordjs/collection").Collection<string, import("../main.js").MessageCommandBuilder>;
|
|
35
|
+
getCommandName(): void;
|
|
36
|
+
selectMenuPaginator(embeds: Array<EmbedBuilder>, options?: SelectMenuOptions): void;
|
|
37
|
+
buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
|
|
38
|
+
buttonMenuPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions & SelectMenuOptions): void;
|
|
36
39
|
isOwner(): boolean;
|
|
40
|
+
createModal(): void;
|
|
37
41
|
}
|
|
38
42
|
export declare class InteractionCommandUtil {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
interaction: any;
|
|
43
|
+
private client;
|
|
44
|
+
private interaction;
|
|
42
45
|
constructor(client: XernerxClient, interaction: Interaction);
|
|
43
46
|
reply(content: MessagePayload | string): any;
|
|
44
47
|
defer(time: number): Promise<unknown>;
|
|
45
48
|
getCommands(): import("@discordjs/collection").Collection<string, import("../main.js").SlashCommandBuilder> | import("@discordjs/collection").Collection<string, import("../main.js").ContextCommandBuilder>;
|
|
49
|
+
getCommandName(): void;
|
|
46
50
|
selectMenuPaginator(embeds: Array<EmbedBuilder>, options?: SelectMenuOptions): void;
|
|
47
51
|
buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
|
|
52
|
+
buttonMenuPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions & SelectMenuOptions): void;
|
|
48
53
|
isOwner(): boolean;
|
|
54
|
+
createModal(): void;
|
|
49
55
|
}
|
|
50
56
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, StringSelectMenuBuilder } from 'discord.js';
|
|
1
|
+
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, StringSelectMenuBuilder, } from 'discord.js';
|
|
2
2
|
import XernerxError from '../tools/XernerxError.js';
|
|
3
3
|
export class MessageCommandUtil {
|
|
4
4
|
client;
|
|
@@ -77,14 +77,14 @@ export class MessageCommandUtil {
|
|
|
77
77
|
getCommands() {
|
|
78
78
|
return this.client.commands.message;
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
getCommandName() { }
|
|
81
|
+
selectMenuPaginator(embeds, options) { }
|
|
82
|
+
buttonPaginator(embeds, options) { }
|
|
83
|
+
buttonMenuPaginator(embeds, options) { }
|
|
84
84
|
isOwner() {
|
|
85
85
|
return this.client.util.isOwner(this.message.author.id);
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
createModal() { }
|
|
88
88
|
}
|
|
89
89
|
export class InteractionCommandUtil {
|
|
90
90
|
client;
|
|
@@ -94,7 +94,9 @@ export class InteractionCommandUtil {
|
|
|
94
94
|
this.interaction = interaction;
|
|
95
95
|
}
|
|
96
96
|
reply(content) {
|
|
97
|
-
return this.interaction.replied || this.interaction.deferred
|
|
97
|
+
return this.interaction.replied || this.interaction.deferred
|
|
98
|
+
? this.interaction.editReply(content)
|
|
99
|
+
: this.interaction.reply(content);
|
|
98
100
|
}
|
|
99
101
|
async defer(time) {
|
|
100
102
|
return new Promise((resolve) => setTimeout(resolve, time));
|
|
@@ -105,7 +107,7 @@ export class InteractionCommandUtil {
|
|
|
105
107
|
else
|
|
106
108
|
return this.client.commands.context;
|
|
107
109
|
}
|
|
108
|
-
|
|
110
|
+
getCommandName() { }
|
|
109
111
|
selectMenuPaginator(embeds, options) {
|
|
110
112
|
if (!Array.isArray(embeds))
|
|
111
113
|
throw new XernerxError(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
|
|
@@ -131,7 +133,12 @@ export class InteractionCommandUtil {
|
|
|
131
133
|
options.row = new ActionRowBuilder();
|
|
132
134
|
if (!options.id)
|
|
133
135
|
options.id = `${this.interaction.id}-menu`;
|
|
134
|
-
options.component = new StringSelectMenuBuilder()
|
|
136
|
+
options.component = new StringSelectMenuBuilder()
|
|
137
|
+
.setCustomId(options.id)
|
|
138
|
+
.setMaxValues(1)
|
|
139
|
+
.setMinValues(1)
|
|
140
|
+
.setPlaceholder('Select a page.')
|
|
141
|
+
.addOptions({ label: 'index', value: '0' });
|
|
135
142
|
embeds.map((embed, i = 0) => {
|
|
136
143
|
options?.component?.addOptions({
|
|
137
144
|
label: embed.data.title || 'No Name',
|
|
@@ -147,7 +154,9 @@ export class InteractionCommandUtil {
|
|
|
147
154
|
components: [options.row, ...options.components],
|
|
148
155
|
ephemeral: !!options.ephemeral,
|
|
149
156
|
};
|
|
150
|
-
(options.reply === undefined || options.reply === true
|
|
157
|
+
(options.reply === undefined || options.reply === true
|
|
158
|
+
? this.interaction.util.reply(content)
|
|
159
|
+
: this.interaction.channel.send(content)).then(() => {
|
|
151
160
|
const collector = this.interaction.channel
|
|
152
161
|
.createMessageComponentCollector({
|
|
153
162
|
filter: options?.filter,
|
|
@@ -193,7 +202,9 @@ export class InteractionCommandUtil {
|
|
|
193
202
|
components: [options.row, ...options.components],
|
|
194
203
|
ephemeral: !!options.ephemeral,
|
|
195
204
|
};
|
|
196
|
-
(options.reply === undefined || options.reply === true
|
|
205
|
+
(options.reply === undefined || options.reply === true
|
|
206
|
+
? this.interaction.util.reply(content)
|
|
207
|
+
: this.interaction.channel.send(content)).then((message) => {
|
|
197
208
|
const collector = message.channel
|
|
198
209
|
.createMessageComponentCollector({
|
|
199
210
|
filter: options.filter,
|
|
@@ -217,7 +228,8 @@ export class InteractionCommandUtil {
|
|
|
217
228
|
break;
|
|
218
229
|
}
|
|
219
230
|
case 3: {
|
|
220
|
-
embed =
|
|
231
|
+
embed =
|
|
232
|
+
embeds[embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1];
|
|
221
233
|
break;
|
|
222
234
|
}
|
|
223
235
|
case 4: {
|
|
@@ -240,9 +252,9 @@ export class InteractionCommandUtil {
|
|
|
240
252
|
});
|
|
241
253
|
});
|
|
242
254
|
}
|
|
243
|
-
|
|
255
|
+
buttonMenuPaginator(embeds, options) { }
|
|
244
256
|
isOwner() {
|
|
245
257
|
return this.client.util.isOwner(this.interaction.user.id);
|
|
246
258
|
}
|
|
247
|
-
|
|
259
|
+
createModal() { }
|
|
248
260
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Interaction } from 'discord.js';
|
|
2
|
+
import ContextCommandBuilder from '../build/ContextCommandBuilder.js';
|
|
3
|
+
import MessageCommandBuilder from '../build/MessageCommandBuilder.js';
|
|
4
|
+
import SlashCommandBuilder from '../build/SlashCommandBuilder.js';
|
|
5
|
+
import XernerxClient from '../client/XernerxClient.js';
|
|
6
|
+
import { XernerxMessage } from '../types/types.js';
|
|
7
|
+
export default function commandValidation(action: XernerxMessage | Interaction, command: SlashCommandBuilder | MessageCommandBuilder | ContextCommandBuilder | any, client: XernerxClient, res?: boolean): boolean;
|