feat(config): fallback channel
This commit is contained in:
parent
a8c0a395ac
commit
2b285f4523
3 changed files with 48 additions and 1 deletions
|
@ -43,6 +43,11 @@ func ConfigShow(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|||
Description: "Configuration",
|
||||
Color: utils.Success,
|
||||
Fields: []*discordgo.MessageEmbedField{
|
||||
{
|
||||
Name: "Salons par défaut",
|
||||
Value: fmt.Sprintf("<#%s>", cfg.FallbackChannel),
|
||||
Inline: false,
|
||||
},
|
||||
{
|
||||
Name: "Rôles liés aux niveaux",
|
||||
Value: roles,
|
||||
|
@ -172,7 +177,7 @@ func ConfigChannel(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|||
if !ok {
|
||||
err := resp.Message("Le salon n'a pas été renseigné.").Send()
|
||||
if err != nil {
|
||||
utils.SendAlert("commands/config.go - Channel not set", err.Error())
|
||||
utils.SendAlert("commands/config.go - Channel not set (disabled)", err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -211,3 +216,34 @@ func ConfigChannel(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|||
utils.SendAlert("commands/config.go - Modification saved message", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func ConfigFallbackChannel(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
optMap := utils.GenerateOptionMapForSubcommand(i)
|
||||
resp := utils.ResponseBuilder{C: s, I: i}
|
||||
resp.IsEphemeral()
|
||||
// verify every args
|
||||
salon, ok := optMap["channel"]
|
||||
if !ok {
|
||||
err := resp.Message("Le salon n'a pas été renseigné.").Send()
|
||||
if err != nil {
|
||||
utils.SendAlert("commands/config.go - Channel not set (fallback)", err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
channel := salon.ChannelValue(s)
|
||||
if channel.Type != discordgo.ChannelTypeGuildText {
|
||||
err := resp.Message("Le salon n'est pas un salon textuel.").Send()
|
||||
if err != nil {
|
||||
utils.SendAlert("commands/config.go - Invalid channel type", err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
cfg := config.GetGuildConfig(i.GuildID)
|
||||
cfg.FallbackChannel = channel.ID
|
||||
// save
|
||||
cfg.Save()
|
||||
err := resp.Message("Salon enregistré.").Send()
|
||||
if err != nil {
|
||||
utils.SendAlert("commands/config.go - Channel saved message", err.Error())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue