diff --git a/main.go b/main.go index 9f3ec60..fb39832 100644 --- a/main.go +++ b/main.go @@ -262,7 +262,7 @@ func createPrivateVCAndMove( break } wait := time.Duration(150*(attempt+1)) * time.Millisecond - log.Printf("Move fehlgeschlagen (Versuch %d): %v – retry in %s", attempt+1, moveErr, wait) + log.Printf("Move fehlgeschlagen (Versuch %d): %v - retry in %s", attempt+1, moveErr, wait) time.Sleep(wait) } if moveErr != nil { @@ -589,6 +589,22 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter } } +// Handler: Commands registrieren, wenn Bot auf neuen Server kommt +func onGuildCreate(s *discordgo.Session, g *discordgo.GuildCreate) { + appID := s.State.User.ID + log.Printf("Registriere Commands in neuer Guild: %s (%s)", g.Name, g.ID) + for _, cmd := range slashCommands { + c, err := s.ApplicationCommandCreate(appID, g.ID, cmd) + if err != nil { + log.Printf("Command-Registrierung in %s fehlgeschlagen: %v", g.Name, err) + continue + } + cfgMu.Lock() + createdCmds[g.ID] = append(createdCmds[g.ID], c) + cfgMu.Unlock() + } +} + // ===== Commands Definition ===== var ( adminPerm = int64(discordgo.PermissionAdministrator) @@ -661,6 +677,7 @@ func main() { s.Identify.Intents = discordgo.IntentsGuilds | discordgo.IntentsGuildVoiceStates s.AddHandler(onVoiceStateUpdate) + s.AddHandler(onGuildCreate) s.AddHandler(onInteractionCreate("")) s.AddHandler(func(s *discordgo.Session, r *discordgo.Ready) { log.Printf("Eingeloggt als %s", r.User.Username)