xernerx 4.0.5 → 4.2.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/SlashCommandBuilder.d.ts +1 -0
- package/dist/build/SlashCommandBuilder.js +1 -0
- package/dist/client/XernerxClient.d.ts +5 -4
- package/dist/client/XernerxClient.js +2 -10
- package/dist/functions/deploy.js +20 -16
- package/dist/handlers/CommandHandler.js +39 -16
- package/dist/handlers/EventHandler.js +1 -1
- package/dist/handlers/ExtensionHandler.js +1 -1
- package/dist/handlers/InhibitorHandler.js +1 -1
- package/dist/main.d.ts +3 -2
- package/dist/main.js +3 -2
- package/dist/tools/XernerxLog.d.ts +1 -0
- package/dist/tools/XernerxLog.js +26 -8
- package/dist/types/extenders.d.ts +11 -6
- package/dist/types/interfaces.d.ts +23 -19
- package/dist/utils/ClientUtil.d.ts +2 -1
- package/dist/utils/ClientUtil.js +10 -1
- package/dist/utils/MessageUtil.d.ts +4 -1
- package/dist/utils/MessageUtil.js +4 -2
- package/package.json +1 -1
- package/dist/build copy/ContextCommandBuilder.d.ts +0 -37
- package/dist/build copy/ContextCommandBuilder.js +0 -88
- package/dist/build copy/EventBuilder.d.ts +0 -21
- package/dist/build copy/EventBuilder.js +0 -34
- package/dist/build copy/InhibitorBuilder.d.ts +0 -19
- package/dist/build copy/InhibitorBuilder.js +0 -27
- package/dist/build copy/MessageCommandBuilder.d.ts +0 -39
- package/dist/build copy/MessageCommandBuilder.js +0 -90
- package/dist/build copy/SlashCommandBuilder.d.ts +0 -41
- package/dist/build copy/SlashCommandBuilder.js +0 -122
- package/dist/client/DBLClient.d.ts +0 -8
- package/dist/client/DBLClient.js +0 -15
- package/dist/client/Top.ggClient.d.ts +0 -1
- package/dist/client/Top.ggClient.js +0 -1
- package/dist/events/messageCreate.d.ts +0 -1
- package/dist/events/messageCreate.js +0 -1
- package/dist/functions/AsyncFunctions.d.ts +0 -1
- package/dist/functions/AsyncFunctions.js +0 -1
- package/dist/functions/getPermissionBitField.d.ts +0 -2
- package/dist/functions/getPermissionBitField.js +0 -17
- package/dist/functions/hasVoted.d.ts +0 -1
- package/dist/functions/hasVoted.js +0 -1
- package/dist/functions/voted.d.ts +0 -1
- package/dist/functions/voted.js +0 -1
- package/dist/models/CommandArguments.d.ts +0 -17
- package/dist/models/CommandArguments.js +0 -101
- package/dist/models/Events.d.ts +0 -24
- package/dist/models/Events.js +0 -297
- package/dist/models/Extensions.d.ts +0 -7
- package/dist/models/Extensions.js +0 -23
- package/dist/models/XernerxUser.d.ts +0 -2
- package/dist/models/XernerxUser.js +0 -9
- package/dist/tools/classes.d.ts +0 -6
- package/dist/tools/classes.js +0 -10
- package/dist/tools/loggers.d.ts +0 -4
- package/dist/tools/loggers.js +0 -4
- package/dist/tools/package.d.ts +0 -42
- package/dist/tools/package.js +0 -41
- package/dist/types/enums.d.ts +0 -44
- package/dist/types/enums.js +0 -35
- package/dist/types/options.d.ts +0 -254
- package/dist/types/options.js +0 -1
- package/dist/utils/CommandUtil.d.ts +0 -58
- package/dist/utils/CommandUtil.js +0 -232
- package/dist/utils/InteractionArguments.d.ts +0 -1
- package/dist/utils/InteractionArguments.js +0 -1
- package/dist/validators/CommandValidations.d.ts +0 -12
- package/dist/validators/CommandValidations.js +0 -166
- package/dist/validators/commands.d.ts +0 -4
- package/dist/validators/commands.js +0 -25
- /package/dist/validators/{InhibitorValidations.d.ts → inhibitorValidations.d.ts} +0 -0
- /package/dist/validators/{InhibitorValidations.js → inhibitorValidations.js} +0 -0
|
@@ -42,6 +42,7 @@ export default class SlashCommandBuilder {
|
|
|
42
42
|
| undefined;
|
|
43
43
|
client: typeof XernerxClient;
|
|
44
44
|
constructor(id: string, options: SlashCommandOptions);
|
|
45
|
+
autocomplete<T>(interaction: XernerxSlashInteraction, focused: T, options: Array<T>): Promise<void>;
|
|
45
46
|
conditions(interaction: XernerxSlashInteraction, args: SlashCommandArguments): Promise<void>;
|
|
46
47
|
exec(interaction: XernerxSlashInteraction, args: SlashCommandArguments): Promise<void>;
|
|
47
48
|
private addArguments;
|
|
@@ -82,6 +82,7 @@ export default class SlashCommandBuilder {
|
|
|
82
82
|
this.defer = options.defer;
|
|
83
83
|
this.client = XernerxClient;
|
|
84
84
|
}
|
|
85
|
+
async autocomplete(interaction, focused, options) {}
|
|
85
86
|
async conditions(interaction, args) {}
|
|
86
87
|
async exec(interaction, args) {}
|
|
87
88
|
addArguments(command, args) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Client, ClientOptions, Collection } from 'discord.js';
|
|
2
2
|
import { XernerxOptions, ModuleOptions, XernerxCommands, XernerxCache } from '../types/interfaces.js';
|
|
3
3
|
import ClientUtil from '../utils/ClientUtil.js';
|
|
4
|
-
import { InhibitorBuilder } from '../main.js';
|
|
4
|
+
import { InhibitorBuilder, EventBuilder } from '../main.js';
|
|
5
5
|
export default class XernerxClient extends Client {
|
|
6
6
|
readonly settings: {
|
|
7
7
|
ownerId: (string | string[]) & (string | string[] | undefined);
|
|
8
|
-
local: string;
|
|
9
8
|
global: boolean;
|
|
9
|
+
local?: string | undefined;
|
|
10
10
|
permissions?:
|
|
11
11
|
| {
|
|
12
12
|
client: string[];
|
|
@@ -27,6 +27,7 @@ export default class XernerxClient extends Client {
|
|
|
27
27
|
ready: boolean;
|
|
28
28
|
error: boolean;
|
|
29
29
|
info: boolean;
|
|
30
|
+
table: string[] | null;
|
|
30
31
|
}
|
|
31
32
|
| undefined;
|
|
32
33
|
cooldown?:
|
|
@@ -38,7 +39,7 @@ export default class XernerxClient extends Client {
|
|
|
38
39
|
};
|
|
39
40
|
readonly config: unknown;
|
|
40
41
|
readonly commands: XernerxCommands;
|
|
41
|
-
readonly events: Collection<
|
|
42
|
+
readonly events: Collection<string, EventBuilder>;
|
|
42
43
|
readonly inhibitors: Collection<string, InhibitorBuilder>;
|
|
43
44
|
readonly modules: ModuleOptions;
|
|
44
45
|
readonly util: ClientUtil;
|
|
@@ -49,6 +50,6 @@ export default class XernerxClient extends Client {
|
|
|
49
50
|
shardCount: number;
|
|
50
51
|
};
|
|
51
52
|
readonly cache: XernerxCache;
|
|
52
|
-
constructor(discordOptions: ClientOptions, xernerxOptions: XernerxOptions, config
|
|
53
|
+
constructor(discordOptions: ClientOptions, xernerxOptions: XernerxOptions, config?: unknown);
|
|
53
54
|
connect(token: string): void;
|
|
54
55
|
}
|
|
@@ -8,20 +8,11 @@ import XernerxLog from '../tools/XernerxLog.js';
|
|
|
8
8
|
import ClientUtil from '../utils/ClientUtil.js';
|
|
9
9
|
import ExtensionHandler from '../handlers/ExtensionHandler.js';
|
|
10
10
|
export default class XernerxClient extends Client {
|
|
11
|
-
settings;
|
|
12
|
-
config;
|
|
13
|
-
commands;
|
|
14
|
-
events;
|
|
15
|
-
inhibitors;
|
|
16
|
-
modules;
|
|
17
|
-
util;
|
|
18
|
-
stats;
|
|
19
|
-
cache;
|
|
20
11
|
constructor(discordOptions, xernerxOptions, config) {
|
|
21
12
|
super(discordOptions);
|
|
22
13
|
this.settings = z
|
|
23
14
|
.object({
|
|
24
|
-
local: z.string(),
|
|
15
|
+
local: z.string().optional(),
|
|
25
16
|
global: z.boolean().default(false),
|
|
26
17
|
ownerId: z.string().or(z.array(z.string())).default([]),
|
|
27
18
|
permissions: z
|
|
@@ -44,6 +35,7 @@ export default class XernerxClient extends Client {
|
|
|
44
35
|
ready: z.boolean().default(false),
|
|
45
36
|
info: z.boolean().default(false),
|
|
46
37
|
error: z.boolean().default(false),
|
|
38
|
+
table: z.array(z.string()).or(z.null()).default(null),
|
|
47
39
|
})
|
|
48
40
|
.optional(),
|
|
49
41
|
cooldown: z
|
package/dist/functions/deploy.js
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
import { GatewayVersion, REST, Routes } from 'discord.js';
|
|
2
2
|
import XernerxLog from '../tools/XernerxLog.js';
|
|
3
|
-
|
|
3
|
+
import XernerxError from '../tools/XernerxError.js';
|
|
4
|
+
const commands = { slash: [], context: [] };
|
|
4
5
|
export default function deploy(client, type) {
|
|
5
6
|
client.prependOnceListener('ready', (client) => {
|
|
6
7
|
commands[type] = client.commands[type].map((command) => command.data.toJSON());
|
|
7
|
-
if (commands.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
} catch (error) {
|
|
17
|
-
new XernerxLog(client).error(`An error occurred while deploying the interaction commands!`, error);
|
|
18
|
-
} finally {
|
|
19
|
-
new XernerxLog(client).info(`Deployed All Commands ${client.settings.global ? 'globally' : 'locally'}.`);
|
|
8
|
+
if (!(!!client.modules.options.slash && !!client.modules.options.context && commands.slash.length > 0 && commands.context.length > 0)) return;
|
|
9
|
+
try {
|
|
10
|
+
if (client.settings.global) {
|
|
11
|
+
put(client, client.settings.global, [...commands.slash, ...commands.context]);
|
|
12
|
+
put(client, !client.settings.global, []);
|
|
13
|
+
} else {
|
|
14
|
+
put(client, !client.settings.global, [...commands.slash, ...commands.context]);
|
|
15
|
+
put(client, client.settings.global, []);
|
|
20
16
|
}
|
|
17
|
+
} catch (error) {
|
|
18
|
+
new XernerxLog(client).error(`An error occurred while deploying the interaction commands!`, error);
|
|
19
|
+
} finally {
|
|
20
|
+
new XernerxLog(client).info(
|
|
21
|
+
`Deployed ${[client.commands.message.size, client.commands.slash.size, client.commands.context.size].reduce((a, b) => (a += b))} Commands ${
|
|
22
|
+
client.settings.global ? 'globally' : 'locally'
|
|
23
|
+
}.`
|
|
24
|
+
);
|
|
21
25
|
}
|
|
22
|
-
commands.retries++;
|
|
23
26
|
});
|
|
24
27
|
}
|
|
25
28
|
function put(client, global, body) {
|
|
26
29
|
const rest = new REST({ version: GatewayVersion }).setToken(client.token);
|
|
27
|
-
if (!global
|
|
30
|
+
if (!global && !client.settings?.local) throw new XernerxError(`No guild ID provided as local guild!`);
|
|
31
|
+
if (!global && client.settings?.local) rest.put(Routes.applicationGuildCommands(client.user?.id, client.settings.local), { body });
|
|
28
32
|
else rest.put(Routes.applicationCommands(client.user?.id), { body });
|
|
29
33
|
}
|
|
@@ -42,7 +42,7 @@ export default class CommandHandler extends Handler {
|
|
|
42
42
|
const filePath = `${path.resolve(options.directory)}\\${file}`;
|
|
43
43
|
this.load(filePath, 'MessageCommand');
|
|
44
44
|
}
|
|
45
|
-
new XernerxLog(this.client).info(`Loaded Message Commands.`);
|
|
45
|
+
new XernerxLog(this.client).info(`Loaded ${files.length} Message Commands.`);
|
|
46
46
|
this.emit({
|
|
47
47
|
name: 'messageCreate',
|
|
48
48
|
fileType: 'MessageCommand',
|
|
@@ -63,6 +63,7 @@ export default class CommandHandler extends Handler {
|
|
|
63
63
|
// return reload(this.client, 'message');
|
|
64
64
|
// }
|
|
65
65
|
loadSlashCommands(options) {
|
|
66
|
+
if (!this.client.settings.local) new XernerxLog(this.client).warn(`Slash commands might not work as you haven't specified a local guild ID.`);
|
|
66
67
|
options = z
|
|
67
68
|
.object({
|
|
68
69
|
directory: z.string(),
|
|
@@ -90,7 +91,7 @@ export default class CommandHandler extends Handler {
|
|
|
90
91
|
const filePath = `${path.resolve(options.directory)}\\${file}`;
|
|
91
92
|
this.load(filePath, 'SlashCommand');
|
|
92
93
|
}
|
|
93
|
-
new XernerxLog(this.client).info(`Loaded Slash Commands.`);
|
|
94
|
+
new XernerxLog(this.client).info(`Loaded ${files.length} Slash Commands.`);
|
|
94
95
|
deploy(this.client, 'slash');
|
|
95
96
|
this.emit({
|
|
96
97
|
name: 'interactionCreate',
|
|
@@ -99,6 +100,7 @@ export default class CommandHandler extends Handler {
|
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
loadContextCommands(options) {
|
|
103
|
+
if (!this.client.settings.local) new XernerxLog(this.client).warn(`Context commands might not work as you haven't specified a local guild ID.`);
|
|
102
104
|
options = z
|
|
103
105
|
.object({
|
|
104
106
|
directory: z.string(),
|
|
@@ -126,7 +128,7 @@ export default class CommandHandler extends Handler {
|
|
|
126
128
|
const filePath = `${path.resolve(options.directory)}\\${file}`;
|
|
127
129
|
this.load(filePath, 'ContextCommand');
|
|
128
130
|
}
|
|
129
|
-
new XernerxLog(this.client).info(`Loaded Context Commands.`);
|
|
131
|
+
new XernerxLog(this.client).info(`Loaded ${files.length} Context Commands.`);
|
|
130
132
|
deploy(this.client, 'context');
|
|
131
133
|
this.emit({
|
|
132
134
|
name: 'interactionCreate',
|
|
@@ -135,6 +137,7 @@ export default class CommandHandler extends Handler {
|
|
|
135
137
|
});
|
|
136
138
|
}
|
|
137
139
|
async messageCommandRun(message, message2) {
|
|
140
|
+
const filetype = 'MessageCommand';
|
|
138
141
|
if (message.author.bot) return;
|
|
139
142
|
message.util = new MessageUtil(this.client, message);
|
|
140
143
|
message.user = await xernerxUser(message, this.client);
|
|
@@ -153,9 +156,10 @@ export default class CommandHandler extends Handler {
|
|
|
153
156
|
if (message.content && this.client.modules.options.message) {
|
|
154
157
|
const commands = this.client.commands.message;
|
|
155
158
|
const prefixes = Array.isArray(this.client.modules.options.message.prefix) ? this.client.modules.options.message.prefix : [this.client.modules.options.message.prefix];
|
|
156
|
-
let commandName,
|
|
159
|
+
let commandName = null,
|
|
157
160
|
cmd,
|
|
158
|
-
|
|
161
|
+
commandAlias = null,
|
|
162
|
+
commandPrefix = null;
|
|
159
163
|
commands.map((command) => {
|
|
160
164
|
let prefix = null;
|
|
161
165
|
if (command.regex && message.content.match(command.regex)) {
|
|
@@ -179,47 +183,66 @@ export default class CommandHandler extends Handler {
|
|
|
179
183
|
?.trim()
|
|
180
184
|
?.toLowerCase() || '';
|
|
181
185
|
if (!this.client.commands.message.has(commandName) && command.aliases?.includes(commandName)) {
|
|
182
|
-
|
|
186
|
+
commandAlias = commandName;
|
|
183
187
|
commandName = command.name;
|
|
184
188
|
}
|
|
189
|
+
commandAlias = commandAlias ? commandAlias : commandName;
|
|
190
|
+
commandPrefix = prefix;
|
|
185
191
|
});
|
|
186
192
|
if (!cmd && this.client.modules.options.message.allowMention) {
|
|
187
193
|
if (message.mentions.users.has(this.client.user?.id) || message.mentions.repliedUser?.id === this.client.user?.id) {
|
|
188
|
-
commandName = message.content.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift()?.toLowerCase();
|
|
194
|
+
commandName = message.content.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift()?.toLowerCase() || null;
|
|
189
195
|
}
|
|
190
196
|
}
|
|
191
|
-
if (!commandName) commandName = '';
|
|
192
197
|
if (this.client.commands.message.has(commandName)) cmd = this.client.commands.message.get(commandName);
|
|
193
198
|
if (await inhibitorValidation(message, cmd)) return;
|
|
194
|
-
if (!cmd) return this.client.emit('commandNotFound');
|
|
195
|
-
message.util.
|
|
196
|
-
|
|
199
|
+
if (!cmd) return this.client.emit('commandNotFound', message, filetype);
|
|
200
|
+
message.util.parsed = {
|
|
201
|
+
alias: commandAlias,
|
|
202
|
+
prefix: commandPrefix,
|
|
203
|
+
};
|
|
204
|
+
this.client.emit('commandStart', message, filetype);
|
|
205
|
+
this.exec(cmd, message, await messageArguments(message, cmd), filetype);
|
|
197
206
|
}
|
|
198
207
|
}
|
|
199
208
|
async slashCommandRun(interaction) {
|
|
209
|
+
const filetype = 'SlashCommand';
|
|
200
210
|
interaction.util = new InteractionUtil(this.client, interaction);
|
|
201
211
|
interaction.user = await xernerxUser(interaction, this.client);
|
|
202
|
-
let cmd;
|
|
212
|
+
let cmd = null;
|
|
203
213
|
if (this.client.commands.slash.has(interaction.commandName)) cmd = this.client.commands.slash.get(interaction.commandName);
|
|
204
214
|
if (await inhibitorValidation(interaction, cmd)) return;
|
|
205
215
|
if (!cmd) return this.client.emit('commandNotFound', interaction);
|
|
206
|
-
|
|
216
|
+
new Promise(async (resolve) => {
|
|
217
|
+
if (interaction.isAutocomplete()) {
|
|
218
|
+
const focused = interaction.options.getFocused(true);
|
|
219
|
+
const options = interaction.options;
|
|
220
|
+
await cmd.autocomplete(interaction, focused, options);
|
|
221
|
+
} else resolve(true);
|
|
222
|
+
})
|
|
223
|
+
.then(async () => {
|
|
224
|
+
this.client.emit('commandStart', interaction, filetype);
|
|
225
|
+
await this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
|
|
226
|
+
})
|
|
227
|
+
.catch((error) => this.client.emit('commandError', interaction, error, filetype));
|
|
207
228
|
}
|
|
208
229
|
async contextCommandRun(interaction) {
|
|
230
|
+
const filetype = 'ContextCommand';
|
|
209
231
|
interaction.util = new InteractionUtil(this.client, interaction);
|
|
210
232
|
interaction.user = await xernerxUser(interaction, this.client);
|
|
211
233
|
let cmd;
|
|
212
234
|
if (this.client.commands.context.has(interaction.commandName)) cmd = this.client.commands.context.get(interaction.commandName);
|
|
213
235
|
if (await inhibitorValidation(interaction, cmd)) return;
|
|
214
|
-
if (!cmd) return this.client.emit('commandNotFound', interaction);
|
|
215
|
-
this.
|
|
236
|
+
if (!cmd) return this.client.emit('commandNotFound', interaction, filetype);
|
|
237
|
+
this.client.emit('commandStart', interaction, filetype);
|
|
238
|
+
this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
|
|
216
239
|
}
|
|
217
240
|
async exec(cmd, event, args, type) {
|
|
218
241
|
try {
|
|
219
242
|
if (await commandValidation(event, cmd)) return;
|
|
220
243
|
if (cmd.conditions && (await cmd.conditions(event, args))) return;
|
|
221
244
|
cmd.exec(event, args);
|
|
222
|
-
this.client.emit('
|
|
245
|
+
this.client.emit('commandFinish', event, type);
|
|
223
246
|
} catch (error) {
|
|
224
247
|
new XernerxLog(this.client).error(`An error occurred executing ${cmd.name}`, error);
|
|
225
248
|
this.client.emit('commandError', event, error, type);
|
|
@@ -19,6 +19,6 @@ export default class EventHandler extends Handler {
|
|
|
19
19
|
const data = await this.load(filePath, 'Event');
|
|
20
20
|
this.emit(data);
|
|
21
21
|
}
|
|
22
|
-
new XernerxLog(this.client).info(`Loaded Events.`);
|
|
22
|
+
new XernerxLog(this.client).info(`Loaded ${this.client.events.size} Events.`);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -14,6 +14,6 @@ export default class ExtensionHandler extends Handler {
|
|
|
14
14
|
new XernerxLog(this.client).error(`An error occurred while loading ${extension.name}`, error);
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
-
new XernerxLog(this.client).info(`Loaded Extensions: ${active.filter((e) => e).join(', ')}`);
|
|
17
|
+
new XernerxLog(this.client).info(`Loaded ${extensions.length} Extensions: ${active.filter((e) => e).join(', ')}`);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -19,6 +19,6 @@ export default class InhibitorHandler extends Handler {
|
|
|
19
19
|
const data = await this.load(filePath, 'Inhibitor');
|
|
20
20
|
this.emit(data);
|
|
21
21
|
}
|
|
22
|
-
new XernerxLog(this.client).info(`Loaded Inhibitors.`);
|
|
22
|
+
new XernerxLog(this.client).info(`Loaded ${this.client.inhibitors.size} Inhibitors.`);
|
|
23
23
|
}
|
|
24
24
|
}
|
package/dist/main.d.ts
CHANGED
|
@@ -4,10 +4,11 @@ import SlashCommandBuilder from './build/SlashCommandBuilder.js';
|
|
|
4
4
|
import ContextCommandBuilder from './build/ContextCommandBuilder.js';
|
|
5
5
|
import EventBuilder from './build/EventBuilder.js';
|
|
6
6
|
import InhibitorBuilder from './build/InhibitorBuilder.js';
|
|
7
|
+
import XernerxLog from './tools/XernerxLog.js';
|
|
7
8
|
export default XernerxClient;
|
|
8
9
|
export * from 'discord.js';
|
|
9
10
|
export * from 'dumfunctions';
|
|
10
11
|
import ExtensionBuilder from 'xernerx-extension-builder';
|
|
11
12
|
import Discord from 'discord.js';
|
|
12
|
-
declare const version = '4.0
|
|
13
|
-
export { XernerxClient, MessageCommandBuilder, SlashCommandBuilder, ContextCommandBuilder, EventBuilder, InhibitorBuilder, ExtensionBuilder, Discord, version };
|
|
13
|
+
declare const version = '4.2.0';
|
|
14
|
+
export { XernerxClient, MessageCommandBuilder, SlashCommandBuilder, ContextCommandBuilder, EventBuilder, InhibitorBuilder, ExtensionBuilder, Discord, version, XernerxLog };
|
package/dist/main.js
CHANGED
|
@@ -4,10 +4,11 @@ import SlashCommandBuilder from './build/SlashCommandBuilder.js';
|
|
|
4
4
|
import ContextCommandBuilder from './build/ContextCommandBuilder.js';
|
|
5
5
|
import EventBuilder from './build/EventBuilder.js';
|
|
6
6
|
import InhibitorBuilder from './build/InhibitorBuilder.js';
|
|
7
|
+
import XernerxLog from './tools/XernerxLog.js';
|
|
7
8
|
export default XernerxClient;
|
|
8
9
|
export * from 'discord.js';
|
|
9
10
|
export * from 'dumfunctions';
|
|
10
11
|
import ExtensionBuilder from 'xernerx-extension-builder';
|
|
11
12
|
import Discord from 'discord.js';
|
|
12
|
-
const version = '4.0
|
|
13
|
-
export { XernerxClient, MessageCommandBuilder, SlashCommandBuilder, ContextCommandBuilder, EventBuilder, InhibitorBuilder, ExtensionBuilder, Discord, version };
|
|
13
|
+
const version = '4.2.0';
|
|
14
|
+
export { XernerxClient, MessageCommandBuilder, SlashCommandBuilder, ContextCommandBuilder, EventBuilder, InhibitorBuilder, ExtensionBuilder, Discord, version, XernerxLog };
|
|
@@ -5,6 +5,7 @@ export default class XernerxLog {
|
|
|
5
5
|
private readonly errorLog;
|
|
6
6
|
private readonly infoLog;
|
|
7
7
|
private readonly readyLog;
|
|
8
|
+
private readonly tableLog;
|
|
8
9
|
constructor(client: XernerxClient);
|
|
9
10
|
info(message: string, force?: boolean): void | null;
|
|
10
11
|
warn(message: string): void | null;
|
package/dist/tools/XernerxLog.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { Style } from 'dumfunctions';
|
|
2
2
|
export default class XernerxLog {
|
|
3
|
-
client;
|
|
4
|
-
errorLog;
|
|
5
|
-
infoLog;
|
|
6
|
-
readyLog;
|
|
7
3
|
constructor(client) {
|
|
8
4
|
this.client = client;
|
|
9
5
|
this.errorLog = client.settings.log?.error;
|
|
10
6
|
this.infoLog = client.settings.log?.info;
|
|
11
7
|
this.readyLog = client.settings.log?.ready;
|
|
8
|
+
this.tableLog = client.settings.log?.table;
|
|
12
9
|
}
|
|
13
10
|
info(message, force = false) {
|
|
14
11
|
return this.infoLog || force ? console.info(`${Style.log('✔️ | Xernerx', { color: Style.TextColor.Purple })} | ${message}`) : null;
|
|
@@ -20,11 +17,32 @@ export default class XernerxLog {
|
|
|
20
17
|
return this.errorLog ? console.error(`${Style.log('❗ | Xernerx', { color: Style.TextColor.Red })} | ${message}${error ? ` | ${error.stack}` : ''}`) : null;
|
|
21
18
|
}
|
|
22
19
|
ready() {
|
|
23
|
-
this.client.prependOnceListener('ready', async (synced) =>
|
|
20
|
+
this.client.prependOnceListener('ready', async (synced) => {
|
|
24
21
|
this.info(
|
|
25
|
-
`${synced.user.tag} is now online, watching ${(await this.client.guilds.fetch()).size} guilds, using ${
|
|
22
|
+
`${synced.user.tag} is now online, watching ${(await this.client.guilds.fetch()).size} guilds, using ${
|
|
23
|
+
this.client.settings.local ? await this.client.guilds.fetch(this.client.settings.local) : 'none'
|
|
24
|
+
} as local guild.`,
|
|
26
25
|
this.readyLog
|
|
27
|
-
)
|
|
28
|
-
|
|
26
|
+
);
|
|
27
|
+
const files = [];
|
|
28
|
+
for (const [id, data] of this.client.commands.message) {
|
|
29
|
+
files.push(data);
|
|
30
|
+
}
|
|
31
|
+
for (const [id, data] of this.client.commands.slash) {
|
|
32
|
+
files.push(data);
|
|
33
|
+
}
|
|
34
|
+
for (const [id, data] of this.client.commands.context) {
|
|
35
|
+
files.push(data);
|
|
36
|
+
}
|
|
37
|
+
for (const [id, data] of this.client.events) {
|
|
38
|
+
files.push(data);
|
|
39
|
+
}
|
|
40
|
+
for (const [id, data] of this.client.inhibitors) {
|
|
41
|
+
files.push(data);
|
|
42
|
+
}
|
|
43
|
+
if (this.tableLog) {
|
|
44
|
+
console.table(files, this.tableLog);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
29
47
|
}
|
|
30
48
|
}
|
|
@@ -11,13 +11,18 @@ export interface XernerxMember extends GuildMember {
|
|
|
11
11
|
export interface XernerxGuild extends Guild {}
|
|
12
12
|
export interface XernerxGuildChannel extends GuildChannel {}
|
|
13
13
|
export interface XernerxDMChannel extends DMChannel {}
|
|
14
|
-
interface XernerxCommand {
|
|
15
|
-
util: InteractionUtil | MessageUtil;
|
|
16
|
-
}
|
|
14
|
+
interface XernerxCommand {}
|
|
17
15
|
export interface XernerxMessage extends Message, XernerxCommand {
|
|
18
16
|
user: XernerxUser;
|
|
17
|
+
util: MessageUtil;
|
|
18
|
+
}
|
|
19
|
+
export interface XernerxSlashInteraction extends ChatInputCommandInteraction, XernerxCommand {
|
|
20
|
+
util: InteractionUtil;
|
|
21
|
+
}
|
|
22
|
+
export interface XernerxUserContextInteraction extends UserContextMenuCommandInteraction, XernerxCommand {
|
|
23
|
+
util: InteractionUtil;
|
|
24
|
+
}
|
|
25
|
+
export interface XernerxMessageContextInteraction extends MessageContextMenuCommandInteraction, XernerxCommand {
|
|
26
|
+
util: InteractionUtil;
|
|
19
27
|
}
|
|
20
|
-
export interface XernerxSlashInteraction extends ChatInputCommandInteraction, XernerxCommand {}
|
|
21
|
-
export interface XernerxUserContextInteraction extends UserContextMenuCommandInteraction, XernerxCommand {}
|
|
22
|
-
export interface XernerxMessageContextInteraction extends MessageContextMenuCommandInteraction, XernerxCommand {}
|
|
23
28
|
export {};
|
|
@@ -9,25 +9,29 @@ import SlashCommandBuilder from '../build/SlashCommandBuilder.js';
|
|
|
9
9
|
import { Locales, MessageCommandArgumentType, PermissionNames, SlashCommandArgumentType, EventType, InhibitorType } from './types.js';
|
|
10
10
|
import ExtensionHandler from '../handlers/ExtensionHandler.js';
|
|
11
11
|
export interface XernerxOptions {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
local?: string;
|
|
13
|
+
global?: boolean;
|
|
14
|
+
ownerId?: string | Array<string>;
|
|
15
|
+
permissions?: {
|
|
16
|
+
client?: Array<string>;
|
|
17
|
+
user?: Array<string>;
|
|
18
|
+
dm?: boolean;
|
|
19
|
+
};
|
|
20
|
+
ignore?: {
|
|
21
|
+
owner?: boolean;
|
|
22
|
+
users?: Array<string>;
|
|
23
|
+
channels?: Array<string>;
|
|
24
|
+
guilds?: Array<string>;
|
|
25
|
+
};
|
|
26
|
+
log?: {
|
|
27
|
+
ready?: boolean;
|
|
28
|
+
info?: boolean;
|
|
29
|
+
error?: boolean;
|
|
30
|
+
table?: Array<'name' | 'aliases' | 'description' | 'fileType' | 'category'>;
|
|
31
|
+
};
|
|
32
|
+
cooldown?: {
|
|
33
|
+
command?: number;
|
|
34
|
+
cache?: number;
|
|
31
35
|
};
|
|
32
36
|
}
|
|
33
37
|
export interface ModuleOptions {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import XernerxClient from '../
|
|
1
|
+
import XernerxClient from '../client/XernerxClient.js';
|
|
2
2
|
import { PresenceOptions } from '../types/interfaces.js';
|
|
3
3
|
import Util from './Util.js';
|
|
4
4
|
export default class ClientUtil extends Util {
|
|
5
5
|
hasVoted?: Function;
|
|
6
6
|
constructor(client: XernerxClient);
|
|
7
7
|
setPresence(options: PresenceOptions): import('discord.js').ClientPresence | undefined;
|
|
8
|
+
resolveChannel(query: string | Record<string, string>): Promise<import('discord.js').Channel | null>;
|
|
8
9
|
}
|
package/dist/utils/ClientUtil.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import setPresence from '../functions/setPresence.js';
|
|
2
2
|
import Util from './Util.js';
|
|
3
3
|
export default class ClientUtil extends Util {
|
|
4
|
-
hasVoted;
|
|
5
4
|
constructor(client) {
|
|
6
5
|
super(client);
|
|
7
6
|
}
|
|
8
7
|
setPresence(options) {
|
|
9
8
|
return setPresence(this.client, options);
|
|
10
9
|
}
|
|
10
|
+
async resolveChannel(query) {
|
|
11
|
+
if (typeof query == 'object') query = query.id;
|
|
12
|
+
try {
|
|
13
|
+
let channel = this.client.channels.cache.find((channel) => (channel.name == query.toLowerCase() || channel.id == query.toLowerCase() ? channel : null)) || null;
|
|
14
|
+
if (!channel) channel = (await this.client.channels.fetch(query)) || null;
|
|
15
|
+
return channel;
|
|
16
|
+
} catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
11
20
|
}
|
|
@@ -4,7 +4,10 @@ import { XernerxMessage } from '../types/extenders.js';
|
|
|
4
4
|
import Util from './Util.js';
|
|
5
5
|
export default class MessageUtil extends Util {
|
|
6
6
|
private readonly message;
|
|
7
|
-
|
|
7
|
+
parsed: {
|
|
8
|
+
alias: null | string;
|
|
9
|
+
prefix: null | string;
|
|
10
|
+
};
|
|
8
11
|
constructor(client: XernerxClient, message: XernerxMessage);
|
|
9
12
|
reply(content: MessagePayload): Promise<import('discord.js').Message<boolean> | undefined>;
|
|
10
13
|
webhookReply(content: MessagePayload, url?: URL, user?: User): Promise<void>;
|
|
@@ -5,11 +5,13 @@ import sendWebhook from '../functions/sendWebhook.js';
|
|
|
5
5
|
import XernerxError from '../tools/XernerxError.js';
|
|
6
6
|
export default class MessageUtil extends Util {
|
|
7
7
|
message;
|
|
8
|
-
alias;
|
|
9
8
|
constructor(client, message) {
|
|
10
9
|
super(client);
|
|
11
10
|
this.message = message;
|
|
12
|
-
this.
|
|
11
|
+
this.parsed = {
|
|
12
|
+
alias: null,
|
|
13
|
+
prefix: null,
|
|
14
|
+
};
|
|
13
15
|
}
|
|
14
16
|
async reply(content) {
|
|
15
17
|
if (this.client.cache.messages.has(this.message.id)) {
|
package/package.json
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ContextMenuCommandBuilder, Interaction } from 'discord.js';
|
|
2
|
-
import { ContextCommandOptions } from '../types/options.js';
|
|
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: string;
|
|
11
|
-
data: ContextMenuCommandBuilder;
|
|
12
|
-
name: any;
|
|
13
|
-
type: any;
|
|
14
|
-
description: any;
|
|
15
|
-
info: any;
|
|
16
|
-
category: any;
|
|
17
|
-
channelType: any;
|
|
18
|
-
cooldown: any;
|
|
19
|
-
ignore: any;
|
|
20
|
-
strict: any;
|
|
21
|
-
permissions: any;
|
|
22
|
-
defer: any;
|
|
23
|
-
client: typeof XernerxClient;
|
|
24
|
-
constructor(id: string, options: ContextCommandOptions);
|
|
25
|
-
/**
|
|
26
|
-
* @param {Interaction} interaction - The Discord interaction event data.
|
|
27
|
-
* @description make any preconditions here.
|
|
28
|
-
* TODO - update description
|
|
29
|
-
*/
|
|
30
|
-
conditions(interaction: Interaction, args: any): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* @param {Interaction} interaction - The Discord interaction event data.
|
|
33
|
-
* @description Make your custom command here.
|
|
34
|
-
* TODO - update description
|
|
35
|
-
*/
|
|
36
|
-
exec(interaction: Interaction, args: any): Promise<void>;
|
|
37
|
-
}
|