log level to debug and log ready and resumed connections

This commit is contained in:
Seraphim Strub 2023-10-13 22:20:34 +02:00
parent 05a11b87ea
commit a20bc22ab1
2 changed files with 13 additions and 4 deletions

View file

@ -8,7 +8,7 @@ import (
) )
func JoinEvent(event *events.GuildVoiceJoin) { func JoinEvent(event *events.GuildVoiceJoin) {
log.Printf("DEBUG: JoinEvent") log.Println("DEBUG: JoinEvent")
channelId := *event.VoiceState.ChannelID channelId := *event.VoiceState.ChannelID
channel, _ := event.Client().Rest().GetChannel(channelId) channel, _ := event.Client().Rest().GetChannel(channelId)
channelName := channel.Name() channelName := channel.Name()
@ -27,7 +27,7 @@ func MoveEvent(event *events.GuildVoiceMove) {
// no that's not a move event // no that's not a move event
return return
} }
log.Printf("DEBUG: MoveEvent") log.Println("DEBUG: MoveEvent")
channelOldId := *event.OldVoiceState.ChannelID channelOldId := *event.OldVoiceState.ChannelID
channelOld, _ := event.Client().Rest().GetChannel(channelOldId) channelOld, _ := event.Client().Rest().GetChannel(channelOldId)
channelOldName := channelOld.Name() channelOldName := channelOld.Name()
@ -45,9 +45,9 @@ func MoveEvent(event *events.GuildVoiceMove) {
} }
func LeaveEvent(event *events.GuildVoiceLeave) { func LeaveEvent(event *events.GuildVoiceLeave) {
log.Printf("DEBUG: LeaveEvent") log.Println("DEBUG: LeaveEvent")
if event.OldVoiceState.ChannelID == nil { if event.OldVoiceState.ChannelID == nil {
log.Printf("ERROR: OldVoiceState.ChannelID missing") log.Println("ERROR: OldVoiceState.ChannelID missing")
return return
} }
channelOldId := *event.OldVoiceState.ChannelID channelOldId := *event.OldVoiceState.ChannelID

View file

@ -5,7 +5,9 @@ import (
"github.com/disgoorg/disgo" "github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot" "github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/cache" "github.com/disgoorg/disgo/cache"
"github.com/disgoorg/disgo/events"
"github.com/disgoorg/disgo/gateway" "github.com/disgoorg/disgo/gateway"
disgolog "github.com/disgoorg/log"
"github.com/getsentry/sentry-go" "github.com/getsentry/sentry-go"
"grow.rievo.dev/discordBots/cmd/vcbot/config" "grow.rievo.dev/discordBots/cmd/vcbot/config"
"grow.rievo.dev/discordBots/cmd/vcbot/event" "grow.rievo.dev/discordBots/cmd/vcbot/event"
@ -21,6 +23,7 @@ var release string
func main() { func main() {
disgolog.SetLevel(disgolog.LevelDebug)
err := sentry.Init(sentry.ClientOptions{ err := sentry.Init(sentry.ClientOptions{
// Either set your DSN here or set the SENTRY_DSN environment variable. // Either set your DSN here or set the SENTRY_DSN environment variable.
//Dsn: "", //Dsn: "",
@ -62,6 +65,12 @@ func main() {
bot.WithEventListenerFunc(event.JoinEvent), bot.WithEventListenerFunc(event.JoinEvent),
bot.WithEventListenerFunc(event.MoveEvent), bot.WithEventListenerFunc(event.MoveEvent),
bot.WithEventListenerFunc(event.LeaveEvent), bot.WithEventListenerFunc(event.LeaveEvent),
bot.WithEventListenerFunc(func(event *events.Ready) {
log.Println("DEBUG: Connection Ready")
}),
bot.WithEventListenerFunc(func(event *events.Resumed) {
log.Println("DEBUG: Connection Resumed")
}),
) )
if err != nil { if err != nil {
log.Fatal("error while building vcbot instance: ", err) log.Fatal("error while building vcbot instance: ", err)