xernerx 4.3.1 → 4.4.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.
@@ -0,0 +1,15 @@
1
+ import { ShardingManager, ShardingManagerOptions } from 'discord.js';
2
+ interface XernerxOptions {
3
+ log?: {
4
+ ready: boolean;
5
+ };
6
+ }
7
+ export default class XernerxShardClient extends ShardingManager {
8
+ readonly stats: {
9
+ guildCount: number;
10
+ userCount: number;
11
+ shardCount: number;
12
+ };
13
+ constructor(file: string, discordOptions: ShardingManagerOptions, xernerxOptions?: XernerxOptions);
14
+ }
15
+ export {};
@@ -0,0 +1,28 @@
1
+ import { ShardingManager } from 'discord.js';
2
+ import XernerxLog from '../tools/XernerxLog.js';
3
+ export default class XernerxShardClient extends ShardingManager {
4
+ constructor(file, discordOptions, xernerxOptions) {
5
+ super(file, discordOptions);
6
+ this.stats = { guildCount: 0, userCount: 0, shardCount: 0 };
7
+ this.on('shardCreate', async (shard) => {
8
+ new XernerxLog({ settings: xernerxOptions }).info(`Launching shard ${shard.id}`);
9
+ shard.on('ready', async () => {
10
+ const guilds = await shard.fetchClientValue('guilds.cache');
11
+ const guildCount = guilds.length;
12
+ const userCount = guilds.map((guild) => guild.memberCount).length ? guilds.map((guild) => guild.memberCount).reduce((a, b) => (a += b)) : 0;
13
+ this.stats.guildCount += Number(guildCount);
14
+ this.stats.userCount += Number(userCount);
15
+ this.stats.shardCount++;
16
+ });
17
+ });
18
+ this.spawn().then(async (shards) => {
19
+ const collector = setInterval(() => {
20
+ const index = shards.size - 1;
21
+ if (shards.get(index)?.ready) {
22
+ new XernerxLog({ settings: xernerxOptions }).info(`Launched all ${this.stats.shardCount} shards, watching ${this.stats.guildCount} guilds, and ${this.stats.userCount} users!`);
23
+ clearInterval(collector);
24
+ }
25
+ }, 1000);
26
+ });
27
+ }
28
+ }
package/dist/main.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import XernerxClient from './client/XernerxClient.js';
2
+ import XernerxShardClient from './client/XernerxShardClient.js';
2
3
  import MessageCommandBuilder from './build/MessageCommandBuilder.js';
3
4
  import SlashCommandBuilder from './build/SlashCommandBuilder.js';
4
5
  import ContextCommandBuilder from './build/ContextCommandBuilder.js';
@@ -11,4 +12,31 @@ import ExtensionBuilder from 'xernerx-extension-builder';
11
12
  import Discord from 'discord.js';
12
13
  declare const version: any;
13
14
  export default XernerxClient;
14
- export { XernerxClient, MessageCommandBuilder, SlashCommandBuilder, ContextCommandBuilder, EventBuilder, InhibitorBuilder, ExtensionBuilder, Discord, version, XernerxLog };
15
+ export {
16
+ /**
17
+ ** Clients
18
+ */
19
+ XernerxClient,
20
+ XernerxShardClient,
21
+ /**
22
+ ** Builders
23
+ */
24
+ MessageCommandBuilder,
25
+ SlashCommandBuilder,
26
+ ContextCommandBuilder,
27
+ EventBuilder,
28
+ InhibitorBuilder,
29
+ ExtensionBuilder,
30
+ /**
31
+ ** Imported exports
32
+ */
33
+ Discord,
34
+ /**
35
+ ** Properties
36
+ */
37
+ version,
38
+ /**
39
+ ** Tools
40
+ */
41
+ XernerxLog,
42
+ };
package/dist/main.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as fs from 'fs';
2
2
  import XernerxClient from './client/XernerxClient.js';
3
+ import XernerxShardClient from './client/XernerxShardClient.js';
3
4
  import MessageCommandBuilder from './build/MessageCommandBuilder.js';
4
5
  import SlashCommandBuilder from './build/SlashCommandBuilder.js';
5
6
  import ContextCommandBuilder from './build/ContextCommandBuilder.js';
@@ -12,4 +13,31 @@ import ExtensionBuilder from 'xernerx-extension-builder';
12
13
  import Discord from 'discord.js';
13
14
  const version = JSON.parse(fs.readFileSync('node_modules/xernerx/package.json', 'utf-8')).version;
14
15
  export default XernerxClient;
15
- export { XernerxClient, MessageCommandBuilder, SlashCommandBuilder, ContextCommandBuilder, EventBuilder, InhibitorBuilder, ExtensionBuilder, Discord, version, XernerxLog };
16
+ export {
17
+ /**
18
+ ** Clients
19
+ */
20
+ XernerxClient,
21
+ XernerxShardClient,
22
+ /**
23
+ ** Builders
24
+ */
25
+ MessageCommandBuilder,
26
+ SlashCommandBuilder,
27
+ ContextCommandBuilder,
28
+ EventBuilder,
29
+ InhibitorBuilder,
30
+ ExtensionBuilder,
31
+ /**
32
+ ** Imported exports
33
+ */
34
+ Discord,
35
+ /**
36
+ ** Properties
37
+ */
38
+ version,
39
+ /**
40
+ ** Tools
41
+ */
42
+ XernerxLog,
43
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "4.3.1",
3
+ "version": "4.4.0",
4
4
  "description": "A bot framework for discord.js.",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",