package discord import ( "github.com/bwmarrin/discordgo" "gitlab.com/whom/bingobot/internal/logging" ) func addHandlers() { session.s.AddHandler(handleConnect) session.s.AddHandler(handleDisconnect) session.s.AddHandler(handleVoiceStateUpdate) session.s.AddHandler(handleCommand) // handles InteractionCreate } func handleConnect(s *discordgo.Session, e *discordgo.Connect) { session.connected = true logging.Info("discord session connected") } func handleDisconnect(s *discordgo.Session, e *discordgo.Disconnect) { session.connected = false logging.Info("discord session disconnected") } func handleVoiceStateUpdate(_ *discordgo.Session, e *discordgo.VoiceStateUpdate) { if e.ChannelID == "" { // user disconnected logging.Info("user left channel", "uid", e.UserID) stopActivityTimer(e.UserID) return } // user connected logging.Info("user joined channel", "uid", e.UserID, "channel", e.ChannelID) startActivityTimer(e.UserID) }