xernerx 4.2.1 → 4.3.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/LICENSE +21 -21
- package/dist/build/ContextCommandBuilder.d.ts +14 -13
- package/dist/build/ContextCommandBuilder.js +2 -13
- package/dist/build/EventBuilder.d.ts +7 -7
- package/dist/build/EventBuilder.js +0 -6
- package/dist/build/InhibitorBuilder.d.ts +5 -5
- package/dist/build/InhibitorBuilder.js +0 -4
- package/dist/build/MessageCommandBuilder.d.ts +1 -0
- package/dist/build/MessageCommandBuilder.js +2 -16
- package/dist/build/SlashCommandBuilder.d.ts +13 -12
- package/dist/build/SlashCommandBuilder.js +2 -12
- package/dist/client/XernerxClient.d.ts +2 -2
- package/dist/client/XernerxClient.js +2 -2
- package/dist/handlers/ExtensionHandler.js +3 -1
- package/dist/handlers/WebhookHandler.js +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.js +1 -1
- package/dist/types/interfaces.d.ts +3 -2
- package/dist/utils/ClientUtil.d.ts +1 -0
- package/dist/utils/ClientUtil.js +10 -0
- package/package.json +2 -2
- package/dist/cjs/build/ContextCommandBuilder.d.ts +0 -68
- package/dist/cjs/build/ContextCommandBuilder.js +0 -97
- package/dist/cjs/build/EventBuilder.d.ts +0 -21
- package/dist/cjs/build/EventBuilder.js +0 -44
- package/dist/cjs/build/InhibitorBuilder.d.ts +0 -19
- package/dist/cjs/build/InhibitorBuilder.js +0 -37
- package/dist/cjs/build/MessageCommandBuilder.d.ts +0 -59
- package/dist/cjs/build/MessageCommandBuilder.js +0 -100
- package/dist/cjs/build/SlashCommandBuilder.d.ts +0 -64
- package/dist/cjs/build/SlashCommandBuilder.js +0 -168
- package/dist/cjs/client/XernerxClient.d.ts +0 -28
- package/dist/cjs/client/XernerxClient.js +0 -116
- package/dist/cjs/handlers/CommandHandler.d.ts +0 -27
- package/dist/cjs/handlers/CommandHandler.js +0 -45
- package/dist/cjs/handlers/EventHandler.d.ts +0 -13
- package/dist/cjs/handlers/EventHandler.js +0 -19
- package/dist/cjs/handlers/Handler.d.ts +0 -57
- package/dist/cjs/handlers/Handler.js +0 -308
- package/dist/cjs/handlers/InhibitorHandler.d.ts +0 -18
- package/dist/cjs/handlers/InhibitorHandler.js +0 -24
- package/dist/cjs/main.d.ts +0 -44
- package/dist/cjs/main.js +0 -112
- package/dist/cjs/models/CommandArguments.d.ts +0 -17
- package/dist/cjs/models/CommandArguments.js +0 -106
- package/dist/cjs/models/Events.d.ts +0 -24
- package/dist/cjs/models/Events.js +0 -307
- package/dist/cjs/models/Extensions.d.ts +0 -7
- package/dist/cjs/models/Extensions.js +0 -26
- package/dist/cjs/tools/XernerxError.d.ts +0 -5
- package/dist/cjs/tools/XernerxError.js +0 -11
- package/dist/cjs/tools/package.d.ts +0 -49
- package/dist/cjs/tools/package.js +0 -50
- package/dist/cjs/types/enums.d.ts +0 -44
- package/dist/cjs/types/enums.js +0 -38
- package/dist/cjs/types/interfaces.d.ts +0 -25
- package/dist/cjs/types/interfaces.js +0 -2
- package/dist/cjs/types/options.d.ts +0 -241
- package/dist/cjs/types/options.js +0 -2
- package/dist/cjs/types/types.d.ts +0 -61
- package/dist/cjs/types/types.js +0 -2
- package/dist/cjs/utils/ClientUtil.d.ts +0 -25
- package/dist/cjs/utils/ClientUtil.js +0 -211
- package/dist/cjs/utils/CommandUtil.d.ts +0 -58
- package/dist/cjs/utils/CommandUtil.js +0 -247
- package/dist/cjs/validators/CommandValidations.d.ts +0 -12
- package/dist/cjs/validators/CommandValidations.js +0 -169
- package/dist/cjs/validators/InhibitorValidations.d.ts +0 -11
- package/dist/cjs/validators/InhibitorValidations.js +0 -40
- package/dist/mjs/build/ContextCommandBuilder.d.ts +0 -68
- package/dist/mjs/build/ContextCommandBuilder.js +0 -88
- package/dist/mjs/build/EventBuilder.d.ts +0 -21
- package/dist/mjs/build/EventBuilder.js +0 -34
- package/dist/mjs/build/InhibitorBuilder.d.ts +0 -19
- package/dist/mjs/build/InhibitorBuilder.js +0 -27
- package/dist/mjs/build/MessageCommandBuilder.d.ts +0 -59
- package/dist/mjs/build/MessageCommandBuilder.js +0 -90
- package/dist/mjs/build/SlashCommandBuilder.d.ts +0 -64
- package/dist/mjs/build/SlashCommandBuilder.js +0 -121
- package/dist/mjs/client/XernerxClient.d.ts +0 -28
- package/dist/mjs/client/XernerxClient.js +0 -108
- package/dist/mjs/handlers/CommandHandler.d.ts +0 -27
- package/dist/mjs/handlers/CommandHandler.js +0 -42
- package/dist/mjs/handlers/EventHandler.d.ts +0 -13
- package/dist/mjs/handlers/EventHandler.js +0 -16
- package/dist/mjs/handlers/Handler.d.ts +0 -57
- package/dist/mjs/handlers/Handler.js +0 -260
- package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -18
- package/dist/mjs/handlers/InhibitorHandler.js +0 -21
- package/dist/mjs/main.d.ts +0 -44
- package/dist/mjs/main.js +0 -52
- package/dist/mjs/models/CommandArguments.d.ts +0 -17
- package/dist/mjs/models/CommandArguments.js +0 -101
- package/dist/mjs/models/Events.d.ts +0 -24
- package/dist/mjs/models/Events.js +0 -295
- package/dist/mjs/models/Extensions.d.ts +0 -7
- package/dist/mjs/models/Extensions.js +0 -23
- package/dist/mjs/tools/XernerxError.d.ts +0 -5
- package/dist/mjs/tools/XernerxError.js +0 -8
- package/dist/mjs/tools/package.d.ts +0 -49
- package/dist/mjs/tools/package.js +0 -48
- package/dist/mjs/types/enums.d.ts +0 -44
- package/dist/mjs/types/enums.js +0 -35
- package/dist/mjs/types/interfaces.d.ts +0 -25
- package/dist/mjs/types/interfaces.js +0 -1
- package/dist/mjs/types/options.d.ts +0 -241
- package/dist/mjs/types/options.js +0 -1
- package/dist/mjs/types/types.d.ts +0 -61
- package/dist/mjs/types/types.js +0 -1
- package/dist/mjs/utils/ClientUtil.d.ts +0 -25
- package/dist/mjs/utils/ClientUtil.js +0 -202
- package/dist/mjs/utils/CommandUtil.d.ts +0 -58
- package/dist/mjs/utils/CommandUtil.js +0 -232
- package/dist/mjs/validators/CommandValidations.d.ts +0 -12
- package/dist/mjs/validators/CommandValidations.js +0 -166
- package/dist/mjs/validators/InhibitorValidations.d.ts +0 -11
- package/dist/mjs/validators/InhibitorValidations.js +0 -36
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
3
|
-
/**
|
|
4
|
-
* @description - The event builder for events.
|
|
5
|
-
* @param {String} id - The unique ID of the event.
|
|
6
|
-
* @param {EventOptions} options - The event options.
|
|
7
|
-
*/
|
|
8
|
-
export default class EventBuilder {
|
|
9
|
-
id;
|
|
10
|
-
name;
|
|
11
|
-
emitter;
|
|
12
|
-
type;
|
|
13
|
-
once;
|
|
14
|
-
client;
|
|
15
|
-
constructor(id, options) {
|
|
16
|
-
this.id = id;
|
|
17
|
-
z.object({
|
|
18
|
-
name: z.string(),
|
|
19
|
-
emitter: z.string().optional(),
|
|
20
|
-
type: z.string().optional(),
|
|
21
|
-
once: z.boolean().optional(),
|
|
22
|
-
}).parse(options);
|
|
23
|
-
this.name = options.name;
|
|
24
|
-
this.emitter = options.emitter || 'client';
|
|
25
|
-
this.type = options.type || 'discord';
|
|
26
|
-
this.once = options.once || false;
|
|
27
|
-
this.client = XernerxClient;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @description run your custom event here.
|
|
31
|
-
* TODO - update description
|
|
32
|
-
*/
|
|
33
|
-
async run() {}
|
|
34
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
2
|
-
import { InhibitorOptions, MessageArgumentOptions, SlashArgumentOptions } from '../types/options.js';
|
|
3
|
-
import { XernerxInteraction, XernerxMessage } from '../types/types.js';
|
|
4
|
-
/**
|
|
5
|
-
* @description - The inhibitor builder for inhibitors.
|
|
6
|
-
* @param {String} id - The unique ID of the inhibitor.
|
|
7
|
-
* @param {InhibitorOptions} options - The inhibitor options.
|
|
8
|
-
*/
|
|
9
|
-
export default class InhibitorBuilder {
|
|
10
|
-
id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
type: import('../main.js').InhibitorType;
|
|
13
|
-
client: typeof XernerxClient;
|
|
14
|
-
constructor(id: string, options: InhibitorOptions);
|
|
15
|
-
/**
|
|
16
|
-
* TODO - update description
|
|
17
|
-
*/
|
|
18
|
-
check(interaction: XernerxInteraction | XernerxMessage, args: SlashArgumentOptions | MessageArgumentOptions): Promise<void>;
|
|
19
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
3
|
-
/**
|
|
4
|
-
* @description - The inhibitor builder for inhibitors.
|
|
5
|
-
* @param {String} id - The unique ID of the inhibitor.
|
|
6
|
-
* @param {InhibitorOptions} options - The inhibitor options.
|
|
7
|
-
*/
|
|
8
|
-
export default class InhibitorBuilder {
|
|
9
|
-
id;
|
|
10
|
-
name;
|
|
11
|
-
type;
|
|
12
|
-
client;
|
|
13
|
-
constructor(id, options) {
|
|
14
|
-
this.id = id;
|
|
15
|
-
z.object({
|
|
16
|
-
name: z.string(),
|
|
17
|
-
type: z.string(),
|
|
18
|
-
}).parse(options);
|
|
19
|
-
this.name = options.name;
|
|
20
|
-
this.type = options.type;
|
|
21
|
-
this.client = XernerxClient;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* TODO - update description
|
|
25
|
-
*/
|
|
26
|
-
async check(interaction, args) {}
|
|
27
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { MessageArgumentOptions, MessageCommandOptions } from '../types/options.js';
|
|
2
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
3
|
-
import { XernerxMessage } from '../types/types.js';
|
|
4
|
-
/**
|
|
5
|
-
* @description - The command builder for message commands.
|
|
6
|
-
* @param {String} id - The unique ID of the command.
|
|
7
|
-
* @param {MessageCommandOptions} options - The command options.
|
|
8
|
-
*/
|
|
9
|
-
export default class MessageCommandBuilder {
|
|
10
|
-
id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
aliases: string[] | undefined;
|
|
13
|
-
separator: string;
|
|
14
|
-
description: string | undefined;
|
|
15
|
-
info: string | undefined;
|
|
16
|
-
category: string | undefined;
|
|
17
|
-
prefix: string[];
|
|
18
|
-
regex: string | undefined;
|
|
19
|
-
channelType: number[] | undefined;
|
|
20
|
-
ignore:
|
|
21
|
-
| {
|
|
22
|
-
owner?: boolean | undefined;
|
|
23
|
-
users?: string[] | undefined;
|
|
24
|
-
channels?: string[] | undefined;
|
|
25
|
-
guilds?: string[] | undefined;
|
|
26
|
-
}
|
|
27
|
-
| undefined;
|
|
28
|
-
strict:
|
|
29
|
-
| {
|
|
30
|
-
owner?: boolean | undefined;
|
|
31
|
-
users?: string[] | undefined;
|
|
32
|
-
channels?: string[] | undefined;
|
|
33
|
-
guilds?: string[] | undefined;
|
|
34
|
-
}
|
|
35
|
-
| undefined;
|
|
36
|
-
permissions:
|
|
37
|
-
| {
|
|
38
|
-
client?: string[] | undefined;
|
|
39
|
-
user?: string[] | undefined;
|
|
40
|
-
dm?: boolean | undefined;
|
|
41
|
-
}
|
|
42
|
-
| undefined;
|
|
43
|
-
cooldown: number;
|
|
44
|
-
args: MessageArgumentOptions[];
|
|
45
|
-
client: typeof XernerxClient;
|
|
46
|
-
constructor(id: string, options: MessageCommandOptions);
|
|
47
|
-
/**
|
|
48
|
-
* @param {Message} message - The Discord message event data.
|
|
49
|
-
* @param {object} args - The arguments you created.
|
|
50
|
-
* @description make any preconditions here.
|
|
51
|
-
*/
|
|
52
|
-
conditions(message: XernerxMessage, args: MessageArgumentOptions): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* @param {Message} message - The Discord message event data.
|
|
55
|
-
* @param {object} args - The arguments you created.
|
|
56
|
-
* @description Make your custom command here.
|
|
57
|
-
*/
|
|
58
|
-
exec(message: XernerxMessage, args: MessageArgumentOptions): Promise<void>;
|
|
59
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
3
|
-
/**
|
|
4
|
-
* @description - The command builder for message commands.
|
|
5
|
-
* @param {String} id - The unique ID of the command.
|
|
6
|
-
* @param {MessageCommandOptions} options - The command options.
|
|
7
|
-
*/
|
|
8
|
-
export default class MessageCommandBuilder {
|
|
9
|
-
id;
|
|
10
|
-
name;
|
|
11
|
-
aliases;
|
|
12
|
-
separator;
|
|
13
|
-
description;
|
|
14
|
-
info;
|
|
15
|
-
category;
|
|
16
|
-
prefix;
|
|
17
|
-
regex;
|
|
18
|
-
channelType;
|
|
19
|
-
ignore;
|
|
20
|
-
strict;
|
|
21
|
-
permissions;
|
|
22
|
-
cooldown;
|
|
23
|
-
args;
|
|
24
|
-
client;
|
|
25
|
-
constructor(id, options) {
|
|
26
|
-
this.id = id;
|
|
27
|
-
z.object({
|
|
28
|
-
name: z.string(),
|
|
29
|
-
aliases: z.array(z.string()).optional(),
|
|
30
|
-
separator: z.string().min(1).max(1).optional(),
|
|
31
|
-
description: z.string().optional(),
|
|
32
|
-
info: z.string().optional(),
|
|
33
|
-
category: z.string().optional(),
|
|
34
|
-
prefix: z.array(z.string()).or(z.string()).optional(),
|
|
35
|
-
regex: z.unknown(),
|
|
36
|
-
channelType: z.array(z.number()).or(z.number()).optional(),
|
|
37
|
-
cooldown: z.number().optional(),
|
|
38
|
-
ignore: z
|
|
39
|
-
.object({
|
|
40
|
-
owners: z.boolean().optional(),
|
|
41
|
-
users: z.array(z.string()).or(z.string()).optional(),
|
|
42
|
-
channels: z.array(z.string()).or(z.string()).optional(),
|
|
43
|
-
guilds: z.array(z.string()).or(z.string()).optional(),
|
|
44
|
-
})
|
|
45
|
-
.optional(),
|
|
46
|
-
strict: z
|
|
47
|
-
.object({
|
|
48
|
-
owners: z.boolean().optional(),
|
|
49
|
-
users: z.array(z.string()).or(z.string()).optional(),
|
|
50
|
-
channels: z.array(z.string()).or(z.string()).optional(),
|
|
51
|
-
guilds: z.array(z.string()).or(z.string()).optional(),
|
|
52
|
-
})
|
|
53
|
-
.optional(),
|
|
54
|
-
permissions: z
|
|
55
|
-
.object({
|
|
56
|
-
client: z.array(z.string()).optional(),
|
|
57
|
-
users: z.array(z.string()).optional(),
|
|
58
|
-
dm: z.boolean().optional(),
|
|
59
|
-
})
|
|
60
|
-
.optional(),
|
|
61
|
-
}).parse(options);
|
|
62
|
-
this.name = options.name;
|
|
63
|
-
this.aliases = options.aliases;
|
|
64
|
-
this.separator = options.separator || ' ';
|
|
65
|
-
this.description = options.description;
|
|
66
|
-
this.info = options.info;
|
|
67
|
-
this.category = options.category;
|
|
68
|
-
this.prefix = options.prefix ? (Array.isArray(options.prefix) ? options.prefix : [options.prefix]) : [];
|
|
69
|
-
this.regex = options.regex;
|
|
70
|
-
this.channelType = options.channelType;
|
|
71
|
-
this.ignore = options.ignore;
|
|
72
|
-
this.strict = options.strict;
|
|
73
|
-
this.permissions = options.permissions;
|
|
74
|
-
this.cooldown = options.cooldown || 0;
|
|
75
|
-
this.args = options.args || [];
|
|
76
|
-
this.client = XernerxClient;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* @param {Message} message - The Discord message event data.
|
|
80
|
-
* @param {object} args - The arguments you created.
|
|
81
|
-
* @description make any preconditions here.
|
|
82
|
-
*/
|
|
83
|
-
async conditions(message, args) {}
|
|
84
|
-
/**
|
|
85
|
-
* @param {Message} message - The Discord message event data.
|
|
86
|
-
* @param {object} args - The arguments you created.
|
|
87
|
-
* @description Make your custom command here.
|
|
88
|
-
*/
|
|
89
|
-
async exec(message, args) {}
|
|
90
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import Discord, { Interaction } from 'discord.js';
|
|
2
|
-
import { SlashCommandOptions } from '../types/options.js';
|
|
3
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
4
|
-
/**
|
|
5
|
-
* @description - The command builder for slash commands.
|
|
6
|
-
* @param {String} id - The unique ID of the command.
|
|
7
|
-
* @param {SlashCommandOptions} options - The command options.
|
|
8
|
-
*/
|
|
9
|
-
export default class SlashCommandBuilder {
|
|
10
|
-
id: string;
|
|
11
|
-
data: Discord.SlashCommandBuilder;
|
|
12
|
-
name: string;
|
|
13
|
-
description: string;
|
|
14
|
-
info: string | undefined;
|
|
15
|
-
category: string | undefined;
|
|
16
|
-
channelType: Discord.ChannelType | undefined;
|
|
17
|
-
cooldown: number | undefined;
|
|
18
|
-
ignore:
|
|
19
|
-
| {
|
|
20
|
-
owner?: boolean | undefined;
|
|
21
|
-
users?: string[] | undefined;
|
|
22
|
-
channels?: string[] | undefined;
|
|
23
|
-
guilds?: string[] | undefined;
|
|
24
|
-
}
|
|
25
|
-
| undefined;
|
|
26
|
-
strict:
|
|
27
|
-
| {
|
|
28
|
-
owner?: boolean | undefined;
|
|
29
|
-
users?: string[] | undefined;
|
|
30
|
-
channels?: string[] | undefined;
|
|
31
|
-
guilds?: string[] | undefined;
|
|
32
|
-
}
|
|
33
|
-
| undefined;
|
|
34
|
-
permissions: {
|
|
35
|
-
client?: string[] | undefined;
|
|
36
|
-
users?: string[] | undefined;
|
|
37
|
-
dm?: boolean | undefined;
|
|
38
|
-
};
|
|
39
|
-
args?: object[];
|
|
40
|
-
subcommands?: object[];
|
|
41
|
-
groups?: object[];
|
|
42
|
-
defer:
|
|
43
|
-
| {
|
|
44
|
-
reply?: boolean | undefined;
|
|
45
|
-
ephemeral?: boolean | undefined;
|
|
46
|
-
fetchReply?: boolean | undefined;
|
|
47
|
-
}
|
|
48
|
-
| undefined;
|
|
49
|
-
client: typeof XernerxClient;
|
|
50
|
-
constructor(id: string, options: SlashCommandOptions);
|
|
51
|
-
/**
|
|
52
|
-
* TODO - update description
|
|
53
|
-
* @param interaction
|
|
54
|
-
*/
|
|
55
|
-
conditions(interaction: Interaction): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* TODO - update description
|
|
58
|
-
* @param interaction
|
|
59
|
-
*/
|
|
60
|
-
exec(interaction: Interaction): Promise<void>;
|
|
61
|
-
private addArgs;
|
|
62
|
-
private addSubcommands;
|
|
63
|
-
private addSubcommandGroups;
|
|
64
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import Discord, { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from 'discord.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import XernerxError from '../tools/XernerxError.js';
|
|
4
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
5
|
-
/**
|
|
6
|
-
* @description - The command builder for slash commands.
|
|
7
|
-
* @param {String} id - The unique ID of the command.
|
|
8
|
-
* @param {SlashCommandOptions} options - The command options.
|
|
9
|
-
*/
|
|
10
|
-
export default class SlashCommandBuilder {
|
|
11
|
-
id;
|
|
12
|
-
data;
|
|
13
|
-
name;
|
|
14
|
-
description;
|
|
15
|
-
info;
|
|
16
|
-
category;
|
|
17
|
-
channelType;
|
|
18
|
-
cooldown;
|
|
19
|
-
ignore;
|
|
20
|
-
strict;
|
|
21
|
-
permissions;
|
|
22
|
-
args;
|
|
23
|
-
subcommands;
|
|
24
|
-
groups;
|
|
25
|
-
defer;
|
|
26
|
-
client;
|
|
27
|
-
constructor(id, options) {
|
|
28
|
-
this.id = id;
|
|
29
|
-
this.data = new Discord.SlashCommandBuilder().setName(options.name).setDescription(options.description);
|
|
30
|
-
if (options.args && options?.args?.length > 0) {
|
|
31
|
-
this.addArgs(this.data, options.args);
|
|
32
|
-
}
|
|
33
|
-
if (options.subcommands && options?.subcommands?.length > 0) {
|
|
34
|
-
this.addSubcommands(this.data, options.subcommands);
|
|
35
|
-
}
|
|
36
|
-
if (options.groups && options?.groups?.length > 0) {
|
|
37
|
-
this.addSubcommandGroups(options.groups);
|
|
38
|
-
}
|
|
39
|
-
z.object({
|
|
40
|
-
description: z.string(),
|
|
41
|
-
info: z.string(),
|
|
42
|
-
category: z.string(),
|
|
43
|
-
channelType: z.array(z.number()).or(z.number()),
|
|
44
|
-
cooldown: z.number(),
|
|
45
|
-
ignore: z.object({
|
|
46
|
-
owner: z.boolean(),
|
|
47
|
-
users: z.array(z.string()),
|
|
48
|
-
channels: z.array(z.string()),
|
|
49
|
-
guilds: z.array(z.string()),
|
|
50
|
-
}),
|
|
51
|
-
strict: z.object({
|
|
52
|
-
owner: z.boolean(),
|
|
53
|
-
users: z.array(z.string()),
|
|
54
|
-
channels: z.array(z.string()),
|
|
55
|
-
guilds: z.array(z.string()),
|
|
56
|
-
}),
|
|
57
|
-
permissions: z.object({
|
|
58
|
-
client: z.array(z.string()),
|
|
59
|
-
users: z.array(z.string()),
|
|
60
|
-
dm: z.boolean(),
|
|
61
|
-
}),
|
|
62
|
-
defer: z.object({
|
|
63
|
-
reply: z.boolean(),
|
|
64
|
-
ephemeral: z.boolean(),
|
|
65
|
-
fetch: z.boolean(),
|
|
66
|
-
}),
|
|
67
|
-
})
|
|
68
|
-
.deepPartial()
|
|
69
|
-
.parse(options);
|
|
70
|
-
this.name = options.name;
|
|
71
|
-
this.description = options.description;
|
|
72
|
-
this.info = options.info;
|
|
73
|
-
this.category = options.category;
|
|
74
|
-
this.channelType = options.channelType;
|
|
75
|
-
this.cooldown = options.cooldown;
|
|
76
|
-
this.ignore = options.ignore;
|
|
77
|
-
this.strict = options.strict;
|
|
78
|
-
this.permissions = options.permissions;
|
|
79
|
-
this.defer = options.defer;
|
|
80
|
-
this.client = XernerxClient;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* TODO - update description
|
|
84
|
-
* @param interaction
|
|
85
|
-
*/
|
|
86
|
-
async conditions(interaction) {}
|
|
87
|
-
/**
|
|
88
|
-
* TODO - update description
|
|
89
|
-
* @param interaction
|
|
90
|
-
*/
|
|
91
|
-
async exec(interaction) {}
|
|
92
|
-
addArgs(command, args) {
|
|
93
|
-
const types = ['boolean', 'integer', 'number', 'string', 'user', 'role', 'channel', 'mentionable'];
|
|
94
|
-
for (const argument of args) {
|
|
95
|
-
if (!types.includes(argument.type.toLowerCase())) throw new XernerxError(`Expected one of ${types.join(', ')}, received ${argument.type} instead.`);
|
|
96
|
-
let slashArgumentType = `${argument.type.slice(0, 1).toUpperCase()}${argument.type.slice(1).toLowerCase()}`;
|
|
97
|
-
command[`add${slashArgumentType}Option`]((option) => {
|
|
98
|
-
option
|
|
99
|
-
.setName(argument.name)
|
|
100
|
-
.setDescription(argument.description)
|
|
101
|
-
.setRequired(argument.required || false);
|
|
102
|
-
if (argument.choices) option.setChoices(...argument?.choices);
|
|
103
|
-
return option;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
addSubcommands(method, subcommands) {
|
|
108
|
-
for (const subcommand of subcommands) {
|
|
109
|
-
let sub = new SlashCommandSubcommandBuilder().setName(subcommand.name).setDescription(subcommand.description);
|
|
110
|
-
if (subcommand.args?.length > 0) this.addArgs(sub, subcommand.args);
|
|
111
|
-
method.addSubcommand(sub);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
addSubcommandGroups(groups) {
|
|
115
|
-
for (const group of groups) {
|
|
116
|
-
let subcommandGroup = new SlashCommandSubcommandGroupBuilder().setName(group.name).setDescription(group.description);
|
|
117
|
-
if (group.subcommands?.length > 0) this.addSubcommands(subcommandGroup, group.subcommands);
|
|
118
|
-
this.data.addSubcommandGroup(subcommandGroup);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Client, Collection } from 'discord.js';
|
|
2
|
-
import ExtensionBuilder from 'xernerx-extension-builder';
|
|
3
|
-
import { ClientUtil } from '../utils/ClientUtil.js';
|
|
4
|
-
import { ClientOptions, DiscordOptions, ExtensionOptions, HandlerOptions } from '../types/options.js';
|
|
5
|
-
import { ClientCache, ClientCommands, ClientModules } from '../types/interfaces.js';
|
|
6
|
-
import EventBuilder from '../build/EventBuilder.js';
|
|
7
|
-
import InhibitorBuilder from '../build/InhibitorBuilder.js';
|
|
8
|
-
/**
|
|
9
|
-
* @description - The Client.
|
|
10
|
-
* @param {DiscordOptions} discordOptions - The options for discord.js.
|
|
11
|
-
* @param {ClientOptions} clientOptions - The options for the Xernerx Client.
|
|
12
|
-
* @extends {Client}
|
|
13
|
-
*/
|
|
14
|
-
export default class XernerxClient extends Client {
|
|
15
|
-
settings: ClientOptions;
|
|
16
|
-
commands: ClientCommands;
|
|
17
|
-
cache: ClientCache;
|
|
18
|
-
modules: ClientModules;
|
|
19
|
-
util: ClientUtil;
|
|
20
|
-
handlerOptions: HandlerOptions;
|
|
21
|
-
events: Collection<string, EventBuilder>;
|
|
22
|
-
extensions: Record<string, ExtensionBuilder>;
|
|
23
|
-
inhibitors: Collection<string, InhibitorBuilder>;
|
|
24
|
-
config: object;
|
|
25
|
-
constructor(discordOptions: DiscordOptions, clientOptions: ClientOptions, config?: object);
|
|
26
|
-
register(token: string): void;
|
|
27
|
-
loadAllExtensions(options: ExtensionOptions): Promise<void>;
|
|
28
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
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(
|
|
89
|
-
Style.log(
|
|
90
|
-
`Xernerx | ${client.user.tag} signed in watching ${size} server${size > 1 ? 's' : ''}. ${
|
|
91
|
-
(this.handlerOptions.slash || this.handlerOptions.context)?.guildId
|
|
92
|
-
? `Using ${(await this.guilds.fetch((this.handlerOptions.slash || this.handlerOptions.context)?.guildId || '0')).name} as local guild.`
|
|
93
|
-
: ''
|
|
94
|
-
}`,
|
|
95
|
-
{ color: Style.TextColor.Purple }
|
|
96
|
-
)
|
|
97
|
-
);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
register(token) {
|
|
102
|
-
this.login(token);
|
|
103
|
-
}
|
|
104
|
-
loadAllExtensions(options) {
|
|
105
|
-
const extensions = new Extensions(this);
|
|
106
|
-
return extensions.load(options.extensions, options.logging || false);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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
|
-
}
|