xernerx 4.13.1 → 4.14.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/client/XernerxShardClient.d.ts +1 -1
- package/dist/client/XernerxShardClient.js +3 -1
- package/dist/functions/deploy.js +7 -1
- package/dist/handlers/CommandHandler.js +1 -1
- package/dist/tools/XernerxLog.d.ts +9 -0
- package/dist/tools/XernerxLog.js +32 -17
- package/dist/utils/ClientUtil.d.ts +2 -1
- package/dist/utils/ClientUtil.js +3 -0
- package/dist/utils/InteractionUtil.d.ts +1 -1
- package/dist/utils/InteractionUtil.js +7 -3
- package/dist/utils/MessageUtil.d.ts +1 -0
- package/dist/utils/MessageUtil.js +3 -0
- package/dist/validators/inhibitorValidations.d.ts +1 -1
- package/package.json +1 -1
|
@@ -16,6 +16,6 @@ export default class XernerxShardClient extends ShardingManager {
|
|
|
16
16
|
};
|
|
17
17
|
user: ClientUser | null;
|
|
18
18
|
spawner: Promise<import("@discordjs/collection").Collection<number, import("discord.js").Shard>>;
|
|
19
|
-
constructor(file: string, discordOptions: ShardingManagerOptions, xernerxOptions?: XernerxOptions);
|
|
19
|
+
constructor(file: string, discordOptions: ShardingManagerOptions, xernerxOptions?: XernerxOptions, data?: unknown);
|
|
20
20
|
}
|
|
21
21
|
export {};
|
|
@@ -3,7 +3,7 @@ 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
|
-
constructor(file, discordOptions, xernerxOptions) {
|
|
6
|
+
constructor(file, discordOptions, xernerxOptions, data = {}) {
|
|
7
7
|
super(file, discordOptions);
|
|
8
8
|
this.stats = { guildCount: 0, userCount: 0, shardCount: 0, voteCount: 0, shards: {} };
|
|
9
9
|
this.user = null;
|
|
@@ -18,6 +18,8 @@ export default class XernerxShardClient extends ShardingManager {
|
|
|
18
18
|
this.stats.userCount += stats.userCount;
|
|
19
19
|
this.stats.shardCount++;
|
|
20
20
|
this.stats.voteCount = stats.voteCount;
|
|
21
|
+
shard.send({ type: 'xernerx', data: { shardId: shard.id, sharded: true } });
|
|
22
|
+
shard.send({ type: 'client', data });
|
|
21
23
|
await new XernerxLog({ settings: xernerxOptions }).info(`Launched shard ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} for ${Style.log(this.user?.tag, { color: Style.TextColor.Blue })}! ${xernerxOptions?.timeout ? `Automatically killing in ${Style.log(String(xernerxOptions.timeout), { color: Style.TextColor.Cyan })}ms.` : ''}`);
|
|
22
24
|
})
|
|
23
25
|
.on('error', (error) => {
|
package/dist/functions/deploy.js
CHANGED
|
@@ -9,8 +9,14 @@ export default function deploy(client) {
|
|
|
9
9
|
const commands = [];
|
|
10
10
|
function stats() {
|
|
11
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));
|
|
12
|
+
client.stats.userCount = client.guilds.cache.map((g) => g.memberCount || g.approximateMemberCount || 0).reduce((a, b) => (a += b), 0);
|
|
13
13
|
}
|
|
14
|
+
process.on('message', (message) => {
|
|
15
|
+
if (message.type == 'xernerx')
|
|
16
|
+
client.stats.shardId = message?.data?.shardId;
|
|
17
|
+
if (message.type == 'client')
|
|
18
|
+
client.data = message.data;
|
|
19
|
+
});
|
|
14
20
|
client.on('messageCreate', stats);
|
|
15
21
|
client.on('interactionCreate', stats);
|
|
16
22
|
client.prependOnceListener('ready', (client) => {
|
|
@@ -273,7 +273,7 @@ export default class CommandHandler extends Handler {
|
|
|
273
273
|
await this.client.emit('commandStart', interaction);
|
|
274
274
|
const args = await interactionArguments(interaction, cmd);
|
|
275
275
|
interaction.util.parsed = {
|
|
276
|
-
alias: [interaction.commandName, args.group ||
|
|
276
|
+
alias: [interaction.commandName, args.group || null, args.subcommand || null].filter((x) => x).join(' '),
|
|
277
277
|
args: args.args,
|
|
278
278
|
};
|
|
279
279
|
cmd.util = interaction.util;
|
|
@@ -10,10 +10,19 @@ export default class XernerxLog {
|
|
|
10
10
|
private readonly readyLog;
|
|
11
11
|
private readonly tableLog;
|
|
12
12
|
private readonly time;
|
|
13
|
+
private readonly ram;
|
|
14
|
+
private shard;
|
|
15
|
+
private readonly base;
|
|
13
16
|
constructor(client: XernerxClient | XernerxClientType | true);
|
|
14
17
|
info(message: string, force?: boolean): void | null;
|
|
15
18
|
warn(message: string): void | null;
|
|
16
19
|
update(version: string, url: string): Promise<void>;
|
|
17
20
|
error(message: string, error?: XernerxError | unknown): void | null;
|
|
18
21
|
ready(): void;
|
|
22
|
+
private cyan;
|
|
23
|
+
private blue;
|
|
24
|
+
private yellow;
|
|
25
|
+
private purple;
|
|
26
|
+
private red;
|
|
27
|
+
private green;
|
|
19
28
|
}
|
package/dist/tools/XernerxLog.js
CHANGED
|
@@ -16,41 +16,38 @@ export default class XernerxLog {
|
|
|
16
16
|
this.tableLog = client.settings.log?.table;
|
|
17
17
|
}
|
|
18
18
|
this.time = () => String(new Date()).split(/ +/)[4];
|
|
19
|
+
this.ram = () => Math.round(process.memoryUsage().rss / 1000000);
|
|
20
|
+
this.shard = '';
|
|
21
|
+
process.on('message', (message) => {
|
|
22
|
+
if (message.type == 'xernerx')
|
|
23
|
+
this.shard = message?.data?.sharded ? `| ${message?.data?.shardId} |` : '';
|
|
24
|
+
});
|
|
25
|
+
this.base = (type, message) => `${type == 'info' ? `✔️ | ${this.purple('Xernerx')}` : type == `error` ? `❗ | ${this.red('Xernerx')}` : type == `update` ? `⬆️ | ${this.blue('Xernerx')}` : `⚠️ | ${this.yellow('Xernerx')}`} | ${this.cyan(this.time())} | ${this.cyan(this.ram())}mb | ${this.client.stats?.shardCount > 1 ? `${this.cyan(this.client.stats.shardId)} | ` : ''}${message}`;
|
|
19
26
|
}
|
|
20
27
|
info(message, force = false) {
|
|
21
|
-
return this.infoLog || force
|
|
22
|
-
? console.info(`✔️ | ${Style.log('Xernerx', { color: Style.TextColor.Purple })} | ${Style.log(this.time(), {
|
|
23
|
-
color: Style.TextColor.Cyan,
|
|
24
|
-
})} | ${Math.round(process.memoryUsage().rss / 1000000)}mb | ${message}`)
|
|
25
|
-
: null;
|
|
28
|
+
return this.infoLog || force ? console.info(this.base('info', message)) : null;
|
|
26
29
|
}
|
|
27
30
|
warn(message) {
|
|
28
|
-
return this.warnLog
|
|
29
|
-
? console.warn(`⚠️ | ${Style.log('Xernerx', { color: Style.TextColor.Yellow })} | ${Style.log(this.time(), { color: Style.TextColor.Cyan })} | ${Math.round(process.memoryUsage().rss / 1000000)}mb | ${message}`)
|
|
30
|
-
: null;
|
|
31
|
+
return this.warnLog ? console.warn(this.base('warn', message)) : null;
|
|
31
32
|
}
|
|
32
33
|
async update(version, url) {
|
|
33
34
|
const pkg = await fetch(url)
|
|
34
35
|
.then(async (res) => await res.json())
|
|
35
36
|
.catch(() => ({ version }));
|
|
36
37
|
if (version !== pkg.version)
|
|
37
|
-
|
|
38
|
-
color: Style.
|
|
39
|
-
})}
|
|
38
|
+
console.info(this.base('update', `A new version for ${pkg.name} is available, you're using version ${this.cyan(version)}, new version is ${this.cyan(pkg.version)}, run ${Style.log(`npm i ${pkg.name}@${pkg.version}`, {
|
|
39
|
+
color: Style.BackgroundColor.Grey,
|
|
40
|
+
})} to update to the latest version.`));
|
|
40
41
|
}
|
|
41
42
|
error(message, error) {
|
|
42
|
-
return this.errorLog
|
|
43
|
-
? console.error(`❗ | ${Style.log('Xernerx', { color: Style.TextColor.Red })} | ${Style.log(this.time(), { color: Style.TextColor.Cyan })} | ${Math.round(process.memoryUsage().rss / 1000000)}mb | ${message}${error ? ` | ${error.stack}` : ''}`)
|
|
44
|
-
: null;
|
|
43
|
+
return this.errorLog ? console.error(this.base('error', message), error) : null;
|
|
45
44
|
}
|
|
46
45
|
ready() {
|
|
47
46
|
if (typeof this.client == 'boolean')
|
|
48
47
|
return;
|
|
49
48
|
const client = this.client;
|
|
50
49
|
this.client.prependOnceListener('ready', async (synced) => {
|
|
51
|
-
this.info(`${Style.log(synced.user.tag, { color: Style.TextColor.Blue })} is now ${
|
|
52
|
-
color: Style.TextColor.Cyan,
|
|
53
|
-
})} guild${client.guilds.cache.size > 1 ? 's' : ''}, using ${client.settings.local ? Style.log((await client.guilds.fetch(client.settings.local))?.name, { color: Style.TextColor.Blue }) : 'none'} as local guild.`, this.readyLog);
|
|
50
|
+
this.info(`${Style.log(synced.user.tag, { color: Style.TextColor.Blue })} is now ${this.green('online')}, watching ${this.cyan(String(client.guilds.cache.size))} guild${client.guilds.cache.size > 1 ? 's' : ''}, using ${client.settings.local ? this.blue((await client.guilds.fetch(client.settings.local))?.name) : 'none'} as local guild.`, this.readyLog);
|
|
54
51
|
const files = [];
|
|
55
52
|
for (const [id, data] of client.commands.message) {
|
|
56
53
|
files.push(data);
|
|
@@ -77,4 +74,22 @@ export default class XernerxLog {
|
|
|
77
74
|
}
|
|
78
75
|
});
|
|
79
76
|
}
|
|
77
|
+
cyan(string) {
|
|
78
|
+
return Style.log(String(string), { color: Style.TextColor.Cyan });
|
|
79
|
+
}
|
|
80
|
+
blue(string) {
|
|
81
|
+
return Style.log(String(string), { color: Style.TextColor.Blue });
|
|
82
|
+
}
|
|
83
|
+
yellow(string) {
|
|
84
|
+
return Style.log(String(string), { color: Style.TextColor.Yellow });
|
|
85
|
+
}
|
|
86
|
+
purple(string) {
|
|
87
|
+
return Style.log(String(string), { color: Style.TextColor.Purple });
|
|
88
|
+
}
|
|
89
|
+
red(string) {
|
|
90
|
+
return Style.log(String(string), { color: Style.TextColor.Red });
|
|
91
|
+
}
|
|
92
|
+
green(string) {
|
|
93
|
+
return Style.log(String(string), { color: Style.TextColor.Green });
|
|
94
|
+
}
|
|
80
95
|
}
|
|
@@ -11,8 +11,9 @@ export default class ClientUtil extends Util {
|
|
|
11
11
|
constructor(client: XernerxClient);
|
|
12
12
|
setPresence(options: PresenceOptions): import("discord.js").ClientPresence | undefined;
|
|
13
13
|
private resolveCooldown;
|
|
14
|
-
resolveCommand(options: ResolveCommandOptions):
|
|
14
|
+
resolveCommand(options: ResolveCommandOptions): XernerxSlashCommand | XernerxContextCommand | XernerxMessageCommand | Collection<string, XernerxSlashCommand | XernerxContextCommand | XernerxMessageCommand>;
|
|
15
15
|
resolveChannel(query: string | Record<string, string>): Promise<import("discord.js").Channel | null>;
|
|
16
16
|
resolveGuild(query: string | Record<string, string>): Promise<import("discord.js").Guild | null>;
|
|
17
17
|
uptime(timestamp?: number | null): string;
|
|
18
|
+
commands(): ([string, XernerxMessageCommand] | [string, XernerxSlashCommand] | [string, XernerxContextCommand])[];
|
|
18
19
|
}
|
package/dist/utils/ClientUtil.js
CHANGED
|
@@ -18,7 +18,7 @@ export default class InteractionUtil extends Util {
|
|
|
18
18
|
send(content: any): Promise<import("discord.js").Message<false> | import("discord.js").Message<true> | undefined>;
|
|
19
19
|
reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions): Promise<import("discord.js").InteractionResponse<boolean> | import("discord.js").Message<boolean>>;
|
|
20
20
|
mimic(user: XernerxUser | string, interaction: MessageCreateOptions, options: MimicOptions): Promise<void>;
|
|
21
|
-
private commandName;
|
|
22
21
|
paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<void | import("discord.js").Message<false> | import("discord.js").Message<true>>;
|
|
22
|
+
commands(): import("@discordjs/collection").Collection<string, import("../main.js").XernerxSlashCommand> | import("@discordjs/collection").Collection<string, import("../main.js").XernerxContextCommand>;
|
|
23
23
|
}
|
|
24
24
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @format */
|
|
2
|
-
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, } from 'discord.js';
|
|
2
|
+
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, InteractionType, StringSelectMenuBuilder, } from 'discord.js';
|
|
3
3
|
import Util from './Util.js';
|
|
4
4
|
import XernerxError from '../tools/XernerxError.js';
|
|
5
5
|
export default class InteractionUtil extends Util {
|
|
@@ -38,8 +38,6 @@ export default class InteractionUtil extends Util {
|
|
|
38
38
|
webhook.delete().catch(() => true);
|
|
39
39
|
}, options.timeout);
|
|
40
40
|
}
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
commandName() { }
|
|
43
41
|
async paginator(embeds, options = {}) {
|
|
44
42
|
let buttonRow, menuRow;
|
|
45
43
|
if (embeds.length <= 0)
|
|
@@ -120,4 +118,10 @@ export default class InteractionUtil extends Util {
|
|
|
120
118
|
});
|
|
121
119
|
});
|
|
122
120
|
}
|
|
121
|
+
commands() {
|
|
122
|
+
if (this.interaction.type == InteractionType.ApplicationCommand)
|
|
123
|
+
return this.client.commands.slash;
|
|
124
|
+
else
|
|
125
|
+
return this.client.commands.context;
|
|
126
|
+
}
|
|
123
127
|
}
|
|
@@ -19,5 +19,6 @@ export default class MessageUtil extends Util {
|
|
|
19
19
|
reply(content: string | MessagePayload | MessageReplyOptions | MessageEditOptions): Promise<import("discord.js").Message<boolean> | null>;
|
|
20
20
|
mimic(user: XernerxUser | string, message: MessageCreateOptions, options: MimicOptions): Promise<void>;
|
|
21
21
|
paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<void | import("discord.js").Message<boolean> | null>;
|
|
22
|
+
commands(): import("@discordjs/collection").Collection<string, import("../main.js").XernerxMessageCommand>;
|
|
22
23
|
}
|
|
23
24
|
export {};
|
|
@@ -6,4 +6,4 @@ import XernerxSlashCommand from '../build/XernerxSlashCommand.js';
|
|
|
6
6
|
import { XernerxMessage, XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
7
7
|
import { InhibitorType, XernerxInteraction } from '../types/types.js';
|
|
8
8
|
export declare function inhibitorValidation(event: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, args?: SlashCommandArguments | MessageCommandArguments | ContextCommandArguments<'user' | 'message'> | null, cmd?: XernerxContextCommand | XernerxMessageCommand | XernerxSlashCommand, type?: 'pre' | 'check' | 'post'): Promise<boolean>;
|
|
9
|
-
export declare function inhibitorArguments(event: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, cmd: XernerxContextCommand | XernerxMessageCommand | XernerxSlashCommand | null, type: InhibitorType): import("../types/extenders.js").XernerxUser | import("discord.js").GuildMember | import("discord.js").Guild | import("discord.js").TextBasedChannel |
|
|
9
|
+
export declare function inhibitorArguments(event: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, cmd: XernerxContextCommand | XernerxMessageCommand | XernerxSlashCommand | null, type: InhibitorType): import("../types/extenders.js").XernerxUser | import("discord.js").GuildMember | import("discord.js").Guild | import("discord.js").TextBasedChannel | XernerxSlashCommand | XernerxContextCommand | XernerxMessageCommand | import("discord.js").APIInteractionGuildMember | null | undefined;
|