xernerx 4.17.3 → 4.17.5
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 +75 -47
- package/dist/build/XernerxContextCommand.js +119 -115
- package/dist/build/XernerxEvent.d.ts +10 -10
- package/dist/build/XernerxEvent.js +17 -17
- package/dist/build/XernerxInhibitor.d.ts +39 -15
- package/dist/build/XernerxInhibitor.js +18 -18
- package/dist/build/XernerxMessageCommand.d.ts +78 -52
- package/dist/build/XernerxMessageCommand.js +118 -114
- package/dist/build/XernerxSlashCommand.d.ts +96 -62
- package/dist/build/XernerxSlashCommand.js +176 -172
- package/dist/client/XernerxClient.d.ts +55 -45
- package/dist/client/XernerxClient.js +83 -88
- package/dist/client/XernerxShardClient.d.ts +14 -14
- package/dist/client/XernerxShardClient.js +61 -47
- package/dist/functions/deploy.js +45 -52
- package/dist/functions/load.js +28 -29
- package/dist/functions/reload.js +23 -24
- package/dist/functions/setPresence.d.ts +1 -1
- package/dist/functions/setPresence.js +17 -16
- package/dist/functions/xernerxUser.js +5 -6
- package/dist/handlers/CommandHandler.d.ts +10 -10
- package/dist/handlers/CommandHandler.js +311 -336
- package/dist/handlers/EventHandler.d.ts +3 -3
- package/dist/handlers/EventHandler.js +48 -21
- package/dist/handlers/ExtensionHandler.d.ts +3 -3
- package/dist/handlers/ExtensionHandler.js +23 -23
- package/dist/handlers/Handler.d.ts +19 -14
- package/dist/handlers/Handler.js +46 -50
- package/dist/handlers/InhibitorHandler.d.ts +3 -3
- package/dist/handlers/InhibitorHandler.js +25 -23
- package/dist/handlers/IntegrationHandler.d.ts +6 -6
- package/dist/handlers/IntegrationHandler.js +20 -20
- package/dist/main.d.ts +28 -21
- package/dist/main.js +28 -21
- package/dist/models/Arguments.d.ts +4 -1
- package/dist/models/Arguments.js +134 -149
- package/dist/models/Cooldowns.d.ts +6 -6
- package/dist/models/Cooldowns.js +25 -29
- package/dist/tools/XernerxError.d.ts +4 -4
- package/dist/tools/XernerxError.js +8 -8
- package/dist/tools/XernerxIntents.d.ts +2 -2
- package/dist/tools/XernerxIntents.js +21 -21
- package/dist/tools/XernerxLog.d.ts +23 -23
- package/dist/tools/XernerxLog.js +125 -110
- package/dist/tools/XernerxText.d.ts +23 -23
- package/dist/tools/XernerxText.js +79 -89
- package/dist/types/extenders.d.ts +55 -47
- package/dist/types/interfaces.d.ts +192 -189
- package/dist/types/types.d.ts +104 -5
- package/dist/utils/ClientUtil.d.ts +12 -9
- package/dist/utils/ClientUtil.js +96 -79
- package/dist/utils/InteractionUtil.d.ts +13 -13
- package/dist/utils/InteractionUtil.js +148 -147
- package/dist/utils/MessageUtil.d.ts +14 -14
- package/dist/utils/MessageUtil.js +162 -161
- package/dist/utils/Util.d.ts +4 -4
- package/dist/utils/Util.js +7 -7
- package/dist/validators/commandValidation.d.ts +4 -1
- package/dist/validators/commandValidation.js +157 -114
- package/dist/validators/inhibitorValidations.d.ts +21 -2
- package/dist/validators/inhibitorValidations.js +39 -39
- package/package.json +3 -3
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/** @format */
|
|
2
2
|
import { ShardingManager, ShardingManagerOptions, ClientUser } from 'discord.js';
|
|
3
3
|
interface XernerxOptions {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
log?: {
|
|
5
|
+
info?: boolean;
|
|
6
|
+
};
|
|
7
|
+
timeout?: number;
|
|
8
8
|
}
|
|
9
9
|
export default class XernerxShardClient extends ShardingManager {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
readonly stats: {
|
|
11
|
+
guildCount: number;
|
|
12
|
+
userCount: number;
|
|
13
|
+
shardCount: number;
|
|
14
|
+
voteCount: number;
|
|
15
|
+
shards: {};
|
|
16
|
+
};
|
|
17
|
+
user: ClientUser | null;
|
|
18
|
+
spawner: Promise<import('discord.js').Collection<number, import('discord.js').Shard>>;
|
|
19
|
+
constructor(file: string, discordOptions: ShardingManagerOptions, xernerxOptions?: XernerxOptions, data?: unknown);
|
|
20
20
|
}
|
|
21
21
|
export {};
|
|
@@ -3,51 +3,65 @@ import { ShardingManager } from 'discord.js';
|
|
|
3
3
|
import { Style } from 'dumfunctions';
|
|
4
4
|
import XernerxLog from '../tools/XernerxLog.js';
|
|
5
5
|
export default class XernerxShardClient extends ShardingManager {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
6
|
+
constructor(file, discordOptions, xernerxOptions, data = {}) {
|
|
7
|
+
super(file, discordOptions);
|
|
8
|
+
this.stats = { guildCount: 0, userCount: 0, shardCount: 0, voteCount: 0, shards: {} };
|
|
9
|
+
this.user = null;
|
|
10
|
+
new XernerxLog(true).info('Starting sharding process...');
|
|
11
|
+
this.on('shardCreate', async (shard) => {
|
|
12
|
+
shard
|
|
13
|
+
.on('ready', async () => {
|
|
14
|
+
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
15
|
+
const stats = await shard.fetchClientValue('stats');
|
|
16
|
+
this.stats.shards[String(shard.id)] = stats;
|
|
17
|
+
this.user = await shard.fetchClientValue('user');
|
|
18
|
+
this.stats.guildCount += stats.guildCount;
|
|
19
|
+
this.stats.userCount += stats.userCount;
|
|
20
|
+
this.stats.shardCount++;
|
|
21
|
+
this.stats.voteCount = stats.voteCount;
|
|
22
|
+
shard.send({ type: 'xernerx', data: { shardId: shard.id, sharded: true } });
|
|
23
|
+
shard.send({ type: 'client', data });
|
|
24
|
+
new XernerxLog({ settings: xernerxOptions }).info(
|
|
25
|
+
`Launched shard ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} for ${Style.log(this.user?.tag, { color: Style.TextColor.Blue })}! ${
|
|
26
|
+
xernerxOptions?.timeout ? `Automatically killing in ${Style.log(String(xernerxOptions.timeout), { color: Style.TextColor.Cyan })}ms.` : ''
|
|
27
|
+
}`
|
|
28
|
+
);
|
|
29
|
+
})
|
|
30
|
+
.on('error', (error) => {
|
|
31
|
+
new XernerxLog({ settings: xernerxOptions }).info(
|
|
32
|
+
`An error occurred in ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} for ${Style.log(String(this.user?.tag), { color: Style.TextColor.Blue })}! ${error}`
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
if (xernerxOptions?.timeout)
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
new XernerxLog({ settings: xernerxOptions }).warn(
|
|
38
|
+
`Automatically killing shard ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} on ${Style.log(String(shard.manager.user?.tag), {
|
|
39
|
+
color: Style.TextColor.Blue,
|
|
40
|
+
})}!`
|
|
41
|
+
);
|
|
42
|
+
shard.kill();
|
|
43
|
+
}, xernerxOptions.timeout);
|
|
44
|
+
});
|
|
45
|
+
const spawn = this.spawn();
|
|
46
|
+
this.spawner = spawn;
|
|
47
|
+
spawn.then(async (shards) => {
|
|
48
|
+
const collector = setInterval(() => {
|
|
49
|
+
const index = shards.size - 1;
|
|
50
|
+
if (shards.get(index)?.ready) {
|
|
51
|
+
clearInterval(collector);
|
|
52
|
+
new XernerxLog({ settings: xernerxOptions }).info(
|
|
53
|
+
`All Shards launched for ${Style.log(String(this.user?.tag), {
|
|
54
|
+
color: Style.TextColor.Blue,
|
|
55
|
+
})} with a total of ${Style.log(String(this.stats.shardCount), { color: Style.TextColor.Cyan })} shard${this.stats.shardCount > 1 ? 's' : ''}, watching ${Style.log(
|
|
56
|
+
String(this.stats.guildCount),
|
|
57
|
+
{
|
|
58
|
+
color: Style.TextColor.Cyan,
|
|
59
|
+
}
|
|
60
|
+
)} guild${this.stats.guildCount > 1 ? 's' : ''}, and ${Style.log(String(this.stats.userCount), { color: Style.TextColor.Cyan })} user${this.stats.userCount > 1 ? 's' : ''}!`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}, 1000);
|
|
64
|
+
});
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
53
67
|
}
|
package/dist/functions/deploy.js
CHANGED
|
@@ -6,58 +6,51 @@ import XernerxError from '../tools/XernerxError.js';
|
|
|
6
6
|
const globalCommands = [];
|
|
7
7
|
const localCommands = [];
|
|
8
8
|
export default function deploy(client) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
? Style.log('globally', { color: Style.TextColor.Green })
|
|
51
|
-
: `${Style.log('locally', { color: Style.TextColor.Red })} in ${Style.log(client.guilds.cache.get(client.settings.local)?.name, { color: Style.TextColor.Blue })}`}.`);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
9
|
+
const commands = [];
|
|
10
|
+
function stats() {
|
|
11
|
+
client.stats.guildCount = client.guilds.cache.size;
|
|
12
|
+
client.stats.userCount = client.guilds.cache.map((g) => g.memberCount || g.approximateMemberCount || 0).reduce((a, b) => (a += b), 0);
|
|
13
|
+
}
|
|
14
|
+
process.on('message', (message) => {
|
|
15
|
+
if (message.type == 'xernerx') client.stats.shardId = message?.data?.shardId;
|
|
16
|
+
if (message.type == 'client') client.data = message.data;
|
|
17
|
+
});
|
|
18
|
+
client.on('messageCreate', stats);
|
|
19
|
+
client.on('interactionCreate', stats);
|
|
20
|
+
client.once('ready', (client) => {
|
|
21
|
+
stats();
|
|
22
|
+
client.commands.slash.map((command) => commands.push(command));
|
|
23
|
+
client.commands.context.map((command) => commands.push(command));
|
|
24
|
+
client.commands.message.map((command) => commands.push(command));
|
|
25
|
+
if (client.commands.slash.size) client.commands.slash.map((command) => (command.global ? globalCommands.push(command.data.toJSON()) : localCommands.push(command.data.toJSON())));
|
|
26
|
+
if (client.commands.context.size) client.commands.context.map((command) => (command.global ? globalCommands.push(command.data.toJSON()) : localCommands.push(command.data.toJSON())));
|
|
27
|
+
if (!globalCommands.length && !localCommands.length && !client.commands.message.size) return;
|
|
28
|
+
try {
|
|
29
|
+
if (client.settings.global) {
|
|
30
|
+
put(client, client.settings.global, globalCommands);
|
|
31
|
+
put(client, !client.settings.global, localCommands);
|
|
32
|
+
} else {
|
|
33
|
+
put(client, !client.settings.global, [...globalCommands, ...localCommands]);
|
|
34
|
+
put(client, client.settings.global, []);
|
|
35
|
+
}
|
|
36
|
+
} catch (error) {
|
|
37
|
+
new XernerxLog(client).error(`An error occurred while deploying the commands!`, error);
|
|
38
|
+
} finally {
|
|
39
|
+
new XernerxLog(client).info(
|
|
40
|
+
`Deployed ${Style.log(String(commands.filter((command) => command.global).length), {
|
|
41
|
+
color: Style.TextColor.Cyan,
|
|
42
|
+
})} Commands ${
|
|
43
|
+
client.settings.global
|
|
44
|
+
? Style.log('globally', { color: Style.TextColor.Green })
|
|
45
|
+
: `${Style.log('locally', { color: Style.TextColor.Red })} in ${Style.log(client.guilds.cache.get(client.settings.local)?.name, { color: Style.TextColor.Blue })}`
|
|
46
|
+
}.`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
54
50
|
}
|
|
55
51
|
function put(client, global, body) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return rest.put(Routes.applicationGuildCommands(client.user?.id, client.settings.local), { body });
|
|
61
|
-
else
|
|
62
|
-
return rest.put(Routes.applicationCommands(client.user?.id), { body });
|
|
52
|
+
const rest = new REST({ version: GatewayVersion }).setToken(client.token);
|
|
53
|
+
if (!global && !client.settings?.local) throw new XernerxError(`No guild ID provided as local guild!`);
|
|
54
|
+
if (!global && client.settings?.local) return rest.put(Routes.applicationGuildCommands(client.user?.id, client.settings.local), { body });
|
|
55
|
+
else return rest.put(Routes.applicationCommands(client.user?.id), { body });
|
|
63
56
|
}
|
package/dist/functions/load.js
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
/** @format */
|
|
2
2
|
import XernerxLog from '../tools/XernerxLog.js';
|
|
3
3
|
export default async function load(client, path, type) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
4
|
+
try {
|
|
5
|
+
let file = new (await import(`file://${path}`)).default();
|
|
6
|
+
file.filetype = type;
|
|
7
|
+
file.filepath = path;
|
|
8
|
+
file.client = client;
|
|
9
|
+
file.util = {};
|
|
10
|
+
fileSave(client, file, type);
|
|
11
|
+
return file;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
new XernerxLog(client).error(`Couldn't load ${type} ${path.match(/\w*\.js$/gim)?.at(0) || path}`, error);
|
|
14
|
+
}
|
|
16
15
|
}
|
|
17
16
|
function fileSave(client, file, type) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
switch (type) {
|
|
18
|
+
case 'MessageCommand':
|
|
19
|
+
client.commands.message.set(file.name, file);
|
|
20
|
+
break;
|
|
21
|
+
case 'SlashCommand':
|
|
22
|
+
client.commands.slash.set(file.name, file);
|
|
23
|
+
break;
|
|
24
|
+
case 'ContextCommand':
|
|
25
|
+
client.commands.context.set(file.name, file);
|
|
26
|
+
break;
|
|
27
|
+
case 'Inhibitor':
|
|
28
|
+
client.inhibitors.set(file.name, file);
|
|
29
|
+
break;
|
|
30
|
+
case 'Event':
|
|
31
|
+
client.events.set(file.name, file);
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
35
34
|
}
|
package/dist/functions/reload.js
CHANGED
|
@@ -3,28 +3,27 @@ import * as path from 'path';
|
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import load from './load.js';
|
|
5
5
|
export default async function reload(client, type) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
6
|
+
switch (type) {
|
|
7
|
+
case 'message': {
|
|
8
|
+
client.commands.message.clear();
|
|
9
|
+
if (!client.modules.options.message) return null;
|
|
10
|
+
const directory = path.resolve(client.modules.options.message?.directory);
|
|
11
|
+
for (const file of fs.readdirSync(directory)) {
|
|
12
|
+
load(client, `${directory}\\${file}`, 'MessageCommand');
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
case 'slash': {
|
|
17
|
+
return client.commands.slash.clear();
|
|
18
|
+
}
|
|
19
|
+
case 'context': {
|
|
20
|
+
return client.commands.context.clear();
|
|
21
|
+
}
|
|
22
|
+
case 'events': {
|
|
23
|
+
return client.events.clear();
|
|
24
|
+
}
|
|
25
|
+
case 'inhibitors': {
|
|
26
|
+
return client.inhibitors.clear();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
30
29
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** @format */
|
|
2
2
|
import XernerxClient from '../client/XernerxClient.js';
|
|
3
3
|
import { PresenceOptions } from '../types/interfaces.js';
|
|
4
|
-
export default function setPresence(client: XernerxClient, options: PresenceOptions): import(
|
|
4
|
+
export default function setPresence(client: XernerxClient, options: PresenceOptions): import('discord.js').ClientPresence | undefined;
|
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
import { ActivityType } from 'discord.js';
|
|
3
3
|
import { Style } from 'dumfunctions';
|
|
4
4
|
export default function setPresence(client, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
const presence = () =>
|
|
6
|
+
client.user?.setPresence({
|
|
7
|
+
activities: [
|
|
8
|
+
{
|
|
9
|
+
name: options.text,
|
|
10
|
+
type: ActivityType[Style.titleCase(options.type || 'Custom')],
|
|
11
|
+
url: options.url,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
status: options.status,
|
|
15
|
+
});
|
|
16
|
+
let response = presence();
|
|
17
|
+
if (options.interval)
|
|
18
|
+
setInterval(() => {
|
|
19
|
+
response = presence();
|
|
20
|
+
}, options.interval);
|
|
21
|
+
return response;
|
|
21
22
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/** @format */
|
|
2
2
|
export async function xernerxUser(event, client) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return author;
|
|
3
|
+
const author = event.author || event.user;
|
|
4
|
+
author.owner = isOwner(client, author);
|
|
5
|
+
if (client.dbl.validate) author.voted = await client?.dbl?.validate(author);
|
|
6
|
+
return author;
|
|
8
7
|
}
|
|
9
8
|
function isOwner(client, user) {
|
|
10
|
-
|
|
9
|
+
return client.settings.ownerId.includes(user.id);
|
|
11
10
|
}
|
|
@@ -3,14 +3,14 @@ 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
readonly readyTimestamp: number;
|
|
7
|
+
constructor(client: XernerxClient);
|
|
8
|
+
loadMessageCommands(options: MessageHandlerOptions): Promise<void>;
|
|
9
|
+
loadSlashCommands(options: SlashHandlerOptions): Promise<void>;
|
|
10
|
+
loadContextCommands(options: ContextHandlerOptions): Promise<void>;
|
|
11
|
+
private messageCommandRun;
|
|
12
|
+
private slashCommandRun;
|
|
13
|
+
private contextCommandRun;
|
|
14
|
+
private exec;
|
|
15
|
+
private _checks;
|
|
16
16
|
}
|