1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-27 17:23:00 +00:00

Only add the guild to SessionErrors if the error is not nil

This commit is contained in:
Matthew Penner 2020-05-13 15:38:07 -06:00
parent 60346f23bb
commit 3aa92c8f05

View file

@ -149,15 +149,7 @@ func (e *CloseError) HasError() bool {
return true return true
} }
for _, err := range e.SessionErrors { return len(e.SessionErrors) > 0
if err == nil {
continue
}
return true
}
return false
} }
func (e *CloseError) Error() string { func (e *CloseError) Error() string {
@ -165,20 +157,11 @@ func (e *CloseError) Error() string {
return e.StateErr.Error() return e.StateErr.Error()
} }
var errorCount int if len(e.SessionErrors) < 1 {
for _, err := range e.SessionErrors {
if err == nil {
continue
}
errorCount++
}
if errorCount < 1 {
return "" return ""
} }
return strconv.Itoa(errorCount) + " voice sessions returned errors while attempting to disconnect" return strconv.Itoa(len(e.SessionErrors)) + " voice sessions returned errors while attempting to disconnect"
} }
func (v *Voice) Close() error { func (v *Voice) Close() error {
@ -190,7 +173,9 @@ func (v *Voice) Close() error {
defer v.mapmutex.Unlock() defer v.mapmutex.Unlock()
for gID, s := range v.sessions { for gID, s := range v.sessions {
err.SessionErrors[gID] = s.Disconnect() if dErr := s.Disconnect(); dErr != nil {
err.SessionErrors[gID] = dErr
}
} }
err.StateErr = v.State.Close() err.StateErr = v.State.Close()