Skip to content

Commit

Permalink
voice: Guild.voiceConnection => Guild.voice.connection
Browse files Browse the repository at this point in the history
  • Loading branch information
amishshah committed Apr 29, 2019
1 parent ce1e3d2 commit dd44647
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/client/voice/VoiceConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class VoiceConnection extends EventEmitter {
* @type {VoiceState}
*/
get voice() {
return this.channel.guild.voiceStates.get(this.client.user.id);
return this.channel.guild.voice;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,15 @@ class Guild extends Base {
null);
}

/**
* The voice state for the client user of this guild, if any
* @type {?VoiceState}
* @readonly
*/
get voice() {
return this.me ? this.me.voice : null;
}

/**
* Returns the GuildMember form of a User object, if the user is present in the guild.
* @param {UserResolvable} user The user that you want to obtain the GuildMember of
Expand Down
11 changes: 11 additions & 0 deletions src/structures/VoiceState.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const Base = require('./Base');
const { browser } = require('../util/Constants');

/**
* Represents the voice state for a Guild Member.
Expand Down Expand Up @@ -77,6 +78,16 @@ class VoiceState extends Base {
return this.guild.channels.get(this.channelID) || null;
}

/**
* If this is a voice state of the client user, then this will refer to the active VoiceConnection for this guild
* @type {?VoiceConnection}
* @readonly
*/
get connection() {
if (browser || this.id !== this.guild.me.id) return null;
return this.client.voice.connections.get(this.guild.id) || null;
}

/**
* Whether this member is either self-deafened or server-deafened
* @type {?boolean}
Expand Down

0 comments on commit dd44647

Please # to comment.