Only return valid existing voice connections

This commit is contained in:
Bruce Marriner 2016-03-16 22:47:53 -05:00
parent 7ec5304bc9
commit ee07ed8afe

View file

@ -338,13 +338,13 @@ type voiceChannelJoinOp struct {
// deaf : If true, you will be set to deafened upon joining.
func (s *Session) ChannelVoiceJoin(gID, cID string, mute, deaf bool) (voice *VoiceConnection, err error) {
// If a voice connection alreadyy exists for this guild then
// If a voice connection already exists for this guild then
// return that connection. If the channel differs, also change channels.
// TODO: check if the voice connection is really valid or just a shell
// because we might want to allow setting variables prior to getting here
// like debug, and other things.
var ok bool
if voice, ok = s.VoiceConnections[gID]; ok {
if voice, ok = s.VoiceConnections[gID]; ok && voice.GuildID != "" {
//TODO: consider a better variable than GuildID in the above check
// to verify if this connection is valid or not.
if voice.ChannelID != cID {
err = voice.ChangeChannel(cID)
}