Skip to content

Commit 5a6c5aa

Browse files
committed
Remove deprecated client files and update package version to 1.8.9
1 parent c782ce7 commit 5a6c5aa

File tree

7 files changed

+151
-152
lines changed

7 files changed

+151
-152
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.8.8",
2+
"version": "1.8.9",
33
"name": "status-sharding",
44
"author": "Digital39999",
55
"scripts": {
@@ -43,7 +43,6 @@
4343
"typescript": "5.5.2"
4444
},
4545
"peerDependencies": {
46-
"@sapphire/framework": ">=5.0.0",
4746
"discord.js": ">=14.14.1"
4847
},
4948
"engines": {

src/core/client/discordjs.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/core/client/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/core/client/sapphire.ts

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/core/clusterClient.ts

Lines changed: 149 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ClusterClientEvents, EvalOptions, MessageTypes, Serialized, Awaitable, ValidIfSerializable, SerializableInput, ClusterClientData } from '../types';
22
import { BaseMessage, BaseMessageInput, DataType, ProcessMessage } from '../other/message';
3+
import { ClientOptions, Client as DiscordClient, Guild, ClientEvents } from 'discord.js';
34
import { BrokerMessage, IPCBrokerClient } from '../handlers/broker';
4-
import { ShardingClient, ShardingClientSapphire } from './client';
55
import { ClusterClientHandler } from '../handlers/message';
66
import { ShardingUtils } from '../other/shardingUtils';
77
import { RefClusterManager } from './clusterManager';
@@ -10,10 +10,156 @@ import { WorkerClient } from '../classes/worker';
1010
import { ChildClient } from '../classes/child';
1111
import { Serializable } from 'child_process';
1212
import { getInfo } from '../other/data';
13-
import { Guild } from 'discord.js';
1413
import EventEmitter from 'events';
1514

