Skip to content

Commit

Permalink
fix(Kirishima): let user decide to spawnPlayer should connect or not
Browse files Browse the repository at this point in the history
  • Loading branch information
KagChi committed Mar 14, 2022
1 parent 17458ec commit eee1478
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "dist/index.js",
"module": "dist/index.mjs",
"description": "Kirishima is extendable, fast, flexible, asynchronous lavalink client",
"version": "0.3.1",
"version": "0.4.0",
"license": "GPL-3.0",
"repository": {
"url": "https://github.com/kirishima-ship/core"
Expand Down
3 changes: 1 addition & 2 deletions src/Structures/Kirishima.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ export class Kirishima extends EventEmitter {

public async spawnPlayer(options: KirishimaPlayerOptions, node?: KirishimaNode) {
node ??= this.resolveNode();
const player = await this.options.spawnPlayer!(options.guildId, options, node!);
return player.connect();
return this.options.spawnPlayer!(options.guildId, options, node!);
}

public async handleVoiceServerUpdate(packet: GatewayVoiceServerUpdateDispatch) {
Expand Down
5 changes: 3 additions & 2 deletions src/Structures/KirishimaNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { KirishimaNodeOptions } from '../typings';
import type { Kirishima } from './Kirishima';
import { GatewayVoiceServerUpdateDispatch, GatewayVoiceStateUpdateDispatch } from 'discord-api-types/gateway/v9';
import { LavalinkStatsPayload, WebsocketOpEnum } from 'lavalink-api-types';
import { BasePlayer } from './BasePlayer';

export class KirishimaNode {
public ws!: Gateway;
Expand Down Expand Up @@ -97,14 +98,14 @@ export class KirishimaNode {
}

public async handleVoiceServerUpdate(packet: GatewayVoiceServerUpdateDispatch) {
const player = await this.kirishima.options.fetchPlayer!(packet.d.guild_id);
const player = (await this.kirishima.options.fetchPlayer!(packet.d.guild_id)) as BasePlayer;
if (player) {
await player.setServerUpdate(packet);
}
}

public async handleVoiceStateUpdate(packet: GatewayVoiceStateUpdateDispatch) {
const player = await this.kirishima.options.fetchPlayer!(packet.d.guild_id!);
const player = (await this.kirishima.options.fetchPlayer!(packet.d.guild_id!)) as BasePlayer;
if (player) {
player.setStateUpdate(packet);
}
Expand Down
4 changes: 2 additions & 2 deletions src/typings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export interface KirishimaOptions {
}

export interface SpawnPlayerOptionHook {
(guildId: string, options: KirishimaPlayerOptions, node: KirishimaNode): Awaitable<BasePlayer>;
(guildId: string, options: KirishimaPlayerOptions, node: KirishimaNode): Awaitable<unknown>;
}

export interface PlayerOptionHook {
(guildId: string): Awaitable<BasePlayer | undefined>;
(guildId: string): Awaitable<unknown | undefined>;
}
export interface payload {
op: GatewayOpcodes;
Expand Down

0 comments on commit eee1478

Please sign in to comment.