xernerx 4.8.2 → 4.9.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.
@@ -8,6 +8,7 @@ export default class XernerxClient extends Client {
8
8
  readonly settings: {
9
9
  ownerId: (string | string[]) & (string | string[] | undefined);
10
10
  local: string;
11
+ ceaseless: boolean;
11
12
  global?: boolean | undefined;
12
13
  permissions?: {
13
14
  user: string[] | null;
@@ -18,6 +18,7 @@ export default class XernerxClient extends Client {
18
18
  local: z.string(),
19
19
  global: z.boolean().default(false).optional(),
20
20
  ownerId: z.string().or(z.array(z.string())).default([]),
21
+ ceaseless: z.boolean().default(false),
21
22
  permissions: z
22
23
  .object({
23
24
  client: z.array(z.string()).or(z.null()).default(null),
@@ -88,6 +89,11 @@ export default class XernerxClient extends Client {
88
89
  async connect(token) {
89
90
  const login = this.login(token);
90
91
  deploy(this);
92
+ if (this.settings.ceaseless) {
93
+ process.on('unhandledRejection', (error) => {
94
+ new XernerxLog(this).error('An uncaught error happpened, this is triggered from the ceaseless setting.', error);
95
+ });
96
+ }
91
97
  new XernerxLog(this).ready();
92
98
  return login;
93
99
  }
@@ -17,13 +17,18 @@ export default class XernerxShardClient extends ShardingManager {
17
17
  this.stats.guildCount += Number(guildCount);
18
18
  this.stats.userCount += Number(userCount);
19
19
  this.stats.shardCount++;
20
- 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 })}!`);
20
+ 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.` : ''}`);
21
21
  })
22
22
  .on('error', (error) => {
23
23
  new XernerxLog({ settings: xernerxOptions }).info(`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}`);
24
24
  });
25
25
  if (xernerxOptions?.timeout)
26
- setTimeout(() => shard.kill(), xernerxOptions.timeout);
26
+ setTimeout(() => {
27
+ new XernerxLog({ settings: xernerxOptions }).warn(`Automatically killing shard ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} on ${Style.log(String(shard.manager.user?.tag), {
28
+ color: Style.TextColor.Blue,
29
+ })}!`);
30
+ shard.kill();
31
+ }, xernerxOptions.timeout);
27
32
  });
28
33
  const spawn = this.spawn();
29
34
  this.spawner = spawn;
@@ -35,7 +35,7 @@ export default function deploy(client) {
35
35
  color: Style.TextColor.Cyan,
36
36
  })} Commands ${client.settings.global
37
37
  ? Style.log('globally', { color: Style.TextColor.Green })
38
- : `${Style.log('locally', { color: Style.TextColor.Red })} in ${Style.log(client.guilds.cache.get(client.settings.local).name, { color: Style.TextColor.Blue })}`}.`);
38
+ : `${Style.log('locally', { color: Style.TextColor.Red })} in ${Style.log(client.guilds.cache.get(client.settings.local)?.name, { color: Style.TextColor.Blue })}`}.`);
39
39
  }
40
40
  });
41
41
  }
@@ -14,6 +14,7 @@ export interface XernerxOptions {
14
14
  local: string;
15
15
  global?: boolean;
16
16
  ownerId?: string | Array<string>;
17
+ ceaseless?: boolean;
17
18
  permissions?: {
18
19
  user?: Array<PermissionNames> | Array<string> | null;
19
20
  client?: Array<PermissionNames> | Array<string> | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "4.8.2",
3
+ "version": "4.9.0",
4
4
  "description": "A bot framework for discord.js.",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",