Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #26 from Gorillas-Team/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Psykka authored Jul 4, 2020
2 parents 6bd1672 + 3c70166 commit 76cb27b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/lib/GorilinkManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ class GorilinkManager extends EventEmitter {
join(data = {}, options = {}) {
const player = this.players.get(data.guild)
if (player) return player

this.sendWS({
op: 4,
d: {
guild_id: data.guild,
guild_id: data.guild.id || data.guild,
channel_id: data.voiceChannel.id || data.voiceChannel,
self_mute: options.selfMute || false,
self_deaf: options.selfDeaf || false
Expand All @@ -113,7 +114,7 @@ class GorilinkManager extends EventEmitter {
this.sendWS({
op: 4,
d: {
guild_id: guild,
guild_id: guild.id || guild,
channel_id: null,
self_mute: false,
self_deaf: false
Expand Down Expand Up @@ -190,14 +191,18 @@ class GorilinkManager extends EventEmitter {
* @param {Object} data Guild data
*/
spawnPlayer(data) {
const has = this.nodes.get(data.guild)
const guild = data.guild.id || data.guild

const has = this.nodes.get(guild)
if (has) return has

if(this.idealNodes.length === 0) throw Error('No nodes connected')

const node = this.nodes.get(this.idealNodes[0].tag || this.idealNodes[0].host)
if (!node) throw Error('No nodes avalible')

const player = new this.Player(node, data, this)
this.players.set(data.guild, player)
this.players.set(guild, player)

return player
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/GorilinkPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class GorilinkPlayer extends EventEmitter {
* Player guild id
* @type {String}
*/
this.guild = options.guild
this.guild = options.guild.id || options.guild

/**
* Player voiceChannel id
* @type {String}
*/
this.voiceChannel = options.voiceChannel
this.voiceChannel = options.voiceChannel.id || options.voiceChannel

/**
* Player textChannel
Expand Down
4 changes: 2 additions & 2 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ declare module 'gorilink' {
public on(event: 'nodeConnect' | 'nodeReconnect', listener: (node: LavalinkNode) => void): this
public on(event: 'nodeClose', listener: (event: any, node: LavalinkNode) => void): this
public on(event: 'nodeError', listener: (node: LavalinkNode, err: any) => void): this
public on(event: 'queueEnd', listener: (player: GorilinkManager) => void): this
public on(event: 'queueEnd', listener: (player: GorilinkPlayer) => void): this
public on(event: 'trackStart' | 'trackEnd', listener: (player: GorilinkPlayer, track: ITrack) => void): this
public on(event: 'trackStuck' | 'trackError', listener: (player: GorilinkPlayer, track: ITrack, data: any) => void): this
public on(event: 'socketClosed', listener: (player: GorilinkPlayer, data: any) => void): this

public once(event: 'nodeConnect' | 'nodeReconnect', listener: (node: LavalinkNode) => void): this
public once(event: 'nodeClose', listener: (event: any, node: LavalinkNode) => void): this
public once(event: 'nodeError', listener: (node: LavalinkNode, err: any) => void): this
public once(event: 'queueEnd', listener: (player: GorilinkManager) => void): this
public once(event: 'queueEnd', listener: (player: GorilinkPlayer) => void): this
public once(event: 'trackStart' | 'trackEnd', listener: (player: GorilinkPlayer, track: ITrack) => void): this
public once(event: 'trackStuck' | 'trackError', listener: (player: GorilinkPlayer, track: ITrack, data: any) => void): this
public once(event: 'socketClosed', listener: (player: GorilinkPlayer, data: any) => void): this
Expand Down

0 comments on commit 76cb27b

Please sign in to comment.