Skip to content

Commit

Permalink
fix: handle possible speaking error
Browse files Browse the repository at this point in the history
I was getting some random "Speaking() write json error, websocket: close sent"
  • Loading branch information
TheTipo01 committed Oct 11, 2024
1 parent 180dadf commit d9bd19d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions manager/sound.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ func (server *Server) playSound(el *queue.Element) (SkipReason, error) {
)

// Start speaking.
_ = server.VC.SetSpeaking(true)
err = server.VC.SetSpeaking(true)
if err != nil {
return Error, err
}
audioChannel := server.VC.GetAudioChannel()

go notify(notification.NotificationMessage{Notification: notification.Playing, Guild: server.GuildID})
Expand Down Expand Up @@ -56,7 +59,10 @@ func (server *Server) playSound(el *queue.Element) (SkipReason, error) {
_ = el.Closer.Close()
}

f, _ := os.Open(constants.CachePath + el.ID + constants.AudioExtension)
f, err := os.Open(constants.CachePath + el.ID + constants.AudioExtension)
if err != nil {
return Error, err
}
el.Reader = bufio.NewReader(f)
el.Closer = f
server.Frames.Store(0)
Expand Down

0 comments on commit d9bd19d

Please sign in to comment.