Reconnection check moved to better position
This commit is contained in:
@@ -303,6 +303,7 @@ func enqueuePlay(user *discordgo.User, guild *discordgo.Guild, coll *SoundCollec
|
|||||||
mutex.Unlock()
|
mutex.Unlock()
|
||||||
playSound(play, nil)
|
playSound(play, nil)
|
||||||
}
|
}
|
||||||
|
go checkReconnectCounter()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play a sound
|
// Play a sound
|
||||||
@@ -472,6 +473,7 @@ func checkReconnectCounter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func reconnect() {
|
func reconnect() {
|
||||||
|
log.Infoln("Reconnecting web socket.")
|
||||||
err := discord.Close()
|
err := discord.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
@@ -488,7 +490,6 @@ func reconnect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func onMessageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
func onMessageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
go checkReconnectCounter()
|
|
||||||
if m.Content == "ping" || m.Content == "pong" {
|
if m.Content == "ping" || m.Content == "pong" {
|
||||||
// If the message is "ping" reply with "Pong!"
|
// If the message is "ping" reply with "Pong!"
|
||||||
if m.Content == "ping" {
|
if m.Content == "ping" {
|
||||||
|
|||||||
Reference in New Issue
Block a user