xernerx 4.15.0 → 4.15.2
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/{cjs/utils → utils}/InteractionUtil.d.ts +1 -1
- package/dist/{mjs/utils → utils}/InteractionUtil.js +4 -3
- package/dist/{cjs/utils → utils}/MessageUtil.d.ts +1 -1
- package/dist/{mjs/utils → utils}/MessageUtil.js +4 -3
- package/package.json +3 -4
- package/dist/cjs/build/XernerxContextCommand.js +0 -124
- package/dist/cjs/build/XernerxEvent.js +0 -34
- package/dist/cjs/build/XernerxInhibitor.js +0 -30
- package/dist/cjs/build/XernerxMessageCommand.js +0 -122
- package/dist/cjs/build/XernerxSlashCommand.js +0 -180
- package/dist/cjs/client/XernerxClient.js +0 -105
- package/dist/cjs/client/XernerxShardClient.js +0 -56
- package/dist/cjs/functions/deploy.js +0 -66
- package/dist/cjs/functions/load.js +0 -38
- package/dist/cjs/functions/reload.js +0 -33
- package/dist/cjs/functions/setPresence.js +0 -24
- package/dist/cjs/functions/xernerxUser.js +0 -15
- package/dist/cjs/handlers/CommandHandler.js +0 -342
- package/dist/cjs/handlers/EventHandler.js +0 -32
- package/dist/cjs/handlers/ExtensionHandler.js +0 -32
- package/dist/cjs/handlers/Handler.js +0 -48
- package/dist/cjs/handlers/InhibitorHandler.js +0 -34
- package/dist/cjs/handlers/IntegrationHandler.js +0 -29
- package/dist/cjs/main.js +0 -36
- package/dist/cjs/models/Arguments.js +0 -159
- package/dist/cjs/models/Cooldowns.js +0 -36
- package/dist/cjs/tools/XernerxError.js +0 -14
- package/dist/cjs/tools/XernerxIntents.js +0 -27
- package/dist/cjs/tools/XernerxLog.js +0 -98
- package/dist/cjs/tools/XernerxText.js +0 -92
- package/dist/cjs/types/extenders.js +0 -3
- package/dist/cjs/types/interfaces.js +0 -3
- package/dist/cjs/types/types.js +0 -3
- package/dist/cjs/utils/ClientUtil.js +0 -84
- package/dist/cjs/utils/InteractionUtil.js +0 -156
- package/dist/cjs/utils/MessageUtil.js +0 -170
- package/dist/cjs/utils/Util.js +0 -14
- package/dist/cjs/validators/commandValidation.js +0 -127
- package/dist/cjs/validators/inhibitorValidations.js +0 -49
- package/dist/mjs/build/XernerxContextCommand.d.ts +0 -53
- package/dist/mjs/build/XernerxEvent.d.ts +0 -25
- package/dist/mjs/build/XernerxInhibitor.d.ts +0 -29
- package/dist/mjs/build/XernerxMessageCommand.d.ts +0 -57
- package/dist/mjs/build/XernerxSlashCommand.d.ts +0 -69
- package/dist/mjs/client/XernerxClient.d.ts +0 -53
- package/dist/mjs/client/XernerxShardClient.d.ts +0 -21
- package/dist/mjs/functions/deploy.d.ts +0 -3
- package/dist/mjs/functions/load.d.ts +0 -4
- package/dist/mjs/functions/reload.d.ts +0 -3
- package/dist/mjs/functions/setPresence.d.ts +0 -4
- package/dist/mjs/functions/xernerxUser.d.ts +0 -4
- package/dist/mjs/handlers/CommandHandler.d.ts +0 -16
- package/dist/mjs/handlers/EventHandler.d.ts +0 -9
- package/dist/mjs/handlers/ExtensionHandler.d.ts +0 -9
- package/dist/mjs/handlers/Handler.d.ts +0 -14
- package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -9
- package/dist/mjs/handlers/IntegrationHandler.d.ts +0 -15
- package/dist/mjs/main.d.ts +0 -40
- package/dist/mjs/models/Arguments.d.ts +0 -9
- package/dist/mjs/models/Cooldowns.d.ts +0 -11
- package/dist/mjs/tools/XernerxError.d.ts +0 -7
- package/dist/mjs/tools/XernerxIntents.d.ts +0 -5
- package/dist/mjs/tools/XernerxLog.d.ts +0 -28
- package/dist/mjs/tools/XernerxText.d.ts +0 -30
- package/dist/mjs/types/extenders.d.ts +0 -61
- package/dist/mjs/types/interfaces.d.ts +0 -256
- package/dist/mjs/types/types.d.ts +0 -14
- package/dist/mjs/utils/ClientUtil.d.ts +0 -19
- package/dist/mjs/utils/InteractionUtil.d.ts +0 -25
- package/dist/mjs/utils/MessageUtil.d.ts +0 -26
- package/dist/mjs/utils/Util.d.ts +0 -9
- package/dist/mjs/validators/commandValidation.d.ts +0 -7
- package/dist/mjs/validators/inhibitorValidations.d.ts +0 -9
- /package/dist/{cjs/build → build}/XernerxContextCommand.d.ts +0 -0
- /package/dist/{mjs/build → build}/XernerxContextCommand.js +0 -0
- /package/dist/{cjs/build → build}/XernerxEvent.d.ts +0 -0
- /package/dist/{mjs/build → build}/XernerxEvent.js +0 -0
- /package/dist/{cjs/build → build}/XernerxInhibitor.d.ts +0 -0
- /package/dist/{mjs/build → build}/XernerxInhibitor.js +0 -0
- /package/dist/{cjs/build → build}/XernerxMessageCommand.d.ts +0 -0
- /package/dist/{mjs/build → build}/XernerxMessageCommand.js +0 -0
- /package/dist/{cjs/build → build}/XernerxSlashCommand.d.ts +0 -0
- /package/dist/{mjs/build → build}/XernerxSlashCommand.js +0 -0
- /package/dist/{cjs/client → client}/XernerxClient.d.ts +0 -0
- /package/dist/{mjs/client → client}/XernerxClient.js +0 -0
- /package/dist/{cjs/client → client}/XernerxShardClient.d.ts +0 -0
- /package/dist/{mjs/client → client}/XernerxShardClient.js +0 -0
- /package/dist/{cjs/functions → functions}/deploy.d.ts +0 -0
- /package/dist/{mjs/functions → functions}/deploy.js +0 -0
- /package/dist/{cjs/functions → functions}/load.d.ts +0 -0
- /package/dist/{mjs/functions → functions}/load.js +0 -0
- /package/dist/{cjs/functions → functions}/reload.d.ts +0 -0
- /package/dist/{mjs/functions → functions}/reload.js +0 -0
- /package/dist/{cjs/functions → functions}/setPresence.d.ts +0 -0
- /package/dist/{mjs/functions → functions}/setPresence.js +0 -0
- /package/dist/{cjs/functions → functions}/xernerxUser.d.ts +0 -0
- /package/dist/{mjs/functions → functions}/xernerxUser.js +0 -0
- /package/dist/{cjs/handlers → handlers}/CommandHandler.d.ts +0 -0
- /package/dist/{mjs/handlers → handlers}/CommandHandler.js +0 -0
- /package/dist/{cjs/handlers → handlers}/EventHandler.d.ts +0 -0
- /package/dist/{mjs/handlers → handlers}/EventHandler.js +0 -0
- /package/dist/{cjs/handlers → handlers}/ExtensionHandler.d.ts +0 -0
- /package/dist/{mjs/handlers → handlers}/ExtensionHandler.js +0 -0
- /package/dist/{cjs/handlers → handlers}/Handler.d.ts +0 -0
- /package/dist/{mjs/handlers → handlers}/Handler.js +0 -0
- /package/dist/{cjs/handlers → handlers}/InhibitorHandler.d.ts +0 -0
- /package/dist/{mjs/handlers → handlers}/InhibitorHandler.js +0 -0
- /package/dist/{cjs/handlers → handlers}/IntegrationHandler.d.ts +0 -0
- /package/dist/{mjs/handlers → handlers}/IntegrationHandler.js +0 -0
- /package/dist/{cjs/main.d.ts → main.d.ts} +0 -0
- /package/dist/{mjs/main.js → main.js} +0 -0
- /package/dist/{cjs/models → models}/Arguments.d.ts +0 -0
- /package/dist/{mjs/models → models}/Arguments.js +0 -0
- /package/dist/{cjs/models → models}/Cooldowns.d.ts +0 -0
- /package/dist/{mjs/models → models}/Cooldowns.js +0 -0
- /package/dist/{cjs/tools → tools}/XernerxError.d.ts +0 -0
- /package/dist/{mjs/tools → tools}/XernerxError.js +0 -0
- /package/dist/{cjs/tools → tools}/XernerxIntents.d.ts +0 -0
- /package/dist/{mjs/tools → tools}/XernerxIntents.js +0 -0
- /package/dist/{cjs/tools → tools}/XernerxLog.d.ts +0 -0
- /package/dist/{mjs/tools → tools}/XernerxLog.js +0 -0
- /package/dist/{cjs/tools → tools}/XernerxText.d.ts +0 -0
- /package/dist/{mjs/tools → tools}/XernerxText.js +0 -0
- /package/dist/{cjs/types → types}/extenders.d.ts +0 -0
- /package/dist/{mjs/types → types}/extenders.js +0 -0
- /package/dist/{cjs/types → types}/interfaces.d.ts +0 -0
- /package/dist/{mjs/types → types}/interfaces.js +0 -0
- /package/dist/{cjs/types → types}/types.d.ts +0 -0
- /package/dist/{mjs/types → types}/types.js +0 -0
- /package/dist/{cjs/utils → utils}/ClientUtil.d.ts +0 -0
- /package/dist/{mjs/utils → utils}/ClientUtil.js +0 -0
- /package/dist/{cjs/utils → utils}/Util.d.ts +0 -0
- /package/dist/{mjs/utils → utils}/Util.js +0 -0
- /package/dist/{cjs/validators → validators}/commandValidation.d.ts +0 -0
- /package/dist/{mjs/validators → validators}/commandValidation.js +0 -0
- /package/dist/{cjs/validators → validators}/inhibitorValidations.d.ts +0 -0
- /package/dist/{mjs/validators → validators}/inhibitorValidations.js +0 -0
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @format */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const path = __importStar(require("path"));
|
|
6
|
-
const discord_js_1 = require("discord.js");
|
|
7
|
-
const Handler_js_1 = __importDefault(require("./Handler.js"));
|
|
8
|
-
const MessageUtil_js_1 = __importDefault(require("../utils/MessageUtil.js"));
|
|
9
|
-
const xernerxUser_js_1 = require("../functions/xernerxUser.js");
|
|
10
|
-
const InteractionUtil_js_1 = __importDefault(require("../utils/InteractionUtil.js"));
|
|
11
|
-
const commandValidation_js_1 = __importDefault(require("../validators/commandValidation.js"));
|
|
12
|
-
const XernerxLog_js_1 = __importDefault(require("../tools/XernerxLog.js"));
|
|
13
|
-
const Arguments_js_1 = require("../models/Arguments.js");
|
|
14
|
-
const inhibitorValidations_js_1 = require("../validators/inhibitorValidations.js");
|
|
15
|
-
const dumfunctions_1 = require("dumfunctions");
|
|
16
|
-
class CommandHandler extends Handler_js_1.default {
|
|
17
|
-
constructor(client) {
|
|
18
|
-
super(client);
|
|
19
|
-
this.readyTimestamp = Number(Date.now());
|
|
20
|
-
}
|
|
21
|
-
async loadMessageCommands(options) {
|
|
22
|
-
const commands = [];
|
|
23
|
-
if (!this.client.options.intents.has(discord_js_1.GatewayIntentBits.MessageContent))
|
|
24
|
-
new XernerxLog_js_1.default(this.client).warn(`Message commands might not work as you're missing the intent MessageContent!`);
|
|
25
|
-
if (!this.client.options.intents.has(discord_js_1.GatewayIntentBits.GuildMessages))
|
|
26
|
-
new XernerxLog_js_1.default(this.client).warn(`Message commands might not work as you're missing the intent GuildMessages!`);
|
|
27
|
-
options = zod_1.z
|
|
28
|
-
.object({
|
|
29
|
-
directory: zod_1.z.string(),
|
|
30
|
-
prefix: zod_1.z.string().or(zod_1.z.array(zod_1.z.string())),
|
|
31
|
-
allowMention: zod_1.z.boolean().default(false),
|
|
32
|
-
cooldown: zod_1.z.number().default(0),
|
|
33
|
-
permissions: zod_1.z
|
|
34
|
-
.object({
|
|
35
|
-
user: zod_1.z.array(zod_1.z.string()).or(zod_1.z.null()).default(null),
|
|
36
|
-
client: zod_1.z.array(zod_1.z.string()).or(zod_1.z.null()).default(null),
|
|
37
|
-
dm: zod_1.z.boolean().default(true),
|
|
38
|
-
})
|
|
39
|
-
.default({}),
|
|
40
|
-
handleEdits: zod_1.z.boolean().default(false),
|
|
41
|
-
handleDeletes: zod_1.z.boolean().default(false),
|
|
42
|
-
handleTyping: zod_1.z.boolean().default(false),
|
|
43
|
-
logging: zod_1.z.boolean().default(false),
|
|
44
|
-
})
|
|
45
|
-
.parse(options);
|
|
46
|
-
this.client.modules.options.message = options;
|
|
47
|
-
const files = this.readdir(options.directory);
|
|
48
|
-
for (const file of files) {
|
|
49
|
-
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
50
|
-
const command = await this.load(filepath, 'MessageCommand');
|
|
51
|
-
this._checks(command);
|
|
52
|
-
commands.push(command.id);
|
|
53
|
-
}
|
|
54
|
-
new XernerxLog_js_1.default(this.client).info(`Loaded ${dumfunctions_1.Style.log(String(files.length), { color: dumfunctions_1.Style.TextColor.Cyan })} Message Commands: ${commands.map((command) => dumfunctions_1.Style.log(command, { color: dumfunctions_1.Style.TextColor.LightYellow })).join(', ')}`);
|
|
55
|
-
this.emit({
|
|
56
|
-
name: 'messageCreate',
|
|
57
|
-
filetype: 'MessageCommand',
|
|
58
|
-
run: (message) => this.messageCommandRun(message),
|
|
59
|
-
});
|
|
60
|
-
this.emit({
|
|
61
|
-
name: 'messageUpdate',
|
|
62
|
-
filetype: 'MessageCommand',
|
|
63
|
-
run: (message, message2) => this.messageCommandRun(message, message2),
|
|
64
|
-
});
|
|
65
|
-
this.emit({
|
|
66
|
-
name: 'messageDelete',
|
|
67
|
-
filetype: 'MessageCommand',
|
|
68
|
-
run: (message) => this.messageCommandRun(message, 'delete'),
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
// public reloadMessageCommands() {
|
|
72
|
-
// return reload(this.client, 'message');
|
|
73
|
-
// }
|
|
74
|
-
async loadSlashCommands(options) {
|
|
75
|
-
const commands = [];
|
|
76
|
-
if (!this.client.settings.local)
|
|
77
|
-
new XernerxLog_js_1.default(this.client).warn(`Slash commands might not work as you haven't specified a local guild ID.`);
|
|
78
|
-
options = zod_1.z
|
|
79
|
-
.object({
|
|
80
|
-
directory: zod_1.z.string(),
|
|
81
|
-
cooldown: zod_1.z.number().default(0),
|
|
82
|
-
permissions: zod_1.z
|
|
83
|
-
.object({
|
|
84
|
-
user: zod_1.z.array(zod_1.z.string()).or(zod_1.z.null()).default(null),
|
|
85
|
-
client: zod_1.z.array(zod_1.z.string()).or(zod_1.z.null()).default(null),
|
|
86
|
-
dm: zod_1.z.boolean().default(true),
|
|
87
|
-
})
|
|
88
|
-
.default({}),
|
|
89
|
-
logging: zod_1.z.boolean().default(false),
|
|
90
|
-
defer: zod_1.z
|
|
91
|
-
.object({
|
|
92
|
-
reply: zod_1.z.boolean().default(false),
|
|
93
|
-
ephemeral: zod_1.z.boolean().default(false),
|
|
94
|
-
fetchReply: zod_1.z.boolean().default(false),
|
|
95
|
-
})
|
|
96
|
-
.default({}),
|
|
97
|
-
})
|
|
98
|
-
.parse(options);
|
|
99
|
-
this.client.modules.options.slash = options;
|
|
100
|
-
const files = this.readdir(options.directory);
|
|
101
|
-
for (const file of files) {
|
|
102
|
-
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
103
|
-
const command = await this.load(filepath, 'SlashCommand');
|
|
104
|
-
commands.push(command.id);
|
|
105
|
-
}
|
|
106
|
-
new XernerxLog_js_1.default(this.client).info(`Loaded ${dumfunctions_1.Style.log(String(files.length), { color: dumfunctions_1.Style.TextColor.Cyan })} Slash Commands: ${commands.map((command) => dumfunctions_1.Style.log(command, { color: dumfunctions_1.Style.TextColor.LightYellow })).join(', ')}`);
|
|
107
|
-
this.emit({
|
|
108
|
-
name: 'interactionCreate',
|
|
109
|
-
filetype: 'SlashCommand',
|
|
110
|
-
run: (interaction) => this.slashCommandRun(interaction),
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
async loadContextCommands(options) {
|
|
114
|
-
const commands = [];
|
|
115
|
-
if (!this.client.settings.local)
|
|
116
|
-
new XernerxLog_js_1.default(this.client).warn(`Context commands might not work as you haven't specified a local guild ID.`);
|
|
117
|
-
options = zod_1.z
|
|
118
|
-
.object({
|
|
119
|
-
directory: zod_1.z.string(),
|
|
120
|
-
cooldown: zod_1.z.number().default(0),
|
|
121
|
-
permissions: zod_1.z
|
|
122
|
-
.object({
|
|
123
|
-
user: zod_1.z.array(zod_1.z.string()).or(zod_1.z.null()).default(null),
|
|
124
|
-
client: zod_1.z.array(zod_1.z.string()).or(zod_1.z.null()).default(null),
|
|
125
|
-
dm: zod_1.z.boolean().default(true),
|
|
126
|
-
})
|
|
127
|
-
.default({}),
|
|
128
|
-
logging: zod_1.z.boolean().default(false),
|
|
129
|
-
defer: zod_1.z
|
|
130
|
-
.object({
|
|
131
|
-
reply: zod_1.z.boolean().default(false),
|
|
132
|
-
ephemeral: zod_1.z.boolean().default(false),
|
|
133
|
-
fetchReply: zod_1.z.boolean().default(false),
|
|
134
|
-
})
|
|
135
|
-
.default({}),
|
|
136
|
-
})
|
|
137
|
-
.parse(options);
|
|
138
|
-
this.client.modules.options.context = options;
|
|
139
|
-
const files = this.readdir(options.directory);
|
|
140
|
-
for (const file of files) {
|
|
141
|
-
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
142
|
-
const command = await this.load(filepath, 'ContextCommand');
|
|
143
|
-
commands.push(command.id);
|
|
144
|
-
}
|
|
145
|
-
new XernerxLog_js_1.default(this.client).info(`Loaded ${dumfunctions_1.Style.log(String(files.length), { color: dumfunctions_1.Style.TextColor.Cyan })} Context Commands: ${commands.map((command) => dumfunctions_1.Style.log(command, { color: dumfunctions_1.Style.TextColor.LightYellow })).join(', ')}`);
|
|
146
|
-
this.emit({
|
|
147
|
-
name: 'interactionCreate',
|
|
148
|
-
filetype: 'ContextCommand',
|
|
149
|
-
run: (interaction) => this.contextCommandRun(interaction),
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
async messageCommandRun(message, message2) {
|
|
153
|
-
const filetype = 'MessageCommand';
|
|
154
|
-
if (message.author.id === this.client.user?.id && this.client.settings.ignore?.self)
|
|
155
|
-
return;
|
|
156
|
-
else if (message.author.bot && this.client.settings.ignore?.bots)
|
|
157
|
-
return;
|
|
158
|
-
if (message.system && this.client.settings.ignore?.system)
|
|
159
|
-
return;
|
|
160
|
-
message.util = new MessageUtil_js_1.default(this.client, message);
|
|
161
|
-
message.user = await (0, xernerxUser_js_1.xernerxUser)(message, this.client);
|
|
162
|
-
if (await (0, inhibitorValidations_js_1.inhibitorValidation)(message, undefined, undefined, 'pre'))
|
|
163
|
-
return;
|
|
164
|
-
if (typeof message2 === 'object')
|
|
165
|
-
message = message2;
|
|
166
|
-
if (message2 === 'delete' && this.client.modules.options.message?.handleDeletes) {
|
|
167
|
-
if (!this.client.cache.messages.has(message.id))
|
|
168
|
-
return;
|
|
169
|
-
const id = this.client.cache.messages.get(message.id);
|
|
170
|
-
if (!id)
|
|
171
|
-
return;
|
|
172
|
-
(async () => {
|
|
173
|
-
const msg = await message.channel.messages.fetch(id);
|
|
174
|
-
await msg.delete();
|
|
175
|
-
this.client.cache.messages.delete(message.id);
|
|
176
|
-
})();
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
if (message.content && this.client.modules.options.message) {
|
|
180
|
-
const commands = this.client.commands.message;
|
|
181
|
-
const prefixes = Array.isArray(this.client.modules.options.message.prefix) ? this.client.modules.options.message.prefix : [this.client.modules.options.message.prefix];
|
|
182
|
-
let commandName = null, cmd, commandAlias = null, commandPrefix = null;
|
|
183
|
-
commands.map((command) => {
|
|
184
|
-
let prefix = null;
|
|
185
|
-
if (command.regex && message.content.match(command.regex)) {
|
|
186
|
-
const [match] = message.content.match(command.regex) || [null];
|
|
187
|
-
if (match)
|
|
188
|
-
commandName = command.name;
|
|
189
|
-
}
|
|
190
|
-
const cp = Array.isArray(command.prefix) ? command.prefix : [command.prefix];
|
|
191
|
-
prefixes.map((p) => {
|
|
192
|
-
if (message.content.startsWith(p))
|
|
193
|
-
prefix = p;
|
|
194
|
-
});
|
|
195
|
-
cp.map((p) => {
|
|
196
|
-
if (message.content.startsWith(p))
|
|
197
|
-
prefix = p;
|
|
198
|
-
});
|
|
199
|
-
if (!prefix)
|
|
200
|
-
return;
|
|
201
|
-
if (!commandName)
|
|
202
|
-
commandName =
|
|
203
|
-
message.content
|
|
204
|
-
.replace(prefix, '')
|
|
205
|
-
.split(command.separator || / +/)
|
|
206
|
-
.shift()
|
|
207
|
-
?.trim()
|
|
208
|
-
?.toLowerCase() || '';
|
|
209
|
-
if (!this.client.commands.message.has(commandName) && command.aliases?.includes(commandName)) {
|
|
210
|
-
commandAlias = commandName;
|
|
211
|
-
commandName = command.name;
|
|
212
|
-
}
|
|
213
|
-
commandAlias = commandAlias ? commandAlias : commandName;
|
|
214
|
-
commandPrefix = prefix;
|
|
215
|
-
});
|
|
216
|
-
if (!cmd && this.client.modules.options.message.allowMention) {
|
|
217
|
-
if (message.mentions.users.has(this.client.user?.id) || message.mentions.repliedUser?.id === this.client.user?.id) {
|
|
218
|
-
commandName =
|
|
219
|
-
message.content
|
|
220
|
-
.replace(`<@${this.client.user?.id}>`, '')
|
|
221
|
-
.trim()
|
|
222
|
-
.split(/ +/)
|
|
223
|
-
.shift()
|
|
224
|
-
?.toLowerCase() || null;
|
|
225
|
-
commands.map((command) => {
|
|
226
|
-
if (command.aliases?.includes(commandName)) {
|
|
227
|
-
commandName = command.name;
|
|
228
|
-
return (commandAlias = commandName);
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
commandPrefix = `<@${this.client.user?.id}>`;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
if (this.client.commands.message.has(commandName)) {
|
|
235
|
-
if (this.client.modules.options.message?.handleTyping)
|
|
236
|
-
message.channel.sendTyping();
|
|
237
|
-
cmd = this.client.commands.message.get(commandName);
|
|
238
|
-
}
|
|
239
|
-
if (!commandPrefix || !commandName)
|
|
240
|
-
return;
|
|
241
|
-
if (!cmd)
|
|
242
|
-
return await this.client.emit('commandNotFound', message, commandName, filetype);
|
|
243
|
-
await this.client.emit('commandStart', message, cmd);
|
|
244
|
-
const args = await (0, Arguments_js_1.messageArguments)(message, cmd, commandPrefix);
|
|
245
|
-
message.util.parsed = {
|
|
246
|
-
alias: commandAlias,
|
|
247
|
-
prefix: commandPrefix,
|
|
248
|
-
args: args.args,
|
|
249
|
-
};
|
|
250
|
-
cmd.util = message.util;
|
|
251
|
-
return await this.exec(cmd, message, args, filetype);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
async slashCommandRun(interaction) {
|
|
255
|
-
const filetype = 'SlashCommand';
|
|
256
|
-
interaction.util = new InteractionUtil_js_1.default(this.client, interaction);
|
|
257
|
-
interaction.user = await (0, xernerxUser_js_1.xernerxUser)(interaction, this.client);
|
|
258
|
-
if (await (0, inhibitorValidations_js_1.inhibitorValidation)(interaction, undefined, undefined, 'pre'))
|
|
259
|
-
return;
|
|
260
|
-
let cmd = null;
|
|
261
|
-
if (this.client.commands.slash.has(interaction.commandName))
|
|
262
|
-
cmd = this.client.commands.slash.get(interaction.commandName);
|
|
263
|
-
if (!cmd)
|
|
264
|
-
return this.client.emit('commandNotFound', interaction, interaction.commandName, filetype);
|
|
265
|
-
new Promise(async (resolve) => {
|
|
266
|
-
if (interaction.isAutocomplete()) {
|
|
267
|
-
const focused = interaction.options.getFocused(true);
|
|
268
|
-
const options = interaction.options;
|
|
269
|
-
await cmd.autocomplete(interaction, focused, options);
|
|
270
|
-
}
|
|
271
|
-
else
|
|
272
|
-
resolve(true);
|
|
273
|
-
})
|
|
274
|
-
.then(async () => {
|
|
275
|
-
await this.client.emit('commandStart', interaction);
|
|
276
|
-
const args = await (0, Arguments_js_1.interactionArguments)(interaction, cmd);
|
|
277
|
-
interaction.util.parsed = {
|
|
278
|
-
alias: [interaction.commandName, args.group || null, args.subcommand || null].filter((x) => x).join(' '),
|
|
279
|
-
args: args.args,
|
|
280
|
-
};
|
|
281
|
-
cmd.util = interaction.util;
|
|
282
|
-
return await this.exec(cmd, interaction, args, filetype);
|
|
283
|
-
})
|
|
284
|
-
.catch((error) => this.client.emit('commandError', interaction, error, cmd, filetype));
|
|
285
|
-
}
|
|
286
|
-
async contextCommandRun(interaction) {
|
|
287
|
-
const filetype = 'ContextCommand';
|
|
288
|
-
interaction.util = new InteractionUtil_js_1.default(this.client, interaction);
|
|
289
|
-
interaction.user = await (0, xernerxUser_js_1.xernerxUser)(interaction, this.client);
|
|
290
|
-
if (await (0, inhibitorValidations_js_1.inhibitorValidation)(interaction, undefined, undefined, 'pre'))
|
|
291
|
-
return;
|
|
292
|
-
let cmd;
|
|
293
|
-
if (this.client.commands.context.has(interaction.commandName))
|
|
294
|
-
cmd = this.client.commands.context.get(interaction.commandName);
|
|
295
|
-
if (!cmd)
|
|
296
|
-
return this.client.emit('commandNotFound', interaction, interaction.commandName, filetype);
|
|
297
|
-
await this.client.emit('commandStart', interaction);
|
|
298
|
-
const args = await (0, Arguments_js_1.interactionArguments)(interaction, cmd);
|
|
299
|
-
interaction.util.parsed = {
|
|
300
|
-
alias: interaction.commandName,
|
|
301
|
-
args: args,
|
|
302
|
-
};
|
|
303
|
-
cmd.util = interaction.util;
|
|
304
|
-
return await this.exec(cmd, interaction, args, filetype);
|
|
305
|
-
}
|
|
306
|
-
async exec(cmd, event, args, type) {
|
|
307
|
-
try {
|
|
308
|
-
if (cmd.filetype == 'SlashCommand' && (cmd?.defer?.reply ?? this.client.modules.options.slash?.defer?.reply)) {
|
|
309
|
-
await event.deferReply({
|
|
310
|
-
ephemeral: cmd.defer?.ephemeral || this.client.modules.options.slash?.defer?.ephemeral || false,
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
if (cmd.filetype == 'ContextCommand' && (cmd?.defer?.reply ?? this.client.modules.options.context?.defer?.reply)) {
|
|
314
|
-
await event.deferReply({
|
|
315
|
-
ephemeral: cmd.defer?.ephemeral || this.client.modules.options.context?.defer?.ephemeral || false,
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
if (await (0, commandValidation_js_1.default)(event, cmd))
|
|
319
|
-
return;
|
|
320
|
-
if (await (0, inhibitorValidations_js_1.inhibitorValidation)(event, args, cmd, 'check'))
|
|
321
|
-
return;
|
|
322
|
-
if (cmd.conditions && (await cmd.conditions(event, args)))
|
|
323
|
-
return;
|
|
324
|
-
await cmd.exec(event, args);
|
|
325
|
-
await (0, inhibitorValidations_js_1.inhibitorValidation)(event, args, cmd, 'post');
|
|
326
|
-
return await this.client.emit('commandFinish', event, cmd);
|
|
327
|
-
}
|
|
328
|
-
catch (error) {
|
|
329
|
-
new XernerxLog_js_1.default(this.client).error(`An error occurred executing ${dumfunctions_1.Style.log(cmd.name, { color: dumfunctions_1.Style.TextColor.Blue })}`, error);
|
|
330
|
-
return await this.client.emit('commandError', event, error, cmd, type);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
_checks(command) {
|
|
334
|
-
if ((command.strict?.voice || command.ignore?.voice) && !this.client.options.intents.has('GuildVoiceStates'))
|
|
335
|
-
new XernerxLog_js_1.default(this.client).warn(`${dumfunctions_1.Style.log(command.id, { color: dumfunctions_1.Style.TextColor.Blue })} options ${dumfunctions_1.Style.log(`Xernerx${command.filetype}#strict#voice`, {
|
|
336
|
-
color: dumfunctions_1.Style.BackgroundColor.Grey,
|
|
337
|
-
})} or ${dumfunctions_1.Style.log(`Xernerx${command.filetype}#ignore#voice`, {
|
|
338
|
-
color: dumfunctions_1.Style.BackgroundColor.Grey,
|
|
339
|
-
})} will misbehave due to missing the ${dumfunctions_1.Style.log('GuildVoiceStates', { color: dumfunctions_1.Style.TextColor.Yellow })} intent.`);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
exports.default = CommandHandler;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @format */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const dumfunctions_1 = require("dumfunctions");
|
|
6
|
-
const path = __importStar(require("path"));
|
|
7
|
-
const Handler_js_1 = __importDefault(require("./Handler.js"));
|
|
8
|
-
const XernerxLog_js_1 = __importDefault(require("../tools/XernerxLog.js"));
|
|
9
|
-
class EventHandler extends Handler_js_1.default {
|
|
10
|
-
constructor(client) {
|
|
11
|
-
super(client);
|
|
12
|
-
this.readyTimestamp = Number(Date.now());
|
|
13
|
-
}
|
|
14
|
-
async loadEvents(options) {
|
|
15
|
-
const events = [];
|
|
16
|
-
options = zod_1.z
|
|
17
|
-
.object({
|
|
18
|
-
directory: zod_1.z.string(),
|
|
19
|
-
})
|
|
20
|
-
.parse(options);
|
|
21
|
-
this.client.modules.options.events = options;
|
|
22
|
-
const files = this.readdir(options.directory);
|
|
23
|
-
for (const file of files) {
|
|
24
|
-
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
25
|
-
const event = await this.load(filepath, 'Event');
|
|
26
|
-
this.emit(event);
|
|
27
|
-
events.push(event.id);
|
|
28
|
-
}
|
|
29
|
-
new XernerxLog_js_1.default(this.client).info(`Loaded ${dumfunctions_1.Style.log(String(this.client.events.size), { color: dumfunctions_1.Style.TextColor.Cyan })} Events: ${events.map((event) => dumfunctions_1.Style.log(event, { color: dumfunctions_1.Style.TextColor.LightYellow })).join(', ')}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.default = EventHandler;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @format */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const dumfunctions_1 = require("dumfunctions");
|
|
5
|
-
const Handler_js_1 = __importDefault(require("./Handler.js"));
|
|
6
|
-
const XernerxLog_js_1 = __importDefault(require("../tools/XernerxLog.js"));
|
|
7
|
-
class ExtensionHandler extends Handler_js_1.default {
|
|
8
|
-
constructor(client) {
|
|
9
|
-
super(client);
|
|
10
|
-
this.readyTimestamp = Number(Date.now());
|
|
11
|
-
}
|
|
12
|
-
loadExtensions(...extensions) {
|
|
13
|
-
const active = extensions.map((extension) => {
|
|
14
|
-
try {
|
|
15
|
-
if (extension.main)
|
|
16
|
-
extension.main(this.client);
|
|
17
|
-
if (extension.defer) {
|
|
18
|
-
this.client.on('ready', (client) => extension.defer(client));
|
|
19
|
-
}
|
|
20
|
-
return extension.name;
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
return new XernerxLog_js_1.default(this.client).error(`An error occurred while loading ${dumfunctions_1.Style.log(extension.name, { color: dumfunctions_1.Style.TextColor.Red })}`, error);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
new XernerxLog_js_1.default(this.client).info(`Loaded ${dumfunctions_1.Style.log(String(extensions.length), { color: dumfunctions_1.Style.TextColor.Cyan })} Extensions: ${active
|
|
27
|
-
.filter((e) => e)
|
|
28
|
-
.map((event) => dumfunctions_1.Style.log(event, { color: dumfunctions_1.Style.TextColor.LightYellow }))
|
|
29
|
-
.join(', ')}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.default = ExtensionHandler;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @format */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const fs = __importStar(require("fs"));
|
|
5
|
-
const path = __importStar(require("path"));
|
|
6
|
-
const load_js_1 = __importDefault(require("../functions/load.js"));
|
|
7
|
-
class Handler {
|
|
8
|
-
client;
|
|
9
|
-
files;
|
|
10
|
-
constructor(client) {
|
|
11
|
-
this.client = client;
|
|
12
|
-
this.files = [];
|
|
13
|
-
}
|
|
14
|
-
readdir(dir) {
|
|
15
|
-
try {
|
|
16
|
-
return fs.readdirSync(path.resolve(dir)).filter((file) => file.endsWith('.js'));
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
console.error(error);
|
|
20
|
-
}
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
async load(filepath, type) {
|
|
24
|
-
const file = await (0, load_js_1.default)(this.client, filepath, type);
|
|
25
|
-
this.files.push(file);
|
|
26
|
-
return file;
|
|
27
|
-
}
|
|
28
|
-
async emit(event) {
|
|
29
|
-
if (!event?.filetype)
|
|
30
|
-
return;
|
|
31
|
-
if (event.filetype === 'Event') {
|
|
32
|
-
if (event.emitter === 'client')
|
|
33
|
-
event.once
|
|
34
|
-
? this.client.once(event.name, (...args) => event.run(...args))
|
|
35
|
-
: this.client.on(event.name, (...args) => event.run(...args));
|
|
36
|
-
else if (event.emitter === 'process')
|
|
37
|
-
event.once
|
|
38
|
-
? process.once(event.name, (...args) => event.run(...args))
|
|
39
|
-
: process.on(event.name, (...args) => event.run(...args));
|
|
40
|
-
}
|
|
41
|
-
if (['MessageCommand', 'SlashCommand', 'ContextCommand'].includes(event.filetype)) {
|
|
42
|
-
event.once
|
|
43
|
-
? this.client.once(event.name, (...args) => event.run(...args))
|
|
44
|
-
: this.client.on(event.name, (...args) => event.run(...args));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.default = Handler;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @format */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const path = __importStar(require("path"));
|
|
6
|
-
const dumfunctions_1 = require("dumfunctions");
|
|
7
|
-
const Handler_js_1 = __importDefault(require("./Handler.js"));
|
|
8
|
-
const XernerxLog_js_1 = __importDefault(require("../tools/XernerxLog.js"));
|
|
9
|
-
class InhibitorHandler extends Handler_js_1.default {
|
|
10
|
-
constructor(client) {
|
|
11
|
-
super(client);
|
|
12
|
-
this.readyTimestamp = Number(Date.now());
|
|
13
|
-
}
|
|
14
|
-
async loadInhibitors(options) {
|
|
15
|
-
const inhibitors = [];
|
|
16
|
-
options = zod_1.z
|
|
17
|
-
.object({
|
|
18
|
-
directory: zod_1.z.string(),
|
|
19
|
-
})
|
|
20
|
-
.parse(options);
|
|
21
|
-
this.client.modules.options.inhibitors = options;
|
|
22
|
-
const files = this.readdir(options.directory);
|
|
23
|
-
for (const file of files) {
|
|
24
|
-
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
25
|
-
const inhibitor = await this.load(filepath, 'Inhibitor');
|
|
26
|
-
this.emit(inhibitor);
|
|
27
|
-
inhibitors.push(inhibitor.id);
|
|
28
|
-
}
|
|
29
|
-
new XernerxLog_js_1.default(this.client).info(`Loaded ${dumfunctions_1.Style.log(String(this.client.inhibitors.size), { color: dumfunctions_1.Style.TextColor.Cyan })} Inhibitors: ${inhibitors
|
|
30
|
-
.map((inhibitor) => dumfunctions_1.Style.log(inhibitor, { color: dumfunctions_1.Style.TextColor.LightYellow }))
|
|
31
|
-
.join(', ')}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.default = InhibitorHandler;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @format */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const dbl_sdk_1 = __importDefault(require("dbl-sdk"));
|
|
5
|
-
const XernerxLog_js_1 = __importDefault(require("../tools/XernerxLog.js"));
|
|
6
|
-
const Handler_js_1 = __importDefault(require("./Handler.js"));
|
|
7
|
-
class IntegrationHandler extends Handler_js_1.default {
|
|
8
|
-
constructor(client) {
|
|
9
|
-
super(client);
|
|
10
|
-
this.dbl = new dbl_sdk_1.default(client, client.config);
|
|
11
|
-
this.readyTimestamp = Number(Date.now());
|
|
12
|
-
}
|
|
13
|
-
async loadIntegrations(options = { votes: true }) {
|
|
14
|
-
this.client.once('ready', async (client) => {
|
|
15
|
-
this.client.dbl.validate = (user) => this.dbl.validate(user);
|
|
16
|
-
if (options.post) {
|
|
17
|
-
this.dbl.post();
|
|
18
|
-
}
|
|
19
|
-
if (options.votes) {
|
|
20
|
-
this.dbl.votes();
|
|
21
|
-
this.client.on('dbl-sync', (client, responses) => {
|
|
22
|
-
this.client.stats.voteCount = responses.voteCount;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
new XernerxLog_js_1.default(this.client).info(`Successfully syncing with top.gg.`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.default = IntegrationHandler;
|
package/dist/cjs/main.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @format */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.XernerxLog = exports.version = exports.Discord = exports.XernerxExtension = exports.XernerxInhibitor = exports.XernerxEvent = exports.XernerxContextCommand = exports.XernerxSlashCommand = exports.XernerxMessageCommand = exports.XernerxShardClient = exports.XernerxClient = exports.XernerxIntents = void 0;
|
|
5
|
-
const fs = __importStar(require("fs"));
|
|
6
|
-
const version = JSON.parse(fs.readFileSync('node_modules/xernerx/package.json', 'utf-8')).version;
|
|
7
|
-
exports.version = version;
|
|
8
|
-
new XernerxLog_js_1.default(true).update(version, 'https://raw.githubusercontent.com/xernerx/xernerx/master/package.json');
|
|
9
|
-
const XernerxClient_js_1 = __importDefault(require("./client/XernerxClient.js"));
|
|
10
|
-
exports.XernerxClient = XernerxClient_js_1.default;
|
|
11
|
-
const XernerxShardClient_js_1 = __importDefault(require("./client/XernerxShardClient.js"));
|
|
12
|
-
exports.XernerxShardClient = XernerxShardClient_js_1.default;
|
|
13
|
-
const XernerxMessageCommand_js_1 = __importDefault(require("./build/XernerxMessageCommand.js"));
|
|
14
|
-
exports.XernerxMessageCommand = XernerxMessageCommand_js_1.default;
|
|
15
|
-
const XernerxSlashCommand_js_1 = __importDefault(require("./build/XernerxSlashCommand.js"));
|
|
16
|
-
exports.XernerxSlashCommand = XernerxSlashCommand_js_1.default;
|
|
17
|
-
const XernerxContextCommand_js_1 = __importDefault(require("./build/XernerxContextCommand.js"));
|
|
18
|
-
exports.XernerxContextCommand = XernerxContextCommand_js_1.default;
|
|
19
|
-
const XernerxEvent_js_1 = __importDefault(require("./build/XernerxEvent.js"));
|
|
20
|
-
exports.XernerxEvent = XernerxEvent_js_1.default;
|
|
21
|
-
const XernerxInhibitor_js_1 = __importDefault(require("./build/XernerxInhibitor.js"));
|
|
22
|
-
exports.XernerxInhibitor = XernerxInhibitor_js_1.default;
|
|
23
|
-
const XernerxLog_js_1 = __importDefault(require("./tools/XernerxLog.js"));
|
|
24
|
-
exports.XernerxLog = XernerxLog_js_1.default;
|
|
25
|
-
var XernerxIntents_js_1 = require("./tools/XernerxIntents.js");
|
|
26
|
-
Object.defineProperty(exports, "XernerxIntents", { enumerable: true, get: function () { return XernerxIntents_js_1.XernerxIntents; } });
|
|
27
|
-
__exportStar(require("discord.js"), exports);
|
|
28
|
-
__exportStar(require("dumfunctions"), exports);
|
|
29
|
-
const discord_js_1 = __importDefault(require("discord.js"));
|
|
30
|
-
exports.Discord = discord_js_1.default;
|
|
31
|
-
const xernerx_extension_builder_1 = __importDefault(require("xernerx-extension-builder"));
|
|
32
|
-
exports.XernerxExtension = xernerx_extension_builder_1.default;
|
|
33
|
-
__exportStar(require("./types/types.js"), exports);
|
|
34
|
-
__exportStar(require("./types/extenders.js"), exports);
|
|
35
|
-
__exportStar(require("./types/interfaces.js"), exports);
|
|
36
|
-
exports.default = XernerxClient_js_1.default;
|