xernerx 3.5.1 → 3.6.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 → cjs/build}/ContextCommandBuilder.d.ts +31 -28
- package/dist/cjs/build/ContextCommandBuilder.js +97 -0
- package/dist/cjs/build/EventBuilder.js +44 -0
- package/dist/{build → cjs/build}/InhibitorBuilder.d.ts +1 -1
- package/dist/cjs/build/InhibitorBuilder.js +37 -0
- package/dist/{build → cjs/build}/MessageCommandBuilder.d.ts +23 -17
- package/dist/cjs/build/MessageCommandBuilder.js +100 -0
- package/dist/{build → cjs/build}/SlashCommandBuilder.d.ts +25 -18
- package/dist/cjs/build/SlashCommandBuilder.js +169 -0
- package/dist/{client → cjs/client}/XernerxClient.d.ts +1 -0
- package/dist/cjs/client/XernerxClient.js +120 -0
- package/dist/{handlers → cjs/handlers}/CommandHandler.js +11 -8
- package/dist/{handlers → cjs/handlers}/EventHandler.js +6 -3
- package/dist/cjs/handlers/Handler.js +308 -0
- package/dist/{handlers → cjs/handlers}/InhibitorHandler.js +6 -3
- package/dist/cjs/handlers/WebhookHandler.d.ts +7 -0
- package/dist/cjs/handlers/WebhookHandler.js +23 -0
- package/dist/{main.d.ts → cjs/main.d.ts} +15 -1
- package/dist/cjs/main.js +112 -0
- package/dist/{models → cjs/models}/CommandArguments.d.ts +1 -1
- package/dist/{models → cjs/models}/CommandArguments.js +37 -52
- package/dist/cjs/models/Events.js +309 -0
- package/dist/cjs/models/Extensions.js +26 -0
- package/dist/cjs/models/XernerxUser.d.ts +2 -0
- package/dist/cjs/models/XernerxUser.js +12 -0
- package/dist/{tools → cjs/tools}/XernerxError.js +4 -1
- package/dist/{tools → cjs/tools}/package.d.ts +4 -9
- package/dist/{tools → cjs/tools}/package.js +14 -17
- package/dist/cjs/types/enums.d.ts +44 -0
- package/dist/cjs/types/enums.js +38 -0
- package/dist/{types → cjs/types}/interfaces.d.ts +2 -0
- package/dist/cjs/types/interfaces.js +2 -0
- package/dist/{types → cjs/types}/options.d.ts +13 -0
- package/dist/cjs/types/options.js +2 -0
- package/dist/{types → cjs/types}/types.d.ts +38 -10
- package/dist/cjs/types/types.js +2 -0
- package/dist/{utils → cjs/utils}/ClientUtil.d.ts +1 -0
- package/dist/{utils → cjs/utils}/ClientUtil.js +73 -84
- package/dist/{utils → cjs/utils}/CommandUtil.d.ts +4 -2
- package/dist/{utils → cjs/utils}/CommandUtil.js +102 -103
- package/dist/{validators → cjs/validators}/CommandValidations.d.ts +6 -1
- package/dist/{validators → cjs/validators}/CommandValidations.js +36 -50
- package/dist/{validators → cjs/validators}/InhibitorValidations.js +12 -14
- package/dist/mjs/build/ContextCommandBuilder.d.ts +63 -0
- package/dist/mjs/build/ContextCommandBuilder.js +97 -0
- package/dist/mjs/build/EventBuilder.d.ts +21 -0
- package/dist/mjs/build/EventBuilder.js +44 -0
- package/dist/mjs/build/InhibitorBuilder.d.ts +19 -0
- package/dist/mjs/build/InhibitorBuilder.js +37 -0
- package/dist/mjs/build/MessageCommandBuilder.d.ts +59 -0
- package/dist/mjs/build/MessageCommandBuilder.js +100 -0
- package/dist/mjs/build/SlashCommandBuilder.d.ts +65 -0
- package/dist/mjs/build/SlashCommandBuilder.js +169 -0
- package/dist/mjs/client/XernerxClient.d.ts +29 -0
- package/dist/mjs/client/XernerxClient.js +120 -0
- package/dist/mjs/handlers/CommandHandler.d.ts +27 -0
- package/dist/mjs/handlers/CommandHandler.js +45 -0
- package/dist/mjs/handlers/EventHandler.d.ts +13 -0
- package/dist/mjs/handlers/EventHandler.js +19 -0
- package/dist/mjs/handlers/Handler.d.ts +57 -0
- package/dist/mjs/handlers/Handler.js +308 -0
- package/dist/mjs/handlers/InhibitorHandler.d.ts +18 -0
- package/dist/mjs/handlers/InhibitorHandler.js +24 -0
- package/dist/mjs/handlers/WebhookHandler.d.ts +7 -0
- package/dist/mjs/handlers/WebhookHandler.js +23 -0
- package/dist/{main.js → mjs/main.d.ts} +20 -18
- package/dist/mjs/main.js +112 -0
- package/dist/mjs/models/CommandArguments.d.ts +17 -0
- package/dist/mjs/models/CommandArguments.js +106 -0
- package/dist/mjs/models/Events.d.ts +24 -0
- package/dist/mjs/models/Events.js +309 -0
- package/dist/mjs/models/Extensions.d.ts +7 -0
- package/dist/mjs/models/Extensions.js +26 -0
- package/dist/mjs/models/XernerxUser.d.ts +2 -0
- package/dist/mjs/models/XernerxUser.js +12 -0
- package/dist/mjs/tools/XernerxError.d.ts +5 -0
- package/dist/mjs/tools/XernerxError.js +11 -0
- package/dist/mjs/tools/package.d.ts +44 -0
- package/dist/mjs/tools/package.js +45 -0
- package/dist/mjs/types/enums.d.ts +44 -0
- package/dist/mjs/types/enums.js +38 -0
- package/dist/mjs/types/interfaces.d.ts +27 -0
- package/dist/mjs/types/interfaces.js +2 -0
- package/dist/mjs/types/options.d.ts +254 -0
- package/dist/mjs/types/options.js +2 -0
- package/dist/mjs/types/types.d.ts +62 -0
- package/dist/mjs/types/types.js +2 -0
- package/dist/mjs/utils/ClientUtil.d.ts +26 -0
- package/dist/mjs/utils/ClientUtil.js +211 -0
- package/dist/mjs/utils/CommandUtil.d.ts +58 -0
- package/dist/mjs/utils/CommandUtil.js +247 -0
- package/dist/mjs/validators/CommandValidations.d.ts +12 -0
- package/dist/mjs/validators/CommandValidations.js +169 -0
- package/dist/mjs/validators/InhibitorValidations.d.ts +11 -0
- package/dist/mjs/validators/InhibitorValidations.js +40 -0
- package/package.json +11 -15
- package/dist/build/ContextCommandBuilder.js +0 -93
- package/dist/build/EventBuilder.js +0 -34
- package/dist/build/InhibitorBuilder.js +0 -27
- package/dist/build/MessageCommandBuilder.js +0 -90
- package/dist/build/SlashCommandBuilder.js +0 -125
- package/dist/client/XernerxClient.js +0 -101
- package/dist/handlers/Handler.js +0 -250
- package/dist/main.cjs +0 -2023
- package/dist/models/Events.js +0 -294
- package/dist/models/Extensions.js +0 -23
- package/dist/types/enums.d.ts +0 -35
- package/dist/types/enums.js +0 -35
- package/dist/types/interfaces.js +0 -1
- package/dist/types/options.js +0 -1
- package/dist/types/types.js +0 -1
- package/dist/validators/Shapes.js +0 -1
- /package/dist/{build → cjs/build}/EventBuilder.d.ts +0 -0
- /package/dist/{handlers → cjs/handlers}/CommandHandler.d.ts +0 -0
- /package/dist/{handlers → cjs/handlers}/EventHandler.d.ts +0 -0
- /package/dist/{handlers → cjs/handlers}/Handler.d.ts +0 -0
- /package/dist/{handlers → cjs/handlers}/InhibitorHandler.d.ts +0 -0
- /package/dist/{models → cjs/models}/Events.d.ts +0 -0
- /package/dist/{models → cjs/models}/Extensions.d.ts +0 -0
- /package/dist/{tools → cjs/tools}/XernerxError.d.ts +0 -0
- /package/dist/{validators → cjs/validators}/InhibitorValidations.d.ts +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
const discord_js_1 = require('discord.js');
|
|
4
|
+
const enums_js_1 = require('../types/enums.js');
|
|
5
|
+
function getUser(from) {
|
|
6
|
+
if (from instanceof discord_js_1.Message) return from.author;
|
|
7
|
+
else return from.user;
|
|
8
|
+
}
|
|
9
|
+
function commandValidation(action, command, client, res = false) {
|
|
10
|
+
let user = getUser(action);
|
|
11
|
+
if (client.settings.ignore?.owner && client.util.isOwner(user.id)) return res;
|
|
12
|
+
else if (inCooldown(user, client, command, action)) return true;
|
|
13
|
+
else if (command.owner && !client.util.isOwner(user.id)) {
|
|
14
|
+
res = true;
|
|
15
|
+
emit(client, action, command, 'Not an owner', client.settings.ownerId);
|
|
16
|
+
} else if (command.channelType?.length > 0 || command.channelType) {
|
|
17
|
+
if (!Array.isArray(command.channelType)) command.channelType = [command.channelType];
|
|
18
|
+
if (!command?.channelType?.includes(action.channel?.type)) {
|
|
19
|
+
res = true;
|
|
20
|
+
emit(client, action, command, 'Not the correct channel', command.channelType);
|
|
21
|
+
}
|
|
22
|
+
} else if (command.channels?.length > 0 && !command.channels.includes(action.channel?.id)) {
|
|
23
|
+
res = true;
|
|
24
|
+
emit(client, action, command, 'Not a whitelisted channel', command.channels);
|
|
25
|
+
} else if (command.guilds?.length > 0 && !command.guilds.includes(action.guild?.id)) {
|
|
26
|
+
res = true;
|
|
27
|
+
emit(client, action, command, 'Not a whitelisted guild', command.guilds);
|
|
28
|
+
} else if (command.channelType && command.channelType !== action.channel?.type) {
|
|
29
|
+
res = true;
|
|
30
|
+
emit(client, action, command, 'Not the correct type of channel', command.channelType);
|
|
31
|
+
} else if (action?.guild && (command.permissions?.user || client.settings.permissions?.user)) {
|
|
32
|
+
const permissions = command.permissions?.user || client?.settings?.permissions?.user?.push(...handlerPermissions(client, command.commandType, 'user')),
|
|
33
|
+
missing = [];
|
|
34
|
+
if (Array.isArray(permissions))
|
|
35
|
+
permissions.map((permission) => {
|
|
36
|
+
if (!(action.member?.permissions).has(permission)) {
|
|
37
|
+
missing.push(permission);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
if (missing.length > 0) {
|
|
41
|
+
res = true;
|
|
42
|
+
emit(client, action, command, 'Missing User Permissions', missing);
|
|
43
|
+
}
|
|
44
|
+
} else if (action?.guild && (command.permissions?.client || client.settings.permissions?.client)) {
|
|
45
|
+
const permissions = command.permissions?.client || client?.settings?.permissions?.client?.push(...handlerPermissions(client, command.commandType, 'client')),
|
|
46
|
+
missing = [];
|
|
47
|
+
if (Array.isArray(permissions))
|
|
48
|
+
permissions.map((permission) => {
|
|
49
|
+
if (!(action.member?.permissions).has(permission)) {
|
|
50
|
+
missing.push(permission);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
if (missing.length > 0) {
|
|
54
|
+
res = true;
|
|
55
|
+
emit(client, action, command, 'Missing Client Permissions', missing);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return res;
|
|
59
|
+
}
|
|
60
|
+
exports.default = commandValidation;
|
|
61
|
+
function emit(client, action, command, reason, extra) {
|
|
62
|
+
return client.emit('commandBlock', action, command, reason, extra);
|
|
63
|
+
}
|
|
64
|
+
function inCooldown(user, client, command, action) {
|
|
65
|
+
let res = false,
|
|
66
|
+
downs = {};
|
|
67
|
+
const { cooldowns, messageCommands, slashCommands, contextCommands, commands } = client.cache;
|
|
68
|
+
if (command.commandType === enums_js_1.CommandType.MessageCommand && client.handlerOptions.message.cooldown) {
|
|
69
|
+
if (messageCommands.has(user.id)) {
|
|
70
|
+
const usr = messageCommands.get(user.id);
|
|
71
|
+
usr.timeRemaining = usr.endsAt - Date.now();
|
|
72
|
+
downs.message = usr;
|
|
73
|
+
res = true;
|
|
74
|
+
}
|
|
75
|
+
if (!messageCommands.has(user.id)) {
|
|
76
|
+
messageCommands.set(user.id, toCooldown(action, command, client.handlerOptions.message.cooldown, user.id));
|
|
77
|
+
setInterval(() => {
|
|
78
|
+
messageCommands.delete(user.id);
|
|
79
|
+
}, client.handlerOptions.message.cooldown);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (command.commandType === enums_js_1.CommandType.SlashCommand && client.handlerOptions.slash.cooldown) {
|
|
83
|
+
if (slashCommands.has(user.id)) {
|
|
84
|
+
const usr = slashCommands.get(user.id);
|
|
85
|
+
usr.timeRemaining = usr.endsAt - Date.now();
|
|
86
|
+
downs.slash = usr;
|
|
87
|
+
res = true;
|
|
88
|
+
}
|
|
89
|
+
if (!slashCommands.has(user.id)) {
|
|
90
|
+
slashCommands.set(user.id, toCooldown(action, command, client.handlerOptions.slash.cooldown, user.id));
|
|
91
|
+
setInterval(() => {
|
|
92
|
+
slashCommands.delete(user.id);
|
|
93
|
+
}, client.handlerOptions.slash.cooldown);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (command.commandType === enums_js_1.CommandType.ContextCommand && client.handlerOptions.context.cooldown) {
|
|
97
|
+
if (contextCommands.has(user.id)) {
|
|
98
|
+
const usr = contextCommands.get(user.id);
|
|
99
|
+
usr.timeRemaining = usr.endsAt - Date.now();
|
|
100
|
+
downs.context = usr;
|
|
101
|
+
res = true;
|
|
102
|
+
}
|
|
103
|
+
if (!contextCommands.has(user.id)) {
|
|
104
|
+
contextCommands.set(user.id, toCooldown(action, command, client.handlerOptions.context.cooldown, user.id));
|
|
105
|
+
setInterval(() => {
|
|
106
|
+
contextCommands.delete(user.id);
|
|
107
|
+
}, client.handlerOptions.context.cooldown);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (client.settings?.cooldown?.default) {
|
|
111
|
+
if (cooldowns.has(user.id)) {
|
|
112
|
+
const usr = cooldowns.get(user.id);
|
|
113
|
+
usr.timeRemaining = usr.endsAt - Date.now();
|
|
114
|
+
downs.default = usr;
|
|
115
|
+
res = true;
|
|
116
|
+
}
|
|
117
|
+
if (!cooldowns.has(user.id)) {
|
|
118
|
+
cooldowns.set(user.id, toCooldown(action, command, client.settings.cooldown.default, user.id));
|
|
119
|
+
setInterval(() => {
|
|
120
|
+
cooldowns.delete(user.id);
|
|
121
|
+
}, client.settings.cooldown.default);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (command.cooldown) {
|
|
125
|
+
const name = user.id + '-' + (command.data?.name || command?.name) + '-' + command.commandType;
|
|
126
|
+
if (commands.has(name)) {
|
|
127
|
+
const usr = commands.get(name);
|
|
128
|
+
usr.timeRemaining = usr.endsAt - Date.now();
|
|
129
|
+
downs.command = usr;
|
|
130
|
+
res = true;
|
|
131
|
+
}
|
|
132
|
+
if (!commands.has(name)) {
|
|
133
|
+
commands.set(name, toCooldown(action, command, command.cooldown, name));
|
|
134
|
+
setInterval(() => {
|
|
135
|
+
commands.delete(name);
|
|
136
|
+
}, command.cooldown);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (Object.keys(downs).length > 0) client.emit('commandCooldown', action, command, downs);
|
|
140
|
+
return res;
|
|
141
|
+
}
|
|
142
|
+
function toCooldown(action, command, cooldown, name) {
|
|
143
|
+
let user = getUser(action);
|
|
144
|
+
return {
|
|
145
|
+
name,
|
|
146
|
+
id: user.id,
|
|
147
|
+
tag: user.tag,
|
|
148
|
+
commandType: command.commandType,
|
|
149
|
+
commandName: command?.data?.name || command?.name,
|
|
150
|
+
guildId: action?.guild?.id,
|
|
151
|
+
channelId: action?.channel?.id,
|
|
152
|
+
startsAt: Number(Date.now()),
|
|
153
|
+
endsAt: Number(Date.now()) + cooldown,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function handlerPermissions(client, commandType, type) {
|
|
157
|
+
let permissions = [];
|
|
158
|
+
if (commandType === enums_js_1.CommandType.MessageCommand) {
|
|
159
|
+
if (type === 'user') permissions = client.handlerOptions.message?.userPermissions || [];
|
|
160
|
+
else if (type === 'client') permissions = client.handlerOptions.message?.clientPermissions || [];
|
|
161
|
+
} else if (commandType === enums_js_1.CommandType.SlashCommand) {
|
|
162
|
+
if (type === 'user') permissions = client.handlerOptions.slash?.userPermissions || [];
|
|
163
|
+
else if (type === 'client') permissions = client.handlerOptions.slash?.clientPermissions || [];
|
|
164
|
+
} else if (commandType === enums_js_1.CommandType.ContextCommand) {
|
|
165
|
+
if (type === 'user') permissions = client.handlerOptions.context?.userPermissions || [];
|
|
166
|
+
else if (type === 'client') permissions = client.handlerOptions.context?.clientPermissions || [];
|
|
167
|
+
}
|
|
168
|
+
return permissions;
|
|
169
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import XernerxClient from '../client/XernerxClient.js';
|
|
2
|
+
import { XernerxInteraction, XernerxMessage } from '../types/types.js';
|
|
3
|
+
export declare class InhibitorValidation {
|
|
4
|
+
client: XernerxClient;
|
|
5
|
+
action: XernerxMessage | XernerxInteraction;
|
|
6
|
+
command: string;
|
|
7
|
+
inhibited: Record<string, string | void>;
|
|
8
|
+
constructor(client: XernerxClient, action: XernerxMessage | XernerxInteraction, command: string);
|
|
9
|
+
inhibit(): Promise<Record<string, string | void> | undefined>;
|
|
10
|
+
private args;
|
|
11
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.InhibitorValidation = void 0;
|
|
4
|
+
const enums_js_1 = require('../types/enums.js');
|
|
5
|
+
class InhibitorValidation {
|
|
6
|
+
client;
|
|
7
|
+
action;
|
|
8
|
+
command;
|
|
9
|
+
inhibited;
|
|
10
|
+
constructor(client, action, command) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
this.action = action;
|
|
13
|
+
this.command = command;
|
|
14
|
+
this.inhibited = {};
|
|
15
|
+
}
|
|
16
|
+
async inhibit() {
|
|
17
|
+
for (const inhibitor of this.client.inhibitors) {
|
|
18
|
+
const inhibit = inhibitor[1];
|
|
19
|
+
if (inhibit) this.inhibited[inhibit.name] = await inhibit.check(this.action, this.args(this.action, inhibit.type));
|
|
20
|
+
}
|
|
21
|
+
for (const inhibit of Object.values(this.inhibited)) {
|
|
22
|
+
if (inhibit) return this.inhibited;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
args(action, type) {
|
|
26
|
+
if (type === enums_js_1.InhibitorType.Channel) return action.channel;
|
|
27
|
+
if (type === enums_js_1.InhibitorType.User) return action.author || action.user;
|
|
28
|
+
if (type === enums_js_1.InhibitorType.Guild) return action.guild;
|
|
29
|
+
if (type === enums_js_1.InhibitorType.Member) return action.member;
|
|
30
|
+
// if (type === InhibitorType.Command)
|
|
31
|
+
// return this.client.util.getAllCommands().filter(this.command.name);
|
|
32
|
+
// if (type === InhibitorType.MessageCommand)
|
|
33
|
+
// return this.client.util.getAllMessageCommands().find(this.command.name);
|
|
34
|
+
// if (type === InhibitorType.SlashCommand)
|
|
35
|
+
// return this.client.util.getAllSlashCommands().find(this.command.name);
|
|
36
|
+
// if (type === InhibitorType.ContextCommand)
|
|
37
|
+
// return this.client.util.getAllContextCommands().find(this.command.name);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.InhibitorValidation = InhibitorValidation;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xernerx",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "3.6.0",
|
|
5
4
|
"description": "A bot framework for discord.js.",
|
|
6
|
-
"main": "dist/main.js",
|
|
5
|
+
"main": "dist/cjs/main.js",
|
|
6
|
+
"module": "dist/mjs/main.js",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"discord.js",
|
|
9
9
|
"discord",
|
|
@@ -17,13 +17,6 @@
|
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"homepage": "https://xernerx.github.io/xernerx/home.html",
|
|
19
19
|
"packageManager": "npm@8.5.5",
|
|
20
|
-
"exports": {
|
|
21
|
-
"import": "./dist/main.js",
|
|
22
|
-
"require": "./dist/main.cjs",
|
|
23
|
-
"types": "./types",
|
|
24
|
-
"node": null,
|
|
25
|
-
"default": null
|
|
26
|
-
},
|
|
27
20
|
"scripts": {
|
|
28
21
|
"start": "npm i && npm fund && npm audit fix --force && npm link && tsc -w",
|
|
29
22
|
"patch": "npm run write && git add . && npm run commit && npm version patch && npm publish && git push",
|
|
@@ -31,8 +24,11 @@
|
|
|
31
24
|
"major": "npm run write && git add . && npm run commit && npm version major && npm publish && git push",
|
|
32
25
|
"site": "git add docs && npm run commit && git push",
|
|
33
26
|
"commit": "node ../.scripts/commit.js",
|
|
34
|
-
"write": "npm run build && node ../.scripts/rewritePackage.js ",
|
|
35
|
-
"
|
|
27
|
+
"write": "npm run build && npm run format && node ../.scripts/rewritePackage.js ",
|
|
28
|
+
"format": "npx prettier --write src dist",
|
|
29
|
+
"build": "npm run build:esm && npm run build:cjs && npm run format",
|
|
30
|
+
"build:esm": "tsc",
|
|
31
|
+
"build:cjs": "tsc --module CommonJS --outDir dist/cjs"
|
|
36
32
|
},
|
|
37
33
|
"repository": {
|
|
38
34
|
"type": "git",
|
|
@@ -43,14 +39,14 @@
|
|
|
43
39
|
},
|
|
44
40
|
"dependencies": {
|
|
45
41
|
"@sapphire/shapeshift": "^3.8.1",
|
|
42
|
+
"dbl-sdk": "^1.2.0",
|
|
46
43
|
"discord.js": "^14.7.1",
|
|
47
|
-
"dumfunctions": "^2.1.
|
|
48
|
-
"xernerx-extension-builder": "^0.0.
|
|
44
|
+
"dumfunctions": "^2.1.2",
|
|
45
|
+
"xernerx-extension-builder": "^0.0.8",
|
|
49
46
|
"zod": "^3.20.6"
|
|
50
47
|
},
|
|
51
48
|
"devDependencies": {
|
|
52
49
|
"prettier": "^2.8.4",
|
|
53
|
-
"tsup": "^6.6.0",
|
|
54
50
|
"typescript": "^4.9.5"
|
|
55
51
|
}
|
|
56
52
|
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { ContextMenuCommandBuilder } from 'discord.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
4
|
-
/**
|
|
5
|
-
* @description The command builder for context commands.
|
|
6
|
-
* @param {String} id - The unique ID of the command.
|
|
7
|
-
* @param {ContextCommandOptions} options - The command options.
|
|
8
|
-
*/
|
|
9
|
-
export default class ContextCommandBuilder {
|
|
10
|
-
id;
|
|
11
|
-
data;
|
|
12
|
-
name;
|
|
13
|
-
type;
|
|
14
|
-
description;
|
|
15
|
-
info;
|
|
16
|
-
category;
|
|
17
|
-
channelType;
|
|
18
|
-
cooldown;
|
|
19
|
-
ignore;
|
|
20
|
-
strict;
|
|
21
|
-
permissions;
|
|
22
|
-
defer;
|
|
23
|
-
client;
|
|
24
|
-
constructor(id, options) {
|
|
25
|
-
this.id = id;
|
|
26
|
-
this.data = new ContextMenuCommandBuilder();
|
|
27
|
-
if (options.name)
|
|
28
|
-
this.data.setName(options.name);
|
|
29
|
-
if (options.type)
|
|
30
|
-
this.data.setType(options.type);
|
|
31
|
-
if (options.permissions?.users)
|
|
32
|
-
this.data.setDefaultMemberPermissions(options.permissions?.users);
|
|
33
|
-
if (options.permissions?.dm === false)
|
|
34
|
-
this.data.setDMPermission(options.permissions?.dm);
|
|
35
|
-
if (options.nameLocalizations)
|
|
36
|
-
this.data.setNameLocalizations(options.nameLocalizations);
|
|
37
|
-
z.object({
|
|
38
|
-
description: z.string(),
|
|
39
|
-
info: z.string(),
|
|
40
|
-
category: z.string(),
|
|
41
|
-
channelType: z.array(z.number()).or(z.number()),
|
|
42
|
-
cooldown: z.number(),
|
|
43
|
-
ignore: z.object({
|
|
44
|
-
owner: z.boolean(),
|
|
45
|
-
users: z.array(z.string()),
|
|
46
|
-
channels: z.array(z.string()),
|
|
47
|
-
guilds: z.array(z.string()),
|
|
48
|
-
}),
|
|
49
|
-
strict: z.object({
|
|
50
|
-
owner: z.boolean(),
|
|
51
|
-
users: z.array(z.string()),
|
|
52
|
-
channels: z.array(z.string()),
|
|
53
|
-
guilds: z.array(z.string()),
|
|
54
|
-
}),
|
|
55
|
-
permissions: z.object({
|
|
56
|
-
client: z.array(z.string()),
|
|
57
|
-
users: z.array(z.string()),
|
|
58
|
-
dm: z.boolean(),
|
|
59
|
-
}),
|
|
60
|
-
defer: z.object({
|
|
61
|
-
reply: z.boolean(),
|
|
62
|
-
ephemeral: z.boolean(),
|
|
63
|
-
fetch: z.boolean(),
|
|
64
|
-
}),
|
|
65
|
-
})
|
|
66
|
-
.deepPartial()
|
|
67
|
-
.parse(options);
|
|
68
|
-
this.name = options.name;
|
|
69
|
-
this.type = options.type;
|
|
70
|
-
this.description = options.description;
|
|
71
|
-
this.info = options.info;
|
|
72
|
-
this.category = options.category;
|
|
73
|
-
this.channelType = options.channelType;
|
|
74
|
-
this.cooldown = options.cooldown;
|
|
75
|
-
this.ignore = options.ignore;
|
|
76
|
-
this.strict = options.strict;
|
|
77
|
-
this.permissions = options.permissions;
|
|
78
|
-
this.defer = options.defer;
|
|
79
|
-
this.client = XernerxClient;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* @param {Interaction} interaction - The Discord interaction event data.
|
|
83
|
-
* @description make any preconditions here.
|
|
84
|
-
* TODO - update description
|
|
85
|
-
*/
|
|
86
|
-
async conditions(interaction, args) { }
|
|
87
|
-
/**
|
|
88
|
-
* @param {Interaction} interaction - The Discord interaction event data.
|
|
89
|
-
* @description Make your custom command here.
|
|
90
|
-
* TODO - update description
|
|
91
|
-
*/
|
|
92
|
-
async exec(interaction, args) { }
|
|
93
|
-
}
|
|
@@ -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,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,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,125 +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()))
|
|
96
|
-
throw new XernerxError(`Expected one of ${types.join(', ')}, received ${argument.type} instead.`);
|
|
97
|
-
let slashArgumentType = `${argument.type.slice(0, 1).toUpperCase()}${argument.type.slice(1).toLowerCase()}`;
|
|
98
|
-
command[`add${slashArgumentType}Option`]((option) => {
|
|
99
|
-
option
|
|
100
|
-
.setName(argument.name)
|
|
101
|
-
.setDescription(argument.description)
|
|
102
|
-
.setRequired(argument.required || false);
|
|
103
|
-
if (argument.choices)
|
|
104
|
-
option.setChoices(...argument?.choices);
|
|
105
|
-
return option;
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
addSubcommands(method, subcommands) {
|
|
110
|
-
for (const subcommand of subcommands) {
|
|
111
|
-
let sub = new SlashCommandSubcommandBuilder().setName(subcommand.name).setDescription(subcommand.description);
|
|
112
|
-
if (subcommand.args?.length > 0)
|
|
113
|
-
this.addArgs(sub, subcommand.args);
|
|
114
|
-
method.addSubcommand(sub);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
addSubcommandGroups(groups) {
|
|
118
|
-
for (const group of groups) {
|
|
119
|
-
let subcommandGroup = new SlashCommandSubcommandGroupBuilder().setName(group.name).setDescription(group.description);
|
|
120
|
-
if (group.subcommands?.length > 0)
|
|
121
|
-
this.addSubcommands(subcommandGroup, group.subcommands);
|
|
122
|
-
this.data.addSubcommandGroup(subcommandGroup);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|