Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Commit

Permalink
fix: correct some types and fixed a bug (#22)
Browse files Browse the repository at this point in the history
fix(types): make NodeSend's return unknown
fix(types): make ClusterSend's return unknown
fix(cluster-node): resolved ReferenceError being thrown when called
  • Loading branch information
kyranet committed Apr 9, 2021
1 parent 6623fe5 commit 9bccab5
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/ClusterNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export class ClusterNode extends BaseNode {
public emit(event: ConnectionEvents.PlayerUpdate, payload: IncomingPlayerUpdatePayload): boolean;
public emit(event: ConnectionEvents.Stats, payload: IncomingStatsPayload): boolean;
public emit(event: ConnectionEvents.Upgrade, req: IncomingMessage): boolean;
public emit(event: ConnectionEvents, ...args: any[]): boolean {
public emit(event: ConnectionEvents, ...args: readonly any[]): boolean {
// @ts-expect-error Expect same arguments as parent.
if (this.listenerCount(name)) super.emit(name, ...args);
if (this.listenerCount(event)) super.emit(event, ...args);
return this.cluster.emit(event, ...args);
}

Expand Down
2 changes: 1 addition & 1 deletion src/base/BaseCluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface ClusterFilter {
}

export interface ClusterSend {
(guildID: string, packet: GatewaySendPayload): any;
(guildID: string, packet: GatewaySendPayload): unknown;
}

export abstract class BaseCluster extends EventEmitter {
Expand Down
2 changes: 1 addition & 1 deletion src/base/BaseNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export interface NodeOptions {
}

export interface NodeSend {
(guildID: string, packet: GatewaySendPayload): Promise<any>;
(guildID: string, packet: GatewaySendPayload): unknown;
}

export abstract class BaseNode extends EventEmitter {
Expand Down
2 changes: 1 addition & 1 deletion src/core/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export class Connection<T extends BaseNode = BaseNode> {
this.node.emit(pk.op, pk);
}

private onError(err: any): void {
private onError(err: Error): void {
this.node.emit(ConnectionEvents.Error, err);
this._reconnect();
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export class Http {
return this.do('GET', url);
}

public async do<T = any>(method: string, url: URL, data?: Buffer): Promise<T> {
public async do<T = unknown>(method: string, url: URL, data?: Buffer): Promise<T> {
const message = await new Promise<IncomingMessage>((resolve) => {
const req = request(
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ export class Player<T extends BaseNode = BaseNode> extends EventEmitter {
await Promise.all([node.voiceStateUpdate(voiceState), node.voiceServerUpdate(voiceServer)]);
}

public leave(): Promise<void> {
public leave(): unknown {
return this.join(null);
}

public join(channel: string | null, { deaf = false, mute = false }: JoinOptions = {}): Promise<void> {
public join(channel: string | null, { deaf = false, mute = false }: JoinOptions = {}): unknown {
this.node.voiceServers.delete(this.guildID);
this.node.voiceStates.delete(this.guildID);

Expand Down

0 comments on commit 9bccab5

Please sign in to comment.