package event import ( "fmt" "github.com/disgoorg/disgo/events" "grow.rievo.dev/discordBots/cmd/vcbot/helper" "log" ) func JoinEvent(event *events.GuildVoiceJoin) { log.Printf("DEBUG: JoinEvent") channelId := *event.VoiceState.ChannelID channel, _ := event.Client().Rest().GetChannel(channelId) channelName := channel.Name() userName := event.Member.EffectiveName() userMention := event.Member.Mention() message := fmt.Sprintf("**CHANNEL LOG:** %v joined %v", userName, channelName) messageEdit := fmt.Sprintf("**CHANNEL LOG:** %v joined %v", userMention, channelName) go helper.SendNoMention(event.Client(), message, messageEdit) helper.UpdateVoiceChannels(event.Client(), false) } func MoveEvent(event *events.GuildVoiceMove) { if event.OldVoiceState.ChannelID.String() == event.VoiceState.ChannelID.String() { // no that's not a move event return } log.Printf("DEBUG: MoveEvent") channelOldId := *event.OldVoiceState.ChannelID channelOld, _ := event.Client().Rest().GetChannel(channelOldId) channelOldName := channelOld.Name() channelId := *event.VoiceState.ChannelID channel, _ := event.Client().Rest().GetChannel(channelId) channelName := channel.Name() userName := event.Member.EffectiveName() userMention := event.Member.Mention() message := fmt.Sprintf("**CHANNEL LOG:** %v moved from %v to %v", userName, channelOldName, channelName) messageEdit := fmt.Sprintf("**CHANNEL LOG:** %v moved from %v to %v", userMention, channelOldName, channelName) go helper.SendNoMention(event.Client(), message, messageEdit) helper.UpdateVoiceChannels(event.Client(), false) } func LeaveEvent(event *events.GuildVoiceLeave) { log.Printf("DEBUG: LeaveEvent") if event.OldVoiceState.ChannelID == nil { log.Printf("ERROR: OldVoiceState.ChannelID missing") return } channelOldId := *event.OldVoiceState.ChannelID channelOld, _ := event.Client().Rest().GetChannel(channelOldId) channelOldName := channelOld.Name() userName := event.Member.EffectiveName() userMention := event.Member.Mention() message := fmt.Sprintf("**CHANNEL LOG:** %v left %v", userName, channelOldName) messageEdit := fmt.Sprintf("**CHANNEL LOG:** %v left %v", userMention, channelOldName) go helper.SendNoMention(event.Client(), message, messageEdit) helper.UpdateVoiceChannels(event.Client(), true) }