xernerx 4.13.0 → 4.14.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/client/XernerxShardClient.d.ts +1 -1
- package/dist/client/XernerxShardClient.js +3 -1
- package/dist/functions/deploy.js +7 -1
- package/dist/tools/XernerxLog.d.ts +9 -0
- package/dist/tools/XernerxLog.js +32 -17
- package/dist/utils/InteractionUtil.d.ts +7 -2
- package/dist/utils/InteractionUtil.js +18 -1
- package/dist/utils/MessageUtil.d.ts +0 -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) => {
|
|
@@ -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
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/** @format */
|
|
2
|
-
import { EmbedBuilder, InteractionEditReplyOptions, InteractionReplyOptions, MessagePayload } from 'discord.js';
|
|
2
|
+
import { EmbedBuilder, InteractionEditReplyOptions, InteractionReplyOptions, MessageCreateOptions, MessagePayload } from 'discord.js';
|
|
3
3
|
import XernerxClient from '../client/XernerxClient.js';
|
|
4
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
|
-
import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
7
|
+
import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUser, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
8
|
+
type MimicOptions = {
|
|
9
|
+
timeout: number;
|
|
10
|
+
};
|
|
8
11
|
export default class InteractionUtil extends Util {
|
|
9
12
|
private readonly interaction;
|
|
10
13
|
parsed: {
|
|
@@ -14,6 +17,8 @@ export default class InteractionUtil extends Util {
|
|
|
14
17
|
constructor(client: XernerxClient, interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>);
|
|
15
18
|
send(content: any): Promise<import("discord.js").Message<false> | import("discord.js").Message<true> | undefined>;
|
|
16
19
|
reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions): Promise<import("discord.js").InteractionResponse<boolean> | import("discord.js").Message<boolean>>;
|
|
20
|
+
mimic(user: XernerxUser | string, interaction: MessageCreateOptions, options: MimicOptions): Promise<void>;
|
|
17
21
|
private commandName;
|
|
18
22
|
paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<void | import("discord.js").Message<false> | import("discord.js").Message<true>>;
|
|
19
23
|
}
|
|
24
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @format */
|
|
2
|
-
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder } from 'discord.js';
|
|
2
|
+
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, 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 {
|
|
@@ -21,6 +21,23 @@ export default class InteractionUtil extends Util {
|
|
|
21
21
|
throw new XernerxError(`Can't send a message without content.`);
|
|
22
22
|
return await (this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content));
|
|
23
23
|
}
|
|
24
|
+
async mimic(user, interaction, options) {
|
|
25
|
+
user = (typeof user == 'string' ? (await this.client.users.fetch(user)) : user);
|
|
26
|
+
const webhooks = await this.interaction.channel.fetchWebhooks();
|
|
27
|
+
const webhook = webhooks.find((wh) => wh.token) ||
|
|
28
|
+
(await this.interaction.channel.createWebhook({
|
|
29
|
+
name: `${this.client.user?.username}'s mimic webhook.`,
|
|
30
|
+
avatar: user.displayAvatarURL() || this.client.user?.displayAvatarURL(),
|
|
31
|
+
}));
|
|
32
|
+
await webhook.send({
|
|
33
|
+
content: interaction.content,
|
|
34
|
+
username: user.username,
|
|
35
|
+
avatarURL: user.displayAvatarURL(),
|
|
36
|
+
});
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
webhook.delete().catch(() => true);
|
|
39
|
+
}, options.timeout);
|
|
40
|
+
}
|
|
24
41
|
// @ts-ignore
|
|
25
42
|
commandName() { }
|
|
26
43
|
async paginator(embeds, options = {}) {
|
|
@@ -5,7 +5,6 @@ import { XernerxMessage, XernerxUser } from '../types/extenders.js';
|
|
|
5
5
|
import Util from './Util.js';
|
|
6
6
|
import { PaginatorOptions } from '../types/interfaces.js';
|
|
7
7
|
type MimicOptions = {
|
|
8
|
-
url: string;
|
|
9
8
|
timeout: number;
|
|
10
9
|
};
|
|
11
10
|
export default class MessageUtil extends Util {
|