Removed reconnection

This commit is contained in:
da
2017-01-22 18:22:16 +01:00
parent 4d461c6f16
commit fc03d04e50
-33
View File
@@ -303,7 +303,6 @@ func enqueuePlay(user *discordgo.User, guild *discordgo.Guild, coll *SoundCollec
mutex.Unlock()
playSound(play, nil)
}
go checkReconnectCounter()
}
// Play a sound
@@ -461,38 +460,6 @@ func setIdleStatus() {
}
}
func checkReconnectCounter() {
mutex.Lock()
if len(queues) > 0 {
mutex.Unlock()
return
}
if rcCounter >= 20 {
reconnect()
rcCounter = 0
} else {
rcCounter++
}
mutex.Unlock()
}
func reconnect() {
log.Infoln("Reconnecting web socket.")
err := discord.Close()
if err != nil {
log.WithFields(log.Fields{
"error": err,
}).Error("Failed to close connection.")
return
}
err = discord.Open()
if err != nil {
log.WithFields(log.Fields{
"error": err,
}).Fatal("Failed to create discord websocket connection")
}
}
func onMessageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
if m.Content == "ping" || m.Content == "pong" {
// If the message is "ping" reply with "Pong!"