16-
export type RefShardingClient = ShardingClient | ShardingClientSapphire;
15+
/**
16+
* Modified ClientEvents such that the ready event has the ShardingClient instead of the normal Client.
17+
* @export
18+
* @typedef {ClientEventsModifiable}
19+
*/
20+
export type ClientEventsModifiable = Omit<ClientEvents, 'ready'> & { ready: [client: ShardingClient] };
21+
22+
/**
23+
* Modified DiscordClient with bunch of new methods.
24+
* @export
25+
* @class ShardingClient
26+
* @typedef {ShardingClient}
27+
* @template {boolean} [Ready=boolean] - The ready state of the client.
28+
* @template {RefClusterManager} [InternalManager=RefClusterManager] - The manager to use for the client.
29+
* @extends {DiscordClient}
30+
*/
31+
export class ShardingClient<
32+
Ready extends boolean = boolean,
33+
InternalManager extends RefClusterManager = RefClusterManager,
34+
> extends DiscordClient<Ready> {
35+
/**
36+
* Cluster associated with this client.
37+
* @type {ClusterClient<this, InternalManage>}
38+
*/
39+
cluster: ClusterClient<this, InternalManager>;
40+
41+
/**
42+
* Creates an instance of ShardingClient.
43+
* @constructor
44+
* @param {ClientOptions} options - The options for the client.
45+
*/
46+
constructor(options: ClientOptions) {
47+
super({
48+
...options,
49+
shards: getInfo().ShardList,
50+
shardCount: getInfo().TotalShards,
51+
});
52+
53+
this.cluster = new ClusterClient<this, InternalManager>(this);
54+
}
55+
56+
/**
57+
* Listen for an event.
58+
* @template {keyof ClientEventsModifiable} K - The type of the event.
59+
* @param {K} event - The event to listen for.
60+
* @param {(...args: ClientEventsModifiable[K]) => void} listener - The listener to execute.
61+
* @returns {this} The client.
62+
*/
63+
on<K extends keyof ClientEventsModifiable>(event: K, listener: (...args: ClientEventsModifiable[K]) => void): this;
64+
/**
65+
* Listen for an event.
66+
* @template {string | symbol} S - The type of the event.
67+
* @param {Exclude<S, keyof ClientEventsModifiable>} event - The event to listen for.
68+
* @param {(...args: unknown[]) => void} listener - The listener to execute.
69+
* @returns {this} The client.
70+
*/
71+
on<S extends string | symbol>(event: Exclude<S, keyof ClientEventsModifiable>, listener: (...args: unknown[]) => void): this;
72+
/**
73+
* Listen for an event.
74+
* @param {(string | symbol)} event - The event to listen for.
75+
* @param {(...args: unknown[]) => void} listener - The listener to execute.
76+
* @returns {this} The client.
77+
*/
78+
on(event: string | symbol, listener: (...args: unknown[]) => void): this {
79+
return super.on(event, listener);
80+
}
81+
82+
/**
83+
* Listen for an event once.
84+
* @template {keyof ClientEventsModifiable} K - The type of the event.
85+
* @param {K} event - The event to listen for.
86+
* @param {(...args: ClientEventsModifiable[K]) => void} listener - The listener to execute.
87+
* @returns {this} The client.
88+
*/
89+
once<K extends keyof ClientEventsModifiable>(event: K, listener: (...args: ClientEventsModifiable[K]) => void): this;
90+
/**
91+
* Listen for an event once.
92+
* @template {string | symbol} S - The type of the event.
93+
* @param {Exclude<S, keyof ClientEventsModifiable>} event - The event to listen for.
94+
* @param {(...args: unknown[]) => void} listener - The listener to execute.
95+
* @returns {this} The client.
96+
*/
97+
once<S extends string | symbol>(event: Exclude<S, keyof ClientEventsModifiable>, listener: (...args: unknown[]) => void): this;
98+
/**
99+
* Listen for an event once.
100+
* @param {(string | symbol)} event - The event to listen for.
101+
* @param {(...args: unknown[]) => void} listener - The listener to execute.
102+
* @returns {this} The client.
103+
*/
104+
once(event: string | symbol, listener: (...args: unknown[]) => void): this {
105+
return super.once(event, listener);
106+
}
107+
108+
/**
109+
* Listen for an event.
110+
* @template {keyof ClientEventsModifiable} K - The type of the event.
111+
* @param {K} event - The event to listen for.
112+
* @param {(...args: ClientEventsModifiable[K]) => void} listener - The listener to execute.
113+
* @returns {this} The client.
114+
*/
115+
off<K extends keyof ClientEventsModifiable>(event: K, listener: (...args: ClientEventsModifiable[K]) => void): this;
116+
/**
117+
* Listen for an event.
118+
* @template {string | symbol} S - The type of the event.
119+
* @param {Exclude<S, keyof ClientEventsModifiable>} event - The event to listen for.
120+
* @param {(...args: unknown[]) => void} listener - The listener to execute.
121+
* @returns {this} The client.
122+
*/
123+
off<S extends string | symbol>(event: Exclude<S, keyof ClientEventsModifiable>, listener: (...args: unknown[]) => void): this;
124+
/**
125+
* Listen for an event.
126+
* @param {(string | symbol)} event - The event to listen for.
127+
* @param {(...args: unknown[]) => void} listener - The listener to execute.
128+
* @returns {this} The client.
129+
*/
130+
off(event: string | symbol, listener: (...args: unknown[]) => void): this {
131+
return super.off(event, listener);
132+
}
133+
134+
/**
135+
* Emit an event.
136+
* @template {keyof ClientEventsModifiable} K - The type of the event.
137+
* @param {K} event - The event to emit.
138+
* @param {...ClientEventsModifiable[K]} args - The arguments to pass to the listener.
139+
* @returns {boolean} Whether the event was emitted.
140+
*/
141+
emit<K extends keyof ClientEventsModifiable>(event: K, ...args: ClientEventsModifiable[K]): boolean;
142+
/**
143+
* Emit an event.
144+
* @template {string | symbol} S - The type of the event.
145+
* @param {Exclude<S, keyof ClientEventsModifiable>} event - The event to emit.
146+
* @param {...unknown[]} args - The arguments to pass to the listener.
147+
* @returns {boolean} Whether the event was emitted.
148+
*/
149+
emit<S extends string | symbol>(event: Exclude<S, keyof ClientEventsModifiable>, ...args: unknown[]): boolean;
150+
/**
151+
* Emit an event.
152+
* @param {(string | symbol)} event - The event to emit.
153+
* @param {...unknown[]} args - The arguments to pass to the listener.
154+
* @returns {boolean} Whether the event was emitted.
155+
*/
156+
emit(event: string | symbol, ...args: unknown[]): boolean {
157+
return super.emit(event, ...args);
158+
}
159+
}
160+
161+
export type RefShardingClient = ShardingClient;
162+
17163

18164
/**
19165
* Simplified Cluster instance available on the {@link ClusterClient}.

src/core/clusterManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class ClusterManager<
104104
enabled: false,
105105
maxRestarts: 3,
106106
interval: 5000,
107-
timeout: -1,
107+
timeout: 10000,
108108
maxMissedHeartbeats: 3,
109109
}),
110110
mode: options.mode || 'worker',

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export * from './classes/worker';
44
export * from './core/clusterManager';
55
export * from './core/clusterClient';
66
export * from './core/cluster';
7-
export * from './core/client';
87

98
export * from './handlers/message';
109
export * from './handlers/promise';

0 commit comments

Comments
 (0)