all repos — disgord @ 532569a1ea202c5e56710cedc078d2b8f37f7900

A simple Discord bot in Go.

disconnect after failed attempt
Marco Andronaco andronacomarco@gmail.com
Fri, 22 Nov 2024 17:09:56 +0100
commit

532569a1ea202c5e56710cedc078d2b8f37f7900

parent

7ec60f80e6cc38ccdab26e661e02a600046a0a97

4 files changed, 8 insertions(+), 17 deletions(-)

jump to
M go.modgo.mod

@@ -1,6 +1,6 @@

module github.com/birabittoh/disgord -go 1.23.2 +go 1.23.3 require ( github.com/FoxeiZ/dca v0.0.0-20240420115706-e4859a963796
M src/music/commands.gosrc/music/commands.go

@@ -39,15 +39,18 @@ logger.Errorf("could not join voice channel: %v", err)

return gl.MsgError } + // Get the queue for the guild + q := GetOrCreateQueue(voice) + // Get the video information video, err := getVideo(args) if err != nil { logger.Errorf("could not get video: %v", err) + if q.nowPlaying == nil { + voice.Disconnect() + } return gl.MsgError } - - // Get the queue for the guild - q := GetOrCreateQueue(voice) // Add video to the queue q.AddVideo(video)
M src/music/video.gosrc/music/video.go

@@ -51,7 +51,7 @@

func getFromYT(videoID string) (video *youtube.Video, err error) { url := "https://youtu.be/" + videoID - const maxRetries = 3 + const maxRetries = 5 const maxBytesToCheck = 1024 var duration time.Duration
M src/mylog/log.gosrc/mylog/log.go

@@ -84,30 +84,18 @@ l.fatalLogger.Fatalf(format, v...)

} func (l Logger) Error(v ...any) { - if l.level < ERROR { - return - } l.errorLogger.Println(v...) } func (l Logger) Errorf(format string, v ...any) { - if l.level < ERROR { - return - } l.errorLogger.Printf(format, v...) } func (l Logger) Warn(v ...any) { - if l.level < WARN { - return - } l.warnLogger.Println(v...) } func (l Logger) Warnf(format string, v ...any) { - if l.level < WARN { - return - } l.warnLogger.Printf(format, v...) }