xernerx 4.0.2 → 4.0.3
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.
|
@@ -2,18 +2,19 @@ import XernerxClient from '../client/XernerxClient.js';
|
|
|
2
2
|
import { XernerxMessage } from '../types/extenders.js';
|
|
3
3
|
import { MessageCommandArguments, MessageCommandOptions } from '../types/interfaces.js';
|
|
4
4
|
export default class MessageCommandBuilder {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly aliases: string[] | undefined;
|
|
8
|
+
readonly regex: RegExp | undefined;
|
|
9
|
+
readonly prefix: string | string[] | undefined;
|
|
10
|
+
readonly description: string | null | undefined;
|
|
11
|
+
readonly info: string | null | undefined;
|
|
12
|
+
readonly separator: string | undefined;
|
|
13
|
+
readonly args: import('../types/interfaces.js').MessageCommandArgumentOptions[] | undefined;
|
|
14
|
+
readonly flags: import('../types/interfaces.js').MessageCommandFlagOptions[] | undefined;
|
|
15
|
+
readonly category: string | null | undefined;
|
|
16
|
+
readonly cooldown: number | null | undefined;
|
|
17
|
+
readonly ignore:
|
|
17
18
|
| {
|
|
18
19
|
owner?: boolean | undefined;
|
|
19
20
|
users?: string[] | undefined;
|
|
@@ -21,7 +22,7 @@ export default class MessageCommandBuilder {
|
|
|
21
22
|
guilds?: string[] | undefined;
|
|
22
23
|
}
|
|
23
24
|
| undefined;
|
|
24
|
-
strict:
|
|
25
|
+
readonly strict:
|
|
25
26
|
| {
|
|
26
27
|
owner?: boolean | undefined;
|
|
27
28
|
users?: string[] | undefined;
|
|
@@ -29,14 +30,14 @@ export default class MessageCommandBuilder {
|
|
|
29
30
|
guilds?: string[] | undefined;
|
|
30
31
|
}
|
|
31
32
|
| undefined;
|
|
32
|
-
permissions:
|
|
33
|
+
readonly permissions:
|
|
33
34
|
| {
|
|
34
35
|
user?: string[] | import('../types/types.js').PermissionNames[] | undefined;
|
|
35
36
|
client?: string[] | import('../types/types.js').PermissionNames[] | undefined;
|
|
36
37
|
dm?: boolean | undefined;
|
|
37
38
|
}
|
|
38
39
|
| undefined;
|
|
39
|
-
client: typeof XernerxClient;
|
|
40
|
+
readonly client: typeof XernerxClient;
|
|
40
41
|
constructor(id: string, options: MessageCommandOptions);
|
|
41
42
|
conditions(message: XernerxMessage, args: MessageCommandArguments): Promise<void>;
|
|
42
43
|
exec(message: XernerxMessage, args: MessageCommandArguments): Promise<void>;
|
|
@@ -3,6 +3,7 @@ import XernerxClient from '../client/XernerxClient.js';
|
|
|
3
3
|
export default class MessageCommandBuilder {
|
|
4
4
|
id;
|
|
5
5
|
name;
|
|
6
|
+
aliases;
|
|
6
7
|
regex;
|
|
7
8
|
prefix;
|
|
8
9
|
description;
|
|
@@ -24,6 +25,7 @@ export default class MessageCommandBuilder {
|
|
|
24
25
|
options = z
|
|
25
26
|
.object({
|
|
26
27
|
name: z.string(),
|
|
28
|
+
aliases: z.array(z.string()).default([]),
|
|
27
29
|
description: z.string().or(z.null()).default(null),
|
|
28
30
|
info: z.string().or(z.null()).default(null),
|
|
29
31
|
category: z.string().or(z.null()).default(null),
|
|
@@ -55,6 +57,7 @@ export default class MessageCommandBuilder {
|
|
|
55
57
|
})
|
|
56
58
|
.parse(options);
|
|
57
59
|
this.name = options.name;
|
|
60
|
+
this.aliases = options.aliases;
|
|
58
61
|
this.prefix = options.prefix;
|
|
59
62
|
this.description = options.description;
|
|
60
63
|
this.info = options.info;
|
|
@@ -153,7 +153,9 @@ export default class CommandHandler extends Handler {
|
|
|
153
153
|
if (message.content && this.client.modules.options.message) {
|
|
154
154
|
const commands = this.client.commands.message;
|
|
155
155
|
const prefixes = Array.isArray(this.client.modules.options.message.prefix) ? this.client.modules.options.message.prefix : [this.client.modules.options.message.prefix];
|
|
156
|
-
let commandName,
|
|
156
|
+
let commandName,
|
|
157
|
+
cmd,
|
|
158
|
+
alias = null;
|
|
157
159
|
commands.map((command) => {
|
|
158
160
|
let prefix = null;
|
|
159
161
|
if (command.regex && message.content.match(command.regex)) {
|
|
@@ -169,12 +171,17 @@ export default class CommandHandler extends Handler {
|
|
|
169
171
|
});
|
|
170
172
|
if (!prefix) return;
|
|
171
173
|
if (!commandName)
|
|
172
|
-
commandName =
|
|
173
|
-
.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
commandName =
|
|
175
|
+
message.content
|
|
176
|
+
.replace(prefix, '')
|
|
177
|
+
.split(command.separator || / +/)
|
|
178
|
+
.shift()
|
|
179
|
+
?.trim()
|
|
180
|
+
?.toLowerCase() || '';
|
|
181
|
+
if (!this.client.commands.message.has(commandName) && command.aliases?.includes(commandName)) {
|
|
182
|
+
alias = commandName;
|
|
183
|
+
commandName = command.name;
|
|
184
|
+
}
|
|
178
185
|
});
|
|
179
186
|
if (!cmd && this.client.modules.options.message.allowMention) {
|
|
180
187
|
if (message.mentions.users.has(this.client.user?.id) || message.mentions.repliedUser?.id === this.client.user?.id) {
|
|
@@ -185,6 +192,7 @@ export default class CommandHandler extends Handler {
|
|
|
185
192
|
if (this.client.commands.message.has(commandName)) cmd = this.client.commands.message.get(commandName);
|
|
186
193
|
if (await inhibitorValidation(message, cmd)) return;
|
|
187
194
|
if (!cmd) return this.client.emit('commandNotFound');
|
|
195
|
+
message.util.alias = alias === commandName ? null : alias;
|
|
188
196
|
this.exec(cmd, message, await messageArguments(message, cmd), 'MessageCommand');
|
|
189
197
|
}
|
|
190
198
|
}
|
|
@@ -3,7 +3,8 @@ import XernerxClient from '../client/XernerxClient.js';
|
|
|
3
3
|
import { XernerxMessage } from '../types/extenders.js';
|
|
4
4
|
import Util from './Util.js';
|
|
5
5
|
export default class MessageUtil extends Util {
|
|
6
|
-
private message;
|
|
6
|
+
private readonly message;
|
|
7
|
+
alias: string | null;
|
|
7
8
|
constructor(client: XernerxClient, message: XernerxMessage);
|
|
8
9
|
reply(content: MessagePayload): Promise<import('discord.js').Message<boolean> | undefined>;
|
|
9
10
|
webhookReply(content: MessagePayload, url?: URL, user?: User): Promise<void>;
|
|
@@ -5,9 +5,11 @@ import sendWebhook from '../functions/sendWebhook.js';
|
|
|
5
5
|
import XernerxError from '../tools/XernerxError.js';
|
|
6
6
|
export default class MessageUtil extends Util {
|
|
7
7
|
message;
|
|
8
|
+
alias;
|
|
8
9
|
constructor(client, message) {
|
|
9
10
|
super(client);
|
|
10
11
|
this.message = message;
|
|
12
|
+
this.alias = null;
|
|
11
13
|
}
|
|
12
14
|
async reply(content) {
|
|
13
15
|
if (this.client.cache.messages.has(this.message.id)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xernerx",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "A bot framework for discord.js.",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"major": "npm run write && git add . && npm run commit && npm version major && npm publish && git push",
|
|
25
25
|
"site": "git add docs && npm run commit && git push",
|
|
26
26
|
"commit": "node ../.scripts/commit.js",
|
|
27
|
-
"write": "npm run build && npm run format
|
|
27
|
+
"write": "npm run build && npm run format",
|
|
28
28
|
"format": "npx prettier --write src dist",
|
|
29
29
|
"build": "tsc && npm run format"
|
|
30
30
|
},
|