xernerx 2.7.4 → 3.0.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/README.md +0 -0
- package/dist/build/ContextCommand.d.ts +39 -0
- package/dist/build/ContextCommand.js +86 -0
- package/dist/build/Event.d.ts +15 -0
- package/dist/build/Event.js +31 -0
- package/dist/build/Inhibitor.d.ts +12 -0
- package/dist/build/Inhibitor.js +20 -0
- package/dist/build/MessageCommand.d.ts +39 -0
- package/dist/build/MessageCommand.js +77 -0
- package/dist/build/SlashCommand.d.ts +32 -0
- package/dist/build/SlashCommand.js +119 -0
- package/dist/client/XernerxClient.d.ts +22 -0
- package/dist/client/XernerxClient.js +76 -0
- package/dist/handlers/CommandHandler.d.ts +27 -0
- package/dist/handlers/CommandHandler.js +42 -0
- package/dist/handlers/EventHandler.d.ts +13 -0
- package/dist/handlers/EventHandler.js +16 -0
- package/dist/handlers/Handler.d.ts +37 -0
- package/dist/handlers/Handler.js +242 -0
- package/dist/handlers/InhibitorHandler.d.ts +18 -0
- package/dist/handlers/InhibitorHandler.js +21 -0
- package/dist/interfaces/ClientInterfaces.d.ts +58 -0
- package/dist/interfaces/ClientInterfaces.js +1 -0
- package/dist/interfaces/CommandInterfaces.d.ts +94 -0
- package/dist/interfaces/CommandInterfaces.js +1 -0
- package/dist/interfaces/HandlerInterfaces.d.ts +70 -0
- package/dist/interfaces/HandlerInterfaces.js +1 -0
- package/dist/main.d.ts +26 -0
- package/dist/main.js +40 -0
- package/dist/models/CommandArguments.d.ts +9 -0
- package/dist/models/CommandArguments.js +128 -0
- package/dist/models/CommandValidations.d.ts +3 -0
- package/dist/models/CommandValidations.js +193 -0
- package/dist/models/Events.d.ts +23 -0
- package/dist/models/Events.js +328 -0
- package/dist/models/Functions.d.ts +1 -0
- package/dist/models/Functions.js +30 -0
- package/dist/models/InhibitorValidations.d.ts +17 -0
- package/dist/models/InhibitorValidations.js +42 -0
- package/dist/types/EventTypes.d.ts +1 -0
- package/dist/types/EventTypes.js +1 -0
- package/dist/types/InhibitorTypes.d.ts +12 -0
- package/dist/types/InhibitorTypes.js +13 -0
- package/dist/types/Types.d.ts +24 -0
- package/dist/types/Types.js +21 -0
- package/dist/utils/ClientUtil.d.ts +25 -0
- package/dist/utils/ClientUtil.js +232 -0
- package/dist/utils/CommandUtil.d.ts +24 -0
- package/dist/utils/CommandUtil.js +163 -0
- package/package.json +5 -8
- package/main.js +0 -49
- package/models/Client.js +0 -60
- package/models/commands/ContextMenuCommand.js +0 -68
- package/models/commands/Event.js +0 -33
- package/models/commands/Inhibitor.js +0 -31
- package/models/commands/InteractionCommand.js +0 -142
- package/models/commands/MessageCommand.js +0 -86
- package/models/data/colors.json +0 -16
- package/models/data/options.json +0 -27
- package/models/events/interactionCreate.js +0 -84
- package/models/events/messageCreate.js +0 -84
- package/models/events/messageUpdate.js +0 -83
- package/models/events/readyOnce.js +0 -58
- package/models/handlers/CommandHandler.js +0 -37
- package/models/handlers/EventHandler.js +0 -67
- package/models/handlers/Handler.js +0 -111
- package/models/handlers/InhibitorHandler.js +0 -16
- package/models/handlers/LanguageHandler.js +0 -37
- package/models/utils/Arguments.js +0 -120
- package/models/utils/CommandValidation.js +0 -96
- package/models/utils/CommandsUtil.js +0 -70
- package/models/utils/Functions.js +0 -266
- package/models/utils/InhibitorsUtil.js +0 -24
- package/models/utils/InhibitorsValidation.js +0 -40
- package/models/utils/Util.js +0 -96
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Dummi
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Dummi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
Binary file
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ChannelType, ContextMenuCommandBuilder, Interaction } from "discord.js";
|
|
2
|
+
import { ContextCommandOptions } from "../interfaces/CommandInterfaces.js";
|
|
3
|
+
/**
|
|
4
|
+
* @description The command builder for context commands.
|
|
5
|
+
* @param {String} id - The unique ID of the command.
|
|
6
|
+
* @param {ContextCommandOptions} options - The command options.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ContextCommand {
|
|
9
|
+
#private;
|
|
10
|
+
id: string;
|
|
11
|
+
data: ContextMenuCommandBuilder;
|
|
12
|
+
description?: string;
|
|
13
|
+
info?: string;
|
|
14
|
+
category?: string;
|
|
15
|
+
owner?: boolean;
|
|
16
|
+
channelType?: ChannelType;
|
|
17
|
+
cooldown?: number;
|
|
18
|
+
ignoreOwner?: boolean;
|
|
19
|
+
channels?: string[];
|
|
20
|
+
guilds?: string[];
|
|
21
|
+
userPermissions?: bigint[];
|
|
22
|
+
clientPermissions?: bigint[];
|
|
23
|
+
defer?: {
|
|
24
|
+
reply?: boolean;
|
|
25
|
+
ephemeral?: boolean;
|
|
26
|
+
fetchReply?: boolean;
|
|
27
|
+
};
|
|
28
|
+
constructor(id: string, options: ContextCommandOptions);
|
|
29
|
+
/**
|
|
30
|
+
* @param {Interaction} interaction - The Discord interaction event data.
|
|
31
|
+
* @description make any preconditions here.
|
|
32
|
+
*/
|
|
33
|
+
conditions(interaction: Interaction): void;
|
|
34
|
+
/**
|
|
35
|
+
* @param {Interaction} interaction - The Discord interaction event data.
|
|
36
|
+
* @description Make your custom command here.
|
|
37
|
+
*/
|
|
38
|
+
exec(interaction: Interaction): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ContextMenuCommandBuilder, } from "discord.js";
|
|
2
|
+
import { s } from "@sapphire/shapeshift";
|
|
3
|
+
/**
|
|
4
|
+
* @description The command builder for context commands.
|
|
5
|
+
* @param {String} id - The unique ID of the command.
|
|
6
|
+
* @param {ContextCommandOptions} options - The command options.
|
|
7
|
+
*/
|
|
8
|
+
export class ContextCommand {
|
|
9
|
+
id;
|
|
10
|
+
data;
|
|
11
|
+
description;
|
|
12
|
+
info;
|
|
13
|
+
category;
|
|
14
|
+
owner;
|
|
15
|
+
channelType;
|
|
16
|
+
cooldown;
|
|
17
|
+
ignoreOwner;
|
|
18
|
+
channels;
|
|
19
|
+
guilds;
|
|
20
|
+
userPermissions;
|
|
21
|
+
clientPermissions;
|
|
22
|
+
defer;
|
|
23
|
+
constructor(id, options) {
|
|
24
|
+
this.id = id;
|
|
25
|
+
this.data = new ContextMenuCommandBuilder();
|
|
26
|
+
if (options.name)
|
|
27
|
+
this.data.setName(options.name);
|
|
28
|
+
if (options.type)
|
|
29
|
+
this.data.setType(this.#types(options.type));
|
|
30
|
+
if (options.defaultMemberPermissions)
|
|
31
|
+
this.data.setDefaultMemberPermissions(options.defaultMemberPermissions);
|
|
32
|
+
if (options.DMPermission)
|
|
33
|
+
this.data.setDMPermission(options.DMPermission);
|
|
34
|
+
if (options.nameLocalization)
|
|
35
|
+
this.data.setNameLocalization(options.nameLocalization.locale, options.nameLocalization.localizedName);
|
|
36
|
+
if (options.nameLocalizations)
|
|
37
|
+
this.data.setNameLocalizations(options.nameLocalizations);
|
|
38
|
+
s.object({
|
|
39
|
+
description: s.string.optional,
|
|
40
|
+
info: s.string.optional,
|
|
41
|
+
category: s.string.optional,
|
|
42
|
+
owner: s.boolean.optional,
|
|
43
|
+
// channelType?: ChannelType,
|
|
44
|
+
cooldown: s.number.optional,
|
|
45
|
+
ignoreOwner: s.boolean.optional,
|
|
46
|
+
channels: s.array(s.string).optional,
|
|
47
|
+
guilds: s.array(s.string).optional,
|
|
48
|
+
userPermissions: s.array(s.bigint).optional,
|
|
49
|
+
clientPermissions: s.array(s.bigint).optional,
|
|
50
|
+
defer: s.object({
|
|
51
|
+
reply: s.boolean.optional,
|
|
52
|
+
ephemeral: s.boolean.optional,
|
|
53
|
+
fetchReply: s.boolean.optional,
|
|
54
|
+
}).optional,
|
|
55
|
+
}).parse(options);
|
|
56
|
+
this.description = options.description;
|
|
57
|
+
this.info = options.info;
|
|
58
|
+
this.category = options.category;
|
|
59
|
+
this.owner = options.owner;
|
|
60
|
+
this.channelType = options.channelType;
|
|
61
|
+
this.cooldown = options.cooldown;
|
|
62
|
+
this.ignoreOwner = options.ignoreOwner;
|
|
63
|
+
this.channels = options.channels;
|
|
64
|
+
this.guilds = options.guilds;
|
|
65
|
+
this.userPermissions = options.userPermissions;
|
|
66
|
+
this.clientPermissions = options.clientPermissions;
|
|
67
|
+
this.defer = options.defer;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @param {Interaction} interaction - The Discord interaction event data.
|
|
71
|
+
* @description make any preconditions here.
|
|
72
|
+
*/
|
|
73
|
+
conditions(interaction) { }
|
|
74
|
+
/**
|
|
75
|
+
* @param {Interaction} interaction - The Discord interaction event data.
|
|
76
|
+
* @description Make your custom command here.
|
|
77
|
+
*/
|
|
78
|
+
exec(interaction) { }
|
|
79
|
+
#types(type) {
|
|
80
|
+
if (String(type)?.toLowerCase() === "message")
|
|
81
|
+
type = 3;
|
|
82
|
+
if (String(type)?.toLowerCase() === "user")
|
|
83
|
+
type = 2;
|
|
84
|
+
return type;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EventOptions } from "../interfaces/HandlerInterfaces.js";
|
|
2
|
+
/**
|
|
3
|
+
* @description - The event builder for any events.
|
|
4
|
+
* @param {String} id - The unique ID of the event.
|
|
5
|
+
* @param {EventOptions} options - The event options.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Event {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
emitter?: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
once?: boolean;
|
|
13
|
+
constructor(id: string, options: EventOptions);
|
|
14
|
+
run(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { s } from "@sapphire/shapeshift";
|
|
2
|
+
/**
|
|
3
|
+
* @description - The event builder for any events.
|
|
4
|
+
* @param {String} id - The unique ID of the event.
|
|
5
|
+
* @param {EventOptions} options - The event options.
|
|
6
|
+
*/
|
|
7
|
+
export class Event {
|
|
8
|
+
id;
|
|
9
|
+
name;
|
|
10
|
+
emitter;
|
|
11
|
+
type;
|
|
12
|
+
once;
|
|
13
|
+
constructor(id, options) {
|
|
14
|
+
this.id = id;
|
|
15
|
+
s.object({
|
|
16
|
+
name: s.string,
|
|
17
|
+
emitter: s.string.optional,
|
|
18
|
+
type: s.string.optional,
|
|
19
|
+
once: s.boolean.optional,
|
|
20
|
+
}).parse(options);
|
|
21
|
+
this.name = options.name;
|
|
22
|
+
this.emitter = options.emitter || "client";
|
|
23
|
+
this.type = options.type || "discord";
|
|
24
|
+
this.once = options.once || false;
|
|
25
|
+
}
|
|
26
|
+
run() {
|
|
27
|
+
/**
|
|
28
|
+
* @description run your custom event here.
|
|
29
|
+
*/
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InhibitorOptions } from "../interfaces/HandlerInterfaces.js";
|
|
2
|
+
/**
|
|
3
|
+
* @description - The inhibitor builder for inhibitors.
|
|
4
|
+
* @param {String} id - The unique ID of the inhibitor.
|
|
5
|
+
* @param {InhibitorOptions} options - The inhibitor options.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Inhibitor {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
constructor(id: string, options: InhibitorOptions);
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { s } from "@sapphire/shapeshift";
|
|
2
|
+
/**
|
|
3
|
+
* @description - The inhibitor builder for inhibitors.
|
|
4
|
+
* @param {String} id - The unique ID of the inhibitor.
|
|
5
|
+
* @param {InhibitorOptions} options - The inhibitor options.
|
|
6
|
+
*/
|
|
7
|
+
export class Inhibitor {
|
|
8
|
+
id;
|
|
9
|
+
name;
|
|
10
|
+
type;
|
|
11
|
+
constructor(id, options) {
|
|
12
|
+
this.id = id;
|
|
13
|
+
s.object({
|
|
14
|
+
name: s.string,
|
|
15
|
+
type: s.string,
|
|
16
|
+
}).parse(options);
|
|
17
|
+
this.name = options.name;
|
|
18
|
+
this.type = options.type;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { MessageCommandOptions } from "../interfaces/CommandInterfaces.js";
|
|
2
|
+
import { Message, ChannelType } from "discord.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 declare class MessageCommand {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
aliases?: string[];
|
|
12
|
+
description?: string;
|
|
13
|
+
info?: string;
|
|
14
|
+
category?: string;
|
|
15
|
+
prefix?: string | string[];
|
|
16
|
+
owner?: boolean;
|
|
17
|
+
channelType?: ChannelType | ChannelType[];
|
|
18
|
+
separator?: string;
|
|
19
|
+
cooldown?: number;
|
|
20
|
+
ignoreOwner?: boolean;
|
|
21
|
+
channels?: string[];
|
|
22
|
+
guilds?: string[];
|
|
23
|
+
userPermissions?: bigint[];
|
|
24
|
+
clientPermissions?: bigint[];
|
|
25
|
+
args: object;
|
|
26
|
+
constructor(id: string, options: MessageCommandOptions);
|
|
27
|
+
/**
|
|
28
|
+
* @param {Message} message - The Discord message event data.
|
|
29
|
+
* @param {object} args - The arguments you created.
|
|
30
|
+
* @description make any preconditions here.
|
|
31
|
+
*/
|
|
32
|
+
conditions(message: Message, args: object): void;
|
|
33
|
+
/**
|
|
34
|
+
* @param {Message} message - The Discord message event data.
|
|
35
|
+
* @param {object} args - The arguments you created.
|
|
36
|
+
* @description Make your custom command here.
|
|
37
|
+
*/
|
|
38
|
+
exec(message: Message, args: object): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { s } from "@sapphire/shapeshift";
|
|
2
|
+
/**
|
|
3
|
+
* @description - The command builder for message commands.
|
|
4
|
+
* @param {String} id - The unique ID of the command.
|
|
5
|
+
* @param {MessageCommandOptions} options - The command options.
|
|
6
|
+
*/
|
|
7
|
+
export class MessageCommand {
|
|
8
|
+
id;
|
|
9
|
+
name;
|
|
10
|
+
aliases;
|
|
11
|
+
description;
|
|
12
|
+
info;
|
|
13
|
+
category;
|
|
14
|
+
prefix;
|
|
15
|
+
owner;
|
|
16
|
+
channelType;
|
|
17
|
+
separator;
|
|
18
|
+
cooldown;
|
|
19
|
+
ignoreOwner;
|
|
20
|
+
channels;
|
|
21
|
+
guilds;
|
|
22
|
+
userPermissions;
|
|
23
|
+
clientPermissions;
|
|
24
|
+
args;
|
|
25
|
+
constructor(id, options) {
|
|
26
|
+
this.id = id;
|
|
27
|
+
s.object({
|
|
28
|
+
name: s.string,
|
|
29
|
+
aliases: s.union(s.array(s.string).unique, s.string).optional,
|
|
30
|
+
description: s.string.optional,
|
|
31
|
+
info: s.string.optional,
|
|
32
|
+
category: s.string.optional,
|
|
33
|
+
prefix: s.union(s.array(s.string).unique, s.string).optional,
|
|
34
|
+
owner: s.boolean.optional,
|
|
35
|
+
// channelType: s.union(s.enum(ChannelType),s.array(s.enum(ChannelType)).unique).optional,
|
|
36
|
+
separator: s.string.optional,
|
|
37
|
+
cooldown: s.number.optional,
|
|
38
|
+
ignoreOwner: s.boolean.optional,
|
|
39
|
+
channels: s.array(s.string).unique.optional,
|
|
40
|
+
guilds: s.array(s.string).unique.optional,
|
|
41
|
+
userPermissions: s.array(s.bigint).unique.optional,
|
|
42
|
+
clientPermissions: s.array(s.bigint).unique.optional,
|
|
43
|
+
}).parse(options);
|
|
44
|
+
this.name = options.name;
|
|
45
|
+
this.aliases = options.aliases;
|
|
46
|
+
this.description = options.description;
|
|
47
|
+
this.info = options.info;
|
|
48
|
+
this.category = options.category;
|
|
49
|
+
this.prefix = options.prefix
|
|
50
|
+
? Array.isArray(options.prefix)
|
|
51
|
+
? options.prefix
|
|
52
|
+
: [options.prefix]
|
|
53
|
+
: [];
|
|
54
|
+
this.owner = options.owner || false;
|
|
55
|
+
this.channelType = options.channelType;
|
|
56
|
+
this.separator = options.separator || " ";
|
|
57
|
+
this.cooldown = options.cooldown || 0;
|
|
58
|
+
this.ignoreOwner = options.ignoreOwner || false;
|
|
59
|
+
this.channels = options.channels || [];
|
|
60
|
+
this.guilds = options.guilds || [];
|
|
61
|
+
this.userPermissions = options.userPermissions || [];
|
|
62
|
+
this.clientPermissions = options.clientPermissions || [];
|
|
63
|
+
this.args = options.args;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @param {Message} message - The Discord message event data.
|
|
67
|
+
* @param {object} args - The arguments you created.
|
|
68
|
+
* @description make any preconditions here.
|
|
69
|
+
*/
|
|
70
|
+
conditions(message, args) { }
|
|
71
|
+
/**
|
|
72
|
+
* @param {Message} message - The Discord message event data.
|
|
73
|
+
* @param {object} args - The arguments you created.
|
|
74
|
+
* @description Make your custom command here.
|
|
75
|
+
*/
|
|
76
|
+
exec(message, args) { }
|
|
77
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SlashCommandOptions } from "../interfaces/CommandInterfaces.js";
|
|
2
|
+
import { ChannelType, SlashCommandBuilder } from "discord.js";
|
|
3
|
+
/**
|
|
4
|
+
* @description - The command builder for slash commands.
|
|
5
|
+
* @param {String} id - The unique ID of the command.
|
|
6
|
+
* @param {SlashCommandOptions} options - The command options.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SlashCommand {
|
|
9
|
+
#private;
|
|
10
|
+
id: string;
|
|
11
|
+
data: SlashCommandBuilder;
|
|
12
|
+
info?: string;
|
|
13
|
+
category?: string;
|
|
14
|
+
owner?: boolean;
|
|
15
|
+
channelType?: ChannelType;
|
|
16
|
+
separator?: string;
|
|
17
|
+
cooldown?: number;
|
|
18
|
+
ignoreOwner?: boolean;
|
|
19
|
+
channels?: string[];
|
|
20
|
+
guilds?: string[];
|
|
21
|
+
userPermissions?: bigint[];
|
|
22
|
+
clientPermissions?: bigint[];
|
|
23
|
+
args?: object[];
|
|
24
|
+
subcommands?: object[];
|
|
25
|
+
groups?: object[];
|
|
26
|
+
defer?: {
|
|
27
|
+
reply?: boolean;
|
|
28
|
+
ephemeral?: boolean;
|
|
29
|
+
fetchReply?: boolean;
|
|
30
|
+
};
|
|
31
|
+
constructor(id: string, options: SlashCommandOptions);
|
|
32
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, } from "discord.js";
|
|
2
|
+
import { s } from "@sapphire/shapeshift";
|
|
3
|
+
/**
|
|
4
|
+
* @description - The command builder for slash commands.
|
|
5
|
+
* @param {String} id - The unique ID of the command.
|
|
6
|
+
* @param {SlashCommandOptions} options - The command options.
|
|
7
|
+
*/
|
|
8
|
+
export class SlashCommand {
|
|
9
|
+
id;
|
|
10
|
+
data;
|
|
11
|
+
info;
|
|
12
|
+
category;
|
|
13
|
+
owner;
|
|
14
|
+
channelType;
|
|
15
|
+
separator;
|
|
16
|
+
cooldown;
|
|
17
|
+
ignoreOwner;
|
|
18
|
+
channels;
|
|
19
|
+
guilds;
|
|
20
|
+
userPermissions;
|
|
21
|
+
clientPermissions;
|
|
22
|
+
args;
|
|
23
|
+
subcommands;
|
|
24
|
+
groups;
|
|
25
|
+
defer;
|
|
26
|
+
constructor(id, options) {
|
|
27
|
+
this.id = id;
|
|
28
|
+
this.data = new SlashCommandBuilder()
|
|
29
|
+
.setName(options.name)
|
|
30
|
+
.setDescription(options.description);
|
|
31
|
+
if (options.args && options?.args?.length > 0) {
|
|
32
|
+
this.#addArgs(this.data, options.args);
|
|
33
|
+
}
|
|
34
|
+
if (options.subcommands && options?.subcommands?.length > 0) {
|
|
35
|
+
this.#addSubcommands(this.data, options.subcommands);
|
|
36
|
+
}
|
|
37
|
+
if (options.groups && options?.groups?.length > 0) {
|
|
38
|
+
this.#addSubcommandGroups(options.groups);
|
|
39
|
+
}
|
|
40
|
+
s.object({
|
|
41
|
+
info: s.string.optional,
|
|
42
|
+
category: s.string.optional,
|
|
43
|
+
owner: s.boolean.optional,
|
|
44
|
+
// channelType: s.ChannelType.optional,
|
|
45
|
+
separator: s.string.optional,
|
|
46
|
+
cooldown: s.number.optional,
|
|
47
|
+
ignoreOwner: s.boolean.optional,
|
|
48
|
+
channels: s.array(s.string).optional,
|
|
49
|
+
guilds: s.array(s.string).optional,
|
|
50
|
+
userPermissions: s.array(s.bigint).optional,
|
|
51
|
+
clientPermissions: s.array(s.bigint).optional,
|
|
52
|
+
defer: s.object({
|
|
53
|
+
reply: s.boolean.optional,
|
|
54
|
+
ephemeral: s.boolean.optional,
|
|
55
|
+
fetchReply: s.boolean.optional,
|
|
56
|
+
}).optional,
|
|
57
|
+
});
|
|
58
|
+
this.info = options.info;
|
|
59
|
+
this.category = options.category;
|
|
60
|
+
this.owner = options.owner;
|
|
61
|
+
this.channelType = options.channelType;
|
|
62
|
+
this.separator = options.separator;
|
|
63
|
+
this.cooldown = options.cooldown;
|
|
64
|
+
this.ignoreOwner = options.ignoreOwner;
|
|
65
|
+
this.channels = options.channels;
|
|
66
|
+
this.guilds = options.guilds;
|
|
67
|
+
this.userPermissions = options.userPermissions;
|
|
68
|
+
this.clientPermissions = options.clientPermissions;
|
|
69
|
+
this.defer = options.defer;
|
|
70
|
+
}
|
|
71
|
+
#addArgs(command, args) {
|
|
72
|
+
const types = [
|
|
73
|
+
"boolean",
|
|
74
|
+
"integer",
|
|
75
|
+
"number",
|
|
76
|
+
"string",
|
|
77
|
+
"user",
|
|
78
|
+
"role",
|
|
79
|
+
"channel",
|
|
80
|
+
"mentionable",
|
|
81
|
+
];
|
|
82
|
+
for (const argument of args) {
|
|
83
|
+
if (!types.includes(argument.type.toLowerCase()))
|
|
84
|
+
throw new Error(`Expected one of ${types.join(", ")}, received ${argument.type} instead.`);
|
|
85
|
+
let niceType = `${argument.type
|
|
86
|
+
.slice(0, 1)
|
|
87
|
+
.toUpperCase()}${argument.type.slice(1).toLowerCase()}`;
|
|
88
|
+
command[`add${niceType}Option`]((option) => {
|
|
89
|
+
option
|
|
90
|
+
.setName(argument.name)
|
|
91
|
+
.setDescription(argument.description)
|
|
92
|
+
.setRequired(argument.required || false);
|
|
93
|
+
if (argument.choices)
|
|
94
|
+
option.setChoices(...argument?.choices);
|
|
95
|
+
return option;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
#addSubcommands(method, subcommands) {
|
|
100
|
+
for (const subcommand of subcommands) {
|
|
101
|
+
let sub = new SlashCommandSubcommandBuilder()
|
|
102
|
+
.setName(subcommand.name)
|
|
103
|
+
.setDescription(subcommand.description);
|
|
104
|
+
if (subcommand.args?.length > 0)
|
|
105
|
+
this.#addArgs(sub, subcommand.args);
|
|
106
|
+
method.addSubcommand(sub);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
#addSubcommandGroups(groups) {
|
|
110
|
+
for (const group of groups) {
|
|
111
|
+
let subcommandGroup = new SlashCommandSubcommandGroupBuilder()
|
|
112
|
+
.setName(group.name)
|
|
113
|
+
.setDescription(group.description);
|
|
114
|
+
if (group.subcommands?.length > 0)
|
|
115
|
+
this.#addSubcommands(subcommandGroup, group.subcommands);
|
|
116
|
+
this.data.addSubcommandGroup(subcommandGroup);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Client, Collection } from "discord.js";
|
|
2
|
+
import { ClientUtil } from "../utils/ClientUtil.js";
|
|
3
|
+
import { DiscordOptions, ClientOptions, Commands, Cache, Modules, HandlerOptions } from "../interfaces/ClientInterfaces.js";
|
|
4
|
+
/**
|
|
5
|
+
* @description - The Client.
|
|
6
|
+
* @param {DiscordOptions} discordOptions - The options for discord.js.
|
|
7
|
+
* @param {ClientOptions} clientOptions - The options for the Xernerx Client.
|
|
8
|
+
* @extends {Client}
|
|
9
|
+
*/
|
|
10
|
+
export default class XernerxClient extends Client {
|
|
11
|
+
settings: ClientOptions;
|
|
12
|
+
commands: Commands;
|
|
13
|
+
cache: Cache;
|
|
14
|
+
modules: Modules;
|
|
15
|
+
util: ClientUtil;
|
|
16
|
+
handlerOptions: HandlerOptions;
|
|
17
|
+
events: Collection<string, object>;
|
|
18
|
+
inhibitors: Collection<string, object>;
|
|
19
|
+
config: object;
|
|
20
|
+
constructor(discordOptions: DiscordOptions, clientOptions: ClientOptions, config?: object);
|
|
21
|
+
register(token: string): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Client, Collection } from "discord.js";
|
|
2
|
+
import { s } from "@sapphire/shapeshift";
|
|
3
|
+
import CommandHandler from "../handlers/CommandHandler.js";
|
|
4
|
+
import EventHandler from "../handlers/EventHandler.js";
|
|
5
|
+
import InhibitorHandler from "../handlers/InhibitorHandler.js";
|
|
6
|
+
import { ClientUtil } from "../utils/ClientUtil.js";
|
|
7
|
+
import { logStyle } from "../models/Functions.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;
|
|
16
|
+
commands;
|
|
17
|
+
cache;
|
|
18
|
+
modules;
|
|
19
|
+
util;
|
|
20
|
+
handlerOptions;
|
|
21
|
+
events;
|
|
22
|
+
inhibitors;
|
|
23
|
+
config;
|
|
24
|
+
constructor(discordOptions, clientOptions, config) {
|
|
25
|
+
super(discordOptions);
|
|
26
|
+
this.settings = s
|
|
27
|
+
.object({
|
|
28
|
+
ownerId: s.union(s.array(s.string).unique, s.string).default([]),
|
|
29
|
+
clientPermissions: s.array(s.bigint).default([]),
|
|
30
|
+
userPermissions: s.array(s.bigint).default([]),
|
|
31
|
+
ignoreOwner: s.boolean.default(false),
|
|
32
|
+
logging: s.boolean.optional,
|
|
33
|
+
cooldown: s.object({
|
|
34
|
+
default: s.number.default(0),
|
|
35
|
+
cache: s.number.default(0),
|
|
36
|
+
}).optional,
|
|
37
|
+
})
|
|
38
|
+
.parse(clientOptions);
|
|
39
|
+
this.config = config || {};
|
|
40
|
+
this.commands = {
|
|
41
|
+
message: new Collection(),
|
|
42
|
+
slash: new Collection(),
|
|
43
|
+
context: new Collection(),
|
|
44
|
+
};
|
|
45
|
+
this.events = new Collection();
|
|
46
|
+
this.inhibitors = new Collection();
|
|
47
|
+
this.cache = {
|
|
48
|
+
messages: new Collection(),
|
|
49
|
+
cooldowns: new Collection(),
|
|
50
|
+
messageCommands: new Collection(),
|
|
51
|
+
slashCommands: new Collection(),
|
|
52
|
+
contextCommands: new Collection(),
|
|
53
|
+
commands: new Collection(),
|
|
54
|
+
};
|
|
55
|
+
this.modules = {
|
|
56
|
+
commandHandler: new CommandHandler(this),
|
|
57
|
+
eventHandler: new EventHandler(this),
|
|
58
|
+
inhibitorHandler: new InhibitorHandler(this),
|
|
59
|
+
};
|
|
60
|
+
this.util = new ClientUtil(this);
|
|
61
|
+
this.handlerOptions = {};
|
|
62
|
+
if (this.settings.logging) {
|
|
63
|
+
this.once("ready", async (client) => {
|
|
64
|
+
const size = (await client.guilds.fetch()).size;
|
|
65
|
+
console.info(logStyle(`Xernerx | ${client.user.tag} signed in watching ${size} server${size > 1 ? "s" : ""}. ${(this.handlerOptions.slash || this.handlerOptions.context)
|
|
66
|
+
?.guildId
|
|
67
|
+
? `Using ${(await this.guilds.fetch((this.handlerOptions.slash ||
|
|
68
|
+
this.handlerOptions.context)?.guildId || "0")).name} as local guild.`
|
|
69
|
+
: ""}`, "text", "purple"));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
register(token) {
|
|
74
|
+
this.login(token);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ContextCommandOptions, SlashCommandOptions, MessageCommandOptions } from "../interfaces/HandlerInterfaces.js";
|
|
2
|
+
import XernerxClient from "../client/XernerxClient.js";
|
|
3
|
+
import { Handler } from "./Handler.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: MessageCommandOptions): void;
|
|
17
|
+
/**
|
|
18
|
+
* @description - The slash command loader.
|
|
19
|
+
* @param {SlashCommandOptions} options - slash command loader options.
|
|
20
|
+
*/
|
|
21
|
+
loadAllSlashCommands(options: SlashCommandOptions): void;
|
|
22
|
+
/**
|
|
23
|
+
* @description - The context command loader.
|
|
24
|
+
* @param {ContextCommandOptions} options - context command loader options.
|
|
25
|
+
*/
|
|
26
|
+
loadAllContextCommands(options: ContextCommandOptions): void;
|
|
27
|
+
}
|