xernerx 4.7.1 → 4.8.1
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/XernerxContextCommand.d.ts +2 -0
- package/dist/build/XernerxContextCommand.js +1 -0
- package/dist/build/XernerxMessageCommand.d.ts +2 -0
- package/dist/build/XernerxMessageCommand.js +1 -0
- package/dist/build/XernerxSlashCommand.d.ts +2 -0
- package/dist/build/XernerxSlashCommand.js +1 -0
- package/dist/client/XernerxClient.d.ts +1 -1
- package/dist/functions/load.js +1 -0
- package/dist/functions/reload.d.ts +2 -2
- package/dist/functions/reload.js +24 -37
- package/dist/handlers/CommandHandler.d.ts +3 -2
- package/dist/handlers/CommandHandler.js +37 -15
- package/dist/handlers/EventHandler.d.ts +1 -0
- package/dist/handlers/EventHandler.js +6 -3
- package/dist/handlers/ExtensionHandler.d.ts +1 -0
- package/dist/handlers/ExtensionHandler.js +6 -2
- package/dist/handlers/Handler.d.ts +0 -1
- package/dist/handlers/Handler.js +0 -2
- package/dist/handlers/InhibitorHandler.d.ts +1 -0
- package/dist/handlers/InhibitorHandler.js +8 -3
- package/dist/handlers/WebhookHandler.d.ts +1 -0
- package/dist/handlers/WebhookHandler.js +1 -0
- package/dist/utils/InteractionUtil.d.ts +6 -2
- package/dist/utils/InteractionUtil.js +4 -1
- package/dist/utils/MessageUtil.d.ts +3 -2
- package/dist/utils/MessageUtil.js +1 -1
- package/dist/validators/commandValidation.js +7 -7
- package/package.json +1 -1
- package/dist/build/ContextCommandBuilder.d.ts +0 -43
- package/dist/build/ContextCommandBuilder.d.ts.map +0 -1
- package/dist/build/ContextCommandBuilder.js +0 -68
- package/dist/build/ContextCommandBuilder.js.map +0 -1
- package/dist/build/EventBuilder.d.ts +0 -25
- package/dist/build/EventBuilder.d.ts.map +0 -1
- package/dist/build/EventBuilder.js +0 -30
- package/dist/build/EventBuilder.js.map +0 -1
- package/dist/build/InhibitorBuilder.d.ts +0 -20
- package/dist/build/InhibitorBuilder.d.ts.map +0 -1
- package/dist/build/InhibitorBuilder.js +0 -21
- package/dist/build/InhibitorBuilder.js.map +0 -1
- package/dist/build/MessageCommandBuilder.d.ts +0 -42
- package/dist/build/MessageCommandBuilder.d.ts.map +0 -1
- package/dist/build/MessageCommandBuilder.js +0 -61
- package/dist/build/MessageCommandBuilder.js.map +0 -1
- package/dist/build/SlashCommandBuilder.d.ts +0 -48
- package/dist/build/SlashCommandBuilder.d.ts.map +0 -1
- package/dist/build/SlashCommandBuilder.js +0 -114
- package/dist/build/SlashCommandBuilder.js.map +0 -1
- package/dist/client/XernerxClient.d.ts.map +0 -1
- package/dist/client/XernerxClient.js.map +0 -1
- package/dist/client/XernerxShardClient.d.ts.map +0 -1
- package/dist/client/XernerxShardClient.js.map +0 -1
- package/dist/functions/delay.d.ts +0 -2
- package/dist/functions/delay.d.ts.map +0 -1
- package/dist/functions/delay.js +0 -4
- package/dist/functions/delay.js.map +0 -1
- package/dist/functions/deploy.d.ts.map +0 -1
- package/dist/functions/deploy.js.map +0 -1
- package/dist/functions/isOwner.d.ts +0 -4
- package/dist/functions/isOwner.d.ts.map +0 -1
- package/dist/functions/isOwner.js +0 -4
- package/dist/functions/isOwner.js.map +0 -1
- package/dist/functions/isVoter.d.ts +0 -4
- package/dist/functions/isVoter.d.ts.map +0 -1
- package/dist/functions/isVoter.js +0 -6
- package/dist/functions/isVoter.js.map +0 -1
- package/dist/functions/load.d.ts.map +0 -1
- package/dist/functions/load.js.map +0 -1
- package/dist/functions/reload.d.ts.map +0 -1
- package/dist/functions/reload.js.map +0 -1
- package/dist/functions/sendWebhook.d.ts.map +0 -1
- package/dist/functions/sendWebhook.js.map +0 -1
- package/dist/functions/setPresence.d.ts.map +0 -1
- package/dist/functions/setPresence.js.map +0 -1
- package/dist/functions/xernerxUser.d.ts.map +0 -1
- package/dist/functions/xernerxUser.js.map +0 -1
- package/dist/handlers/CommandHandler.d.ts.map +0 -1
- package/dist/handlers/CommandHandler.js.map +0 -1
- package/dist/handlers/EventHandler.d.ts.map +0 -1
- package/dist/handlers/EventHandler.js.map +0 -1
- package/dist/handlers/ExtensionHandler.d.ts.map +0 -1
- package/dist/handlers/ExtensionHandler.js.map +0 -1
- package/dist/handlers/Handler.d.ts.map +0 -1
- package/dist/handlers/Handler.js.map +0 -1
- package/dist/handlers/InhibitorHandler.d.ts.map +0 -1
- package/dist/handlers/InhibitorHandler.js.map +0 -1
- package/dist/handlers/WebhookHandler.d.ts.map +0 -1
- package/dist/handlers/WebhookHandler.js.map +0 -1
- package/dist/main.d.ts.map +0 -1
- package/dist/main.js.map +0 -1
- package/dist/models/Arguments.d.ts.map +0 -1
- package/dist/models/Arguments.js.map +0 -1
- package/dist/tools/XernerxError.d.ts.map +0 -1
- package/dist/tools/XernerxError.js.map +0 -1
- package/dist/tools/XernerxLog.d.ts.map +0 -1
- package/dist/tools/XernerxLog.js.map +0 -1
- package/dist/types/extenders.d.ts.map +0 -1
- package/dist/types/extenders.js.map +0 -1
- package/dist/types/interfaces.d.ts.map +0 -1
- package/dist/types/interfaces.js.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/types.js.map +0 -1
- package/dist/utils/ClientUtil.d.ts.map +0 -1
- package/dist/utils/ClientUtil.js.map +0 -1
- package/dist/utils/InteractionUtil.d.ts.map +0 -1
- package/dist/utils/InteractionUtil.js.map +0 -1
- package/dist/utils/MessageUtil.d.ts.map +0 -1
- package/dist/utils/MessageUtil.js.map +0 -1
- package/dist/utils/Util.d.ts.map +0 -1
- package/dist/utils/Util.js.map +0 -1
- package/dist/validators/commandValidation.d.ts.map +0 -1
- package/dist/validators/commandValidation.js.map +0 -1
- package/dist/validators/inhibitorValidations.d.ts.map +0 -1
- package/dist/validators/inhibitorValidations.js.map +0 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { ContextMenuCommandBuilder } from 'discord.js';
|
|
3
3
|
import { XernerxMessageContextInteraction, XernerxUserContextInteraction, XernerxClientType } from '../types/extenders.js';
|
|
4
4
|
import { ContextCommandArguments, ContextCommandOptions } from '../types/interfaces.js';
|
|
5
|
+
import InteractionUtil from '../utils/InteractionUtil.js';
|
|
5
6
|
export default class XernerxContextCommand {
|
|
6
7
|
readonly id: string;
|
|
7
8
|
readonly data: ContextMenuCommandBuilder;
|
|
@@ -41,6 +42,7 @@ export default class XernerxContextCommand {
|
|
|
41
42
|
readonly filetype: 'ContextCommand';
|
|
42
43
|
readonly filepath: string;
|
|
43
44
|
readonly client: XernerxClientType;
|
|
45
|
+
util: InteractionUtil;
|
|
44
46
|
constructor(id: string, options: ContextCommandOptions);
|
|
45
47
|
/**
|
|
46
48
|
* @description the execution of the command
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @format */
|
|
2
2
|
import { XernerxClientType, XernerxMessage } from '../types/extenders.js';
|
|
3
3
|
import { MessageCommandArguments, MessageCommandOptions } from '../types/interfaces.js';
|
|
4
|
+
import MessageUtil from '../utils/MessageUtil.js';
|
|
4
5
|
export default class XernerxMessageCommand {
|
|
5
6
|
readonly id: string;
|
|
6
7
|
readonly name: string;
|
|
@@ -39,6 +40,7 @@ export default class XernerxMessageCommand {
|
|
|
39
40
|
readonly filetype: 'MessageCommand';
|
|
40
41
|
readonly filepath: string;
|
|
41
42
|
readonly client: XernerxClientType;
|
|
43
|
+
util: MessageUtil;
|
|
42
44
|
constructor(id: string, options: MessageCommandOptions);
|
|
43
45
|
/**
|
|
44
46
|
* @description Checks for conditions before running the command
|
|
@@ -99,6 +99,7 @@ export default class XernerxMessageCommand {
|
|
|
99
99
|
this.separator = options.separator;
|
|
100
100
|
this.permissions = options.permissions;
|
|
101
101
|
this.client = this.client;
|
|
102
|
+
this.util = this.util;
|
|
102
103
|
}
|
|
103
104
|
/**
|
|
104
105
|
* @description Checks for conditions before running the command
|
|
@@ -3,6 +3,7 @@ import Discord from 'discord.js';
|
|
|
3
3
|
import { XernerxClientType, XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
4
4
|
import { SlashCommandArguments, SlashCommandOptions } from '../types/interfaces.js';
|
|
5
5
|
import { XernerxInteraction } from '../types/types.js';
|
|
6
|
+
import InteractionUtil from '../utils/InteractionUtil.js';
|
|
6
7
|
export default class XernerxSlashCommand {
|
|
7
8
|
readonly id: string;
|
|
8
9
|
readonly data: Discord.SlashCommandBuilder;
|
|
@@ -41,6 +42,7 @@ export default class XernerxSlashCommand {
|
|
|
41
42
|
readonly filetype: 'SlashCommand';
|
|
42
43
|
readonly filepath: string;
|
|
43
44
|
readonly client: XernerxClientType;
|
|
45
|
+
util: InteractionUtil;
|
|
44
46
|
constructor(id: string, options: SlashCommandOptions);
|
|
45
47
|
/**
|
|
46
48
|
* @description autocomplete let's you add choices to string option arguments
|
|
@@ -115,6 +115,7 @@ export default class XernerxSlashCommand {
|
|
|
115
115
|
this.permissions = options.permissions;
|
|
116
116
|
this.defer = options.defer;
|
|
117
117
|
this.client = this.client;
|
|
118
|
+
this.util = this.util;
|
|
118
119
|
}
|
|
119
120
|
/**
|
|
120
121
|
* @description autocomplete let's you add choices to string option arguments
|
package/dist/functions/load.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** @format */
|
|
2
|
-
import XernerxClient from '../
|
|
3
|
-
export default function reload(client: XernerxClient, type: '
|
|
2
|
+
import { XernerxClient } from '../main.js';
|
|
3
|
+
export default function reload(client: XernerxClient, type: 'commands' | 'context' | 'message' | 'slash' | 'events' | 'inhibitors'): Promise<true | void | null>;
|
package/dist/functions/reload.js
CHANGED
|
@@ -1,43 +1,30 @@
|
|
|
1
1
|
/** @format */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import load from './load.js';
|
|
5
|
+
export default async function reload(client, type) {
|
|
6
|
+
switch (type) {
|
|
7
|
+
case 'message': {
|
|
8
|
+
client.commands.message.clear();
|
|
9
|
+
if (!client.modules.options.message)
|
|
10
|
+
return null;
|
|
11
|
+
const directory = path.resolve(client.modules.options.message?.directory);
|
|
12
|
+
for (const file of fs.readdirSync(directory)) {
|
|
13
|
+
load(client, `${directory}\\${file}`, 'MessageCommand');
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (type === 'event') {
|
|
19
|
-
for (const [name] of client.events) {
|
|
20
|
-
files.push(client.events.get(name).filepath);
|
|
17
|
+
case 'slash': {
|
|
18
|
+
return client.commands.slash.clear();
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
case 'context': {
|
|
21
|
+
return client.commands.context.clear();
|
|
22
|
+
}
|
|
23
|
+
case 'events': {
|
|
24
|
+
return client.events.clear();
|
|
25
|
+
}
|
|
26
|
+
case 'inhibitors': {
|
|
27
|
+
return client.inhibitors.clear();
|
|
27
28
|
}
|
|
28
|
-
client.inhibitors.sweep(() => true);
|
|
29
29
|
}
|
|
30
|
-
return files.map(async (file) => {
|
|
31
|
-
let filedata = new (await import(`file://${file}`)).default();
|
|
32
|
-
filedata.filetype = filetypes[type];
|
|
33
|
-
filedata.filepath = file;
|
|
34
|
-
filedata.client = client;
|
|
35
|
-
if (type === 'message' || type === 'slash' || type === 'context')
|
|
36
|
-
client.commands[type].set(filedata.name, filedata);
|
|
37
|
-
if (type === 'event')
|
|
38
|
-
client.events.set(filedata.name, filedata);
|
|
39
|
-
if (type === 'inhibitor')
|
|
40
|
-
client.inhibitors.set(filedata.name, filedata);
|
|
41
|
-
return filedata;
|
|
42
|
-
});
|
|
43
30
|
}
|
|
@@ -3,10 +3,11 @@ import XernerxClient from '../client/XernerxClient.js';
|
|
|
3
3
|
import { ContextHandlerOptions, MessageHandlerOptions, SlashHandlerOptions } from '../types/interfaces.js';
|
|
4
4
|
import Handler from './Handler.js';
|
|
5
5
|
export default class CommandHandler extends Handler {
|
|
6
|
+
readonly readyTimestamp: number;
|
|
6
7
|
constructor(client: XernerxClient);
|
|
7
8
|
loadMessageCommands(options: MessageHandlerOptions): Promise<void>;
|
|
8
|
-
loadSlashCommands(options: SlashHandlerOptions): void
|
|
9
|
-
loadContextCommands(options: ContextHandlerOptions): void
|
|
9
|
+
loadSlashCommands(options: SlashHandlerOptions): Promise<void>;
|
|
10
|
+
loadContextCommands(options: ContextHandlerOptions): Promise<void>;
|
|
10
11
|
private messageCommandRun;
|
|
11
12
|
private slashCommandRun;
|
|
12
13
|
private contextCommandRun;
|
|
@@ -14,8 +14,10 @@ import { Style } from 'dumfunctions';
|
|
|
14
14
|
export default class CommandHandler extends Handler {
|
|
15
15
|
constructor(client) {
|
|
16
16
|
super(client);
|
|
17
|
+
this.readyTimestamp = Number(Date.now());
|
|
17
18
|
}
|
|
18
19
|
async loadMessageCommands(options) {
|
|
20
|
+
const commands = [];
|
|
19
21
|
if (!this.client.options.intents.has(GatewayIntentBits.MessageContent))
|
|
20
22
|
new XernerxLog(this.client).warn(`Message commands might not work as you're missing the intent MessageContent!`);
|
|
21
23
|
if (!this.client.options.intents.has(GatewayIntentBits.GuildMessages))
|
|
@@ -45,8 +47,9 @@ export default class CommandHandler extends Handler {
|
|
|
45
47
|
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
46
48
|
const command = await this.load(filepath, 'MessageCommand');
|
|
47
49
|
this._checks(command);
|
|
50
|
+
commands.push(command.id);
|
|
48
51
|
}
|
|
49
|
-
new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Message Commands
|
|
52
|
+
new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Message Commands: ${commands.map((command) => Style.log(command, { color: Style.TextColor.LightYellow })).join(', ')}`);
|
|
50
53
|
this.emit({
|
|
51
54
|
name: 'messageCreate',
|
|
52
55
|
filetype: 'MessageCommand',
|
|
@@ -64,9 +67,10 @@ export default class CommandHandler extends Handler {
|
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
// public reloadMessageCommands() {
|
|
67
|
-
//
|
|
70
|
+
// return reload(this.client, 'message');
|
|
68
71
|
// }
|
|
69
|
-
loadSlashCommands(options) {
|
|
72
|
+
async loadSlashCommands(options) {
|
|
73
|
+
const commands = [];
|
|
70
74
|
if (!this.client.settings.local)
|
|
71
75
|
new XernerxLog(this.client).warn(`Slash commands might not work as you haven't specified a local guild ID.`);
|
|
72
76
|
options = z
|
|
@@ -94,16 +98,18 @@ export default class CommandHandler extends Handler {
|
|
|
94
98
|
const files = this.readdir(options.directory);
|
|
95
99
|
for (const file of files) {
|
|
96
100
|
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
97
|
-
this.load(filepath, 'SlashCommand');
|
|
101
|
+
const command = await this.load(filepath, 'SlashCommand');
|
|
102
|
+
commands.push(command.id);
|
|
98
103
|
}
|
|
99
|
-
new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Slash Commands
|
|
104
|
+
new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Slash Commands: ${commands.map((command) => Style.log(command, { color: Style.TextColor.LightYellow })).join(', ')}`);
|
|
100
105
|
this.emit({
|
|
101
106
|
name: 'interactionCreate',
|
|
102
107
|
filetype: 'SlashCommand',
|
|
103
108
|
run: (interaction) => this.slashCommandRun(interaction),
|
|
104
109
|
});
|
|
105
110
|
}
|
|
106
|
-
loadContextCommands(options) {
|
|
111
|
+
async loadContextCommands(options) {
|
|
112
|
+
const commands = [];
|
|
107
113
|
if (!this.client.settings.local)
|
|
108
114
|
new XernerxLog(this.client).warn(`Context commands might not work as you haven't specified a local guild ID.`);
|
|
109
115
|
options = z
|
|
@@ -131,9 +137,10 @@ export default class CommandHandler extends Handler {
|
|
|
131
137
|
const files = this.readdir(options.directory);
|
|
132
138
|
for (const file of files) {
|
|
133
139
|
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
134
|
-
this.load(filepath, 'ContextCommand');
|
|
140
|
+
const command = await this.load(filepath, 'ContextCommand');
|
|
141
|
+
commands.push(command.id);
|
|
135
142
|
}
|
|
136
|
-
new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Context Commands
|
|
143
|
+
new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Context Commands: ${commands.map((command) => Style.log(command, { color: Style.TextColor.LightYellow })).join(', ')}`);
|
|
137
144
|
this.emit({
|
|
138
145
|
name: 'interactionCreate',
|
|
139
146
|
filetype: 'ContextCommand',
|
|
@@ -231,12 +238,15 @@ export default class CommandHandler extends Handler {
|
|
|
231
238
|
return;
|
|
232
239
|
if (!cmd)
|
|
233
240
|
return await this.client.emit('commandNotFound', message, commandName, filetype);
|
|
241
|
+
await this.client.emit('commandStart', message, cmd);
|
|
242
|
+
const args = await messageArguments(message, cmd, commandPrefix);
|
|
234
243
|
message.util.parsed = {
|
|
235
244
|
alias: commandAlias,
|
|
236
245
|
prefix: commandPrefix,
|
|
246
|
+
args: args.args,
|
|
237
247
|
};
|
|
238
|
-
|
|
239
|
-
return await this.exec(cmd, message,
|
|
248
|
+
cmd.util = message.util;
|
|
249
|
+
return await this.exec(cmd, message, args, filetype);
|
|
240
250
|
}
|
|
241
251
|
}
|
|
242
252
|
async slashCommandRun(interaction) {
|
|
@@ -260,8 +270,14 @@ export default class CommandHandler extends Handler {
|
|
|
260
270
|
resolve(true);
|
|
261
271
|
})
|
|
262
272
|
.then(async () => {
|
|
263
|
-
this.client.emit('commandStart', interaction
|
|
264
|
-
|
|
273
|
+
await this.client.emit('commandStart', interaction);
|
|
274
|
+
const args = await interactionArguments(interaction, cmd);
|
|
275
|
+
interaction.util.parsed = {
|
|
276
|
+
alias: [interaction.commandName, args.group || '', args.subcommand || ''].join(' '),
|
|
277
|
+
args: args.args,
|
|
278
|
+
};
|
|
279
|
+
cmd.util = interaction.util;
|
|
280
|
+
return await this.exec(cmd, interaction, args, filetype);
|
|
265
281
|
})
|
|
266
282
|
.catch((error) => this.client.emit('commandError', interaction, error, cmd, filetype));
|
|
267
283
|
}
|
|
@@ -276,8 +292,14 @@ export default class CommandHandler extends Handler {
|
|
|
276
292
|
cmd = this.client.commands.context.get(interaction.commandName);
|
|
277
293
|
if (!cmd)
|
|
278
294
|
return this.client.emit('commandNotFound', interaction, interaction.commandName, filetype);
|
|
279
|
-
this.client.emit('commandStart', interaction
|
|
280
|
-
|
|
295
|
+
await this.client.emit('commandStart', interaction);
|
|
296
|
+
const args = await interactionArguments(interaction, cmd);
|
|
297
|
+
interaction.util.parsed = {
|
|
298
|
+
alias: interaction.commandName,
|
|
299
|
+
args: args,
|
|
300
|
+
};
|
|
301
|
+
cmd.util = interaction.util;
|
|
302
|
+
return await this.exec(cmd, interaction, args, filetype);
|
|
281
303
|
}
|
|
282
304
|
async exec(cmd, event, args, type) {
|
|
283
305
|
try {
|
|
@@ -299,7 +321,7 @@ export default class CommandHandler extends Handler {
|
|
|
299
321
|
return;
|
|
300
322
|
await cmd.exec(event, args);
|
|
301
323
|
await inhibitorValidation(event, args, cmd, 'post');
|
|
302
|
-
return await this.client.emit('commandFinish', event,
|
|
324
|
+
return await this.client.emit('commandFinish', event, cmd);
|
|
303
325
|
}
|
|
304
326
|
catch (error) {
|
|
305
327
|
new XernerxLog(this.client).error(`An error occurred executing ${Style.log(cmd.name, { color: Style.TextColor.Blue })}`, error);
|
|
@@ -3,6 +3,7 @@ import XernerxClient from '../client/XernerxClient.js';
|
|
|
3
3
|
import { EventHandlerOptions } from '../types/interfaces.js';
|
|
4
4
|
import Handler from './Handler.js';
|
|
5
5
|
export default class EventHandler extends Handler {
|
|
6
|
+
readonly readyTimestamp: number;
|
|
6
7
|
constructor(client: XernerxClient);
|
|
7
8
|
loadEvents(options: EventHandlerOptions): Promise<void>;
|
|
8
9
|
}
|
|
@@ -7,8 +7,10 @@ import { Style } from 'dumfunctions';
|
|
|
7
7
|
export default class EventHandler extends Handler {
|
|
8
8
|
constructor(client) {
|
|
9
9
|
super(client);
|
|
10
|
+
this.readyTimestamp = Number(Date.now());
|
|
10
11
|
}
|
|
11
12
|
async loadEvents(options) {
|
|
13
|
+
const events = [];
|
|
12
14
|
options = z
|
|
13
15
|
.object({
|
|
14
16
|
directory: z.string(),
|
|
@@ -18,9 +20,10 @@ export default class EventHandler extends Handler {
|
|
|
18
20
|
const files = this.readdir(options.directory);
|
|
19
21
|
for (const file of files) {
|
|
20
22
|
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
21
|
-
const
|
|
22
|
-
this.emit(
|
|
23
|
+
const event = await this.load(filepath, 'Event');
|
|
24
|
+
this.emit(event);
|
|
25
|
+
events.push(event.id);
|
|
23
26
|
}
|
|
24
|
-
new XernerxLog(this.client).info(`Loaded ${Style.log(String(this.client.events.size), { color: Style.TextColor.Cyan })} Events
|
|
27
|
+
new XernerxLog(this.client).info(`Loaded ${Style.log(String(this.client.events.size), { color: Style.TextColor.Cyan })} Events: ${events.map((event) => Style.log(event, { color: Style.TextColor.LightYellow })).join(', ')}`);
|
|
25
28
|
}
|
|
26
29
|
}
|
|
@@ -3,6 +3,7 @@ import XernerxExtensionBuilder from 'xernerx-extension-builder';
|
|
|
3
3
|
import XernerxClient from '../client/XernerxClient.js';
|
|
4
4
|
import Handler from './Handler.js';
|
|
5
5
|
export default class ExtensionHandler extends Handler {
|
|
6
|
+
readonly readyTimestamp: number;
|
|
6
7
|
constructor(client: XernerxClient);
|
|
7
8
|
loadExtensions(...extensions: Array<XernerxExtensionBuilder>): void;
|
|
8
9
|
}
|
|
@@ -5,6 +5,7 @@ import { Style } from 'dumfunctions';
|
|
|
5
5
|
export default class ExtensionHandler extends Handler {
|
|
6
6
|
constructor(client) {
|
|
7
7
|
super(client);
|
|
8
|
+
this.readyTimestamp = Number(Date.now());
|
|
8
9
|
}
|
|
9
10
|
loadExtensions(...extensions) {
|
|
10
11
|
const active = extensions.map((extension) => {
|
|
@@ -17,9 +18,12 @@ export default class ExtensionHandler extends Handler {
|
|
|
17
18
|
return extension.name;
|
|
18
19
|
}
|
|
19
20
|
catch (error) {
|
|
20
|
-
return new XernerxLog(this.client).error(`An error occurred while loading ${Style.log(extension.name, { color: Style.TextColor.
|
|
21
|
+
return new XernerxLog(this.client).error(`An error occurred while loading ${Style.log(extension.name, { color: Style.TextColor.Red })}`, error);
|
|
21
22
|
}
|
|
22
23
|
});
|
|
23
|
-
new XernerxLog(this.client).info(`Loaded ${Style.log(String(extensions.length), { color: Style.TextColor.Cyan })} Extensions: ${active
|
|
24
|
+
new XernerxLog(this.client).info(`Loaded ${Style.log(String(extensions.length), { color: Style.TextColor.Cyan })} Extensions: ${active
|
|
25
|
+
.filter((e) => e)
|
|
26
|
+
.map((event) => Style.log(event, { color: Style.TextColor.LightYellow }))
|
|
27
|
+
.join(', ')}`);
|
|
24
28
|
}
|
|
25
29
|
}
|
|
@@ -7,7 +7,6 @@ import { filetype } from '../types/types.js';
|
|
|
7
7
|
export default class Handler {
|
|
8
8
|
readonly client: XernerxClient;
|
|
9
9
|
readonly files: Array<MessageCommandBuilder | XernerxSlashCommand | XernerxContextCommand>;
|
|
10
|
-
readonly readyTimestamp: number;
|
|
11
10
|
constructor(client: XernerxClient);
|
|
12
11
|
readdir(dir: string): string[];
|
|
13
12
|
load(filepath: string, type: filetype): Promise<any>;
|
package/dist/handlers/Handler.js
CHANGED
|
@@ -3,6 +3,7 @@ import XernerxClient from '../client/XernerxClient.js';
|
|
|
3
3
|
import Handler from './Handler.js';
|
|
4
4
|
import { InhibitorHandlerOptions } from '../types/interfaces.js';
|
|
5
5
|
export default class InhibitorHandler extends Handler {
|
|
6
|
+
readonly readyTimestamp: number;
|
|
6
7
|
constructor(client: XernerxClient);
|
|
7
8
|
loadInhibitors(options: InhibitorHandlerOptions): Promise<void>;
|
|
8
9
|
}
|
|
@@ -7,8 +7,10 @@ import { Style } from 'dumfunctions';
|
|
|
7
7
|
export default class InhibitorHandler extends Handler {
|
|
8
8
|
constructor(client) {
|
|
9
9
|
super(client);
|
|
10
|
+
this.readyTimestamp = Number(Date.now());
|
|
10
11
|
}
|
|
11
12
|
async loadInhibitors(options) {
|
|
13
|
+
const inhibitors = [];
|
|
12
14
|
options = z
|
|
13
15
|
.object({
|
|
14
16
|
directory: z.string(),
|
|
@@ -18,9 +20,12 @@ export default class InhibitorHandler extends Handler {
|
|
|
18
20
|
const files = this.readdir(options.directory);
|
|
19
21
|
for (const file of files) {
|
|
20
22
|
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
21
|
-
const
|
|
22
|
-
this.emit(
|
|
23
|
+
const inhibitor = await this.load(filepath, 'Inhibitor');
|
|
24
|
+
this.emit(inhibitor);
|
|
25
|
+
inhibitors.push(inhibitor.id);
|
|
23
26
|
}
|
|
24
|
-
new XernerxLog(this.client).info(`Loaded ${Style.log(String(this.client.inhibitors.size), { color: Style.TextColor.Cyan })} Inhibitors
|
|
27
|
+
new XernerxLog(this.client).info(`Loaded ${Style.log(String(this.client.inhibitors.size), { color: Style.TextColor.Cyan })} Inhibitors: ${inhibitors
|
|
28
|
+
.map((inhibitor) => Style.log(inhibitor, { color: Style.TextColor.LightYellow }))
|
|
29
|
+
.join(', ')}`);
|
|
25
30
|
}
|
|
26
31
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/** @format */
|
|
2
2
|
import { EmbedBuilder, InteractionEditReplyOptions, InteractionReplyOptions, MessagePayload } from 'discord.js';
|
|
3
3
|
import XernerxClient from '../client/XernerxClient.js';
|
|
4
|
-
import { PaginatorOptions } from '../types/interfaces.js';
|
|
4
|
+
import { ContextCommandArguments, PaginatorOptions, SlashCommandArguments } from '../types/interfaces.js';
|
|
5
5
|
import { XernerxInteraction } from '../types/types.js';
|
|
6
6
|
import Util from './Util.js';
|
|
7
7
|
import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
8
8
|
export default class InteractionUtil extends Util {
|
|
9
|
-
private interaction;
|
|
9
|
+
private readonly interaction;
|
|
10
|
+
parsed: {
|
|
11
|
+
alias: string | null;
|
|
12
|
+
args: (SlashCommandArguments | ContextCommandArguments<'message' | 'user'>) | null;
|
|
13
|
+
};
|
|
10
14
|
constructor(client: XernerxClient, interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>);
|
|
11
15
|
send(content: any): Promise<import("discord.js").Message<false> | import("discord.js").Message<true> | undefined>;
|
|
12
16
|
reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions): Promise<import("discord.js").InteractionResponse<boolean> | import("discord.js").Message<boolean>>;
|
|
@@ -3,10 +3,13 @@ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder }
|
|
|
3
3
|
import Util from './Util.js';
|
|
4
4
|
import XernerxError from '../tools/XernerxError.js';
|
|
5
5
|
export default class InteractionUtil extends Util {
|
|
6
|
-
interaction;
|
|
7
6
|
constructor(client, interaction) {
|
|
8
7
|
super(client);
|
|
9
8
|
this.interaction = interaction;
|
|
9
|
+
this.parsed = {
|
|
10
|
+
alias: null,
|
|
11
|
+
args: null,
|
|
12
|
+
};
|
|
10
13
|
}
|
|
11
14
|
async send(content) {
|
|
12
15
|
if (!content)
|
|
@@ -7,8 +7,9 @@ import { PaginatorOptions } from '../main.js';
|
|
|
7
7
|
export default class MessageUtil extends Util {
|
|
8
8
|
private readonly message;
|
|
9
9
|
parsed: {
|
|
10
|
-
alias:
|
|
11
|
-
prefix:
|
|
10
|
+
alias: string | null;
|
|
11
|
+
prefix: string | null;
|
|
12
|
+
args: Record<string, unknown> | null;
|
|
12
13
|
};
|
|
13
14
|
constructor(client: XernerxClient, message: XernerxMessage);
|
|
14
15
|
send(content: any): Promise<import("discord.js").Message<boolean> | null>;
|
|
@@ -4,13 +4,13 @@ import Util from './Util.js';
|
|
|
4
4
|
import sendWebhook from '../functions/sendWebhook.js';
|
|
5
5
|
import XernerxError from '../tools/XernerxError.js';
|
|
6
6
|
export default class MessageUtil extends Util {
|
|
7
|
-
message;
|
|
8
7
|
constructor(client, message) {
|
|
9
8
|
super(client);
|
|
10
9
|
this.message = message;
|
|
11
10
|
this.parsed = {
|
|
12
11
|
alias: null,
|
|
13
12
|
prefix: null,
|
|
13
|
+
args: null,
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
async send(content) {
|
|
@@ -89,25 +89,25 @@ export default async function commandValidation(event, command) {
|
|
|
89
89
|
message: `\`${command.name}\` can't be used in a DM Channel`,
|
|
90
90
|
}, command);
|
|
91
91
|
if (userPermissions) {
|
|
92
|
-
const missing = userPermissions.map(permission => (event.member?.permissions).has(toBigInt([permission])) ? null : permission).filter(x => x);
|
|
92
|
+
const missing = userPermissions.map((permission) => ((event.member?.permissions).has(toBigInt([permission])) ? null : permission)).filter((x) => x);
|
|
93
93
|
const desired = (event.member?.permissions).has(toBigInt(userPermissions));
|
|
94
94
|
if (!desired)
|
|
95
95
|
return await emit(event, {
|
|
96
96
|
reason: 'missingUserPermissions',
|
|
97
|
-
message: `You are missing the following permissions to run \`${command.name}\`:\n${missing.map(permission => `> - ${permission}`).join('\n')}`,
|
|
97
|
+
message: `You are missing the following permissions to run \`${command.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
|
|
98
98
|
required: userPermissions,
|
|
99
|
-
missing
|
|
99
|
+
missing,
|
|
100
100
|
}, command);
|
|
101
101
|
}
|
|
102
102
|
if (clientPermissions) {
|
|
103
|
-
const missing = clientPermissions.map(permission => event.guild?.members.me?.permissions.has(toBigInt([permission])) ? null : permission).filter(x => x);
|
|
104
|
-
const desired =
|
|
103
|
+
const missing = clientPermissions.map((permission) => (event.guild?.members.me?.permissions.has(toBigInt([permission])) ? null : permission)).filter((x) => x);
|
|
104
|
+
const desired = event.guild?.members.me?.permissions?.has(toBigInt(clientPermissions));
|
|
105
105
|
if (!desired)
|
|
106
106
|
return await emit(event, {
|
|
107
107
|
reason: 'missingClientPermissions',
|
|
108
|
-
message: `I am missing the following permissions to run \`${command.name}\`:\n${missing.map(permission => `> - ${permission}`).join('\n')}`,
|
|
108
|
+
message: `I am missing the following permissions to run \`${command.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
|
|
109
109
|
required: clientPermissions,
|
|
110
|
-
missing
|
|
110
|
+
missing,
|
|
111
111
|
}, command);
|
|
112
112
|
}
|
|
113
113
|
if ((!command.global || !client.settings.global) && client.settings.local !== event.guild?.id)
|
package/package.json
CHANGED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ContextMenuCommandBuilder } from 'discord.js';
|
|
2
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
3
|
-
import { XernerxMessageContextInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
4
|
-
import { ContextCommandArguments, ContextCommandOptions } from '../types/interfaces.js';
|
|
5
|
-
export default class ContextCommandBuilder {
|
|
6
|
-
readonly id: string;
|
|
7
|
-
readonly data: ContextMenuCommandBuilder;
|
|
8
|
-
readonly name: string;
|
|
9
|
-
readonly type: 'user' | 'message';
|
|
10
|
-
readonly description: string | null | undefined;
|
|
11
|
-
readonly usage: string | null | undefined;
|
|
12
|
-
readonly info: string | null | undefined;
|
|
13
|
-
readonly category: string | null | undefined;
|
|
14
|
-
readonly cooldown: number | null | undefined;
|
|
15
|
-
readonly ignore: {
|
|
16
|
-
owner?: boolean | undefined;
|
|
17
|
-
users?: string[] | undefined;
|
|
18
|
-
channels?: string[] | undefined;
|
|
19
|
-
guilds?: string[] | undefined;
|
|
20
|
-
} | undefined;
|
|
21
|
-
readonly strict: {
|
|
22
|
-
owner?: boolean | undefined;
|
|
23
|
-
users?: string[] | undefined;
|
|
24
|
-
channels?: string[] | undefined;
|
|
25
|
-
guilds?: string[] | undefined;
|
|
26
|
-
} | undefined;
|
|
27
|
-
readonly permissions: {
|
|
28
|
-
user?: string[] | import("../main.js").PermissionNames[] | undefined;
|
|
29
|
-
client?: string[] | import("../main.js").PermissionNames[] | undefined;
|
|
30
|
-
dm?: boolean | undefined;
|
|
31
|
-
} | undefined;
|
|
32
|
-
readonly defer: {
|
|
33
|
-
reply?: boolean | undefined;
|
|
34
|
-
ephemeral?: boolean | undefined;
|
|
35
|
-
fetchReply?: boolean | undefined;
|
|
36
|
-
} | undefined;
|
|
37
|
-
readonly fileType: 'ContextCommand';
|
|
38
|
-
readonly filePath: string;
|
|
39
|
-
readonly client: typeof XernerxClient;
|
|
40
|
-
constructor(id: string, options: ContextCommandOptions);
|
|
41
|
-
exec<T>(interaction: XernerxUserContextInteraction | XernerxMessageContextInteraction, args: ContextCommandArguments<'user' | 'message'>): Promise<void | any | T>;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=ContextCommandBuilder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContextCommandBuilder.d.ts","sourceRoot":"","sources":["../../src/build/ContextCommandBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAGvD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,gCAAgC,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAExF,MAAM,CAAC,OAAO,OAAO,qBAAqB;IACtC,SAAwB,EAAE,SAAC;IAC3B,SAAwB,IAAI,4BAAC;IAC7B,SAAwB,IAAI,SAAC;IAC7B,SAAwB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACjD,SAAwB,WAAW,4BAAC;IACpC,SAAwB,KAAK,4BAAC;IAC9B,SAAwB,IAAI,4BAAC;IAC7B,SAAwB,QAAQ,4BAAC;IACjC,SAAwB,QAAQ,4BAAC;IACjC,SAAwB,MAAM;;;;;kBAAC;IAC/B,SAAwB,MAAM;;;;;kBAAC;IAC/B,SAAwB,WAAW;;;;kBAAC;IACpC,SAAwB,KAAK;;;;kBAAC;IAC9B,SAAwB,QAAQ,EAAE,gBAAgB,CAAC;IACnD,SAAwB,QAAQ,EAAE,MAAM,CAAC;IACzC,SAAwB,MAAM,uBAAC;gBAEZ,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB;IAgFhD,IAAI,CAAC,CAAC,EAAE,WAAW,EAAE,6BAA6B,GAAG,gCAAgC,EAAE,IAAI,EAAE,uBAAuB,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC;CAClL"}
|