This commit is contained in:
48
main.go
48
main.go
@@ -99,6 +99,7 @@ func setLanguage(guildID, language string) error {
|
||||
// Sprachabruf
|
||||
func getLanguage(guildID string) string {
|
||||
cfg := getCfg(guildID)
|
||||
//fmt.Println("Debug: Language:", cfg.Language)
|
||||
return cfg.Language
|
||||
}
|
||||
|
||||
@@ -720,11 +721,12 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{Content: "Konnte Voice-Channel nicht erstellen. Fehlen dem Bot Rechte (Manage Channels/Move Members)?", Flags: discordgo.MessageFlagsEphemeral}})
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("✅ Voice-Channel **%s** erstellt.", newChan.Name)
|
||||
|
||||
msg := fmt.Sprintf(translations[getLanguage(guildID)]["response.voicechannel.created"], newChan.Name)
|
||||
if srcVC == "" {
|
||||
msg += " Du bist aktuell in keinem Voice-Channel; join bitte manuell in deinen neuen Raum."
|
||||
msg += translations[getLanguage(guildID)]["response.voicechannel.created.notinvoice"]
|
||||
} else {
|
||||
msg += " Ich verschiebe dich jetzt dort hinein."
|
||||
msg += translations[getLanguage(guildID)]["response.voicechannel.created.move"]
|
||||
}
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{Content: msg, Flags: discordgo.MessageFlagsEphemeral}})
|
||||
|
||||
@@ -734,7 +736,7 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "❌ Nur Administratoren dürfen das.",
|
||||
Content: translations[getLanguage(guildID)]["response.setlobby.onlyadmins"],
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -753,7 +755,7 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "Bitte gib einen Namen an.",
|
||||
Content: translations[getLanguage(guildID)]["response.setlobby.pleaseentername"],
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -767,7 +769,7 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "⚠️ Lobby-Name gesetzt, aber Speichern fehlgeschlagen. Schau die Logs.",
|
||||
Content: translations[getLanguage(guildID)]["response.setlobby.error.saving"],
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -775,10 +777,11 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
}
|
||||
|
||||
// Antwort <= 3s
|
||||
msg := fmt.Sprintf(translations[getLanguage(guildID)]["response.setlobby.success"], name)
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "✅ Lobby-Name aktualisiert auf: " + name,
|
||||
Content: msg,
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -789,7 +792,7 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "❌ Nur Administratoren dürfen das.",
|
||||
Content: translations[getLanguage(guildID)]["response.setcategory.onlyadmins"],
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -808,7 +811,7 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "Bitte gib einen Namen an.",
|
||||
Content: translations[getLanguage(guildID)]["response.setcategory.error.name"],
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -822,7 +825,7 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "⚠️ Kategorie-Name gesetzt, aber Speichern fehlgeschlagen. Schau die Logs.",
|
||||
Content: translations[getLanguage(guildID)]["response.setcategory.error.saving"],
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -830,10 +833,11 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
}
|
||||
|
||||
// Antwort <= 3s
|
||||
msg := fmt.Sprintf(translations[getLanguage(guildID)]["response.setcategory.success"], name)
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "✅ Kategorie-Name aktualisiert auf: " + name,
|
||||
Content: msg,
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -844,7 +848,7 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "❌ Nur Administratoren dürfen das.",
|
||||
Content: translations[getLanguage(guildID)]["response.settimeout.onlyadmins"],
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -870,7 +874,7 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "⚠️ Timeout gesetzt, aber Speichern fehlgeschlagen. Schau die Logs.",
|
||||
Content: translations[getLanguage(guildID)]["response.settimeout.error.saving"],
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -878,10 +882,11 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
}
|
||||
|
||||
// Antwort <= 3s
|
||||
msg := fmt.Sprintf(translations[getLanguage(guildID)]["response.settimeout.success"], minutes)
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: fmt.Sprintf("✅ Timeout auf %d Minuten gesetzt.", minutes),
|
||||
Content: msg,
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -911,7 +916,7 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "Bitte gib ein gültiges Mitglied an.",
|
||||
Content: translations[getLanguage(guildID)]["response.adduser.error.user"],
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -924,7 +929,7 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "Du bist aktuell in keinem Voice-Channel. Betritt zuerst deinen privaten Channel.",
|
||||
Content: translations[getLanguage(guildID)]["response.adduser.error.notinvoice"],
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -938,7 +943,7 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: "❌ Du bist nicht der Besitzer dieses Channels oder dir fehlen Rechte (Manage Channel).",
|
||||
Content: translations[getLanguage(guildID)]["response.adduser.error.notowner"],
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -960,20 +965,21 @@ func onInteractionCreate(_ string) func(s *discordgo.Session, i *discordgo.Inter
|
||||
allow,
|
||||
0,
|
||||
); err != nil {
|
||||
msg := fmt.Sprintf(translations[getLanguage(guildID)]["response.adduser.error.setpermissions"], err)
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: fmt.Sprintf("Konnte Berechtigung nicht setzen: %v", err),
|
||||
Content: msg,
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf(translations[getLanguage(guildID)]["response.adduser.success"], target.Username)
|
||||
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: fmt.Sprintf("✅ %s hat jetzt Zugriff auf deinen Voice-Channel.", target.Username),
|
||||
Content: msg,
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
@@ -1257,7 +1263,7 @@ func Enabled(k string, def bool) bool {
|
||||
func main() {
|
||||
initDB()
|
||||
|
||||
loadTranslationsFromFile(GetENV("TRANSLATIONS_FILE", "./language.json"))
|
||||
translations, _ = loadTranslationsFromFile(GetENV("TRANSLATIONS_FILE", "/tempsrc/language.json"))
|
||||
token := GetENV("DISCORD_TOKEN", "")
|
||||
if token == "" {
|
||||
log.Fatal("Bitte setze DISCORD_TOKEN")
|
||||
|
Reference in New Issue
Block a user