fix(config): not deleting role

This commit is contained in:
Anhgelus Morhtuuzh 2024-04-15 16:14:21 +02:00
parent 9e6a5ce1d3
commit bde93e6b80
No known key found for this signature in database
GPG key ID: CF4550297832A29F

View file

@ -2,6 +2,7 @@ package commands
import ( import (
"fmt" "fmt"
"github.com/anhgelus/gokord"
"github.com/anhgelus/gokord/utils" "github.com/anhgelus/gokord/utils"
"github.com/anhgelus/les-copaings-bot/config" "github.com/anhgelus/les-copaings-bot/config"
"github.com/anhgelus/les-copaings-bot/xp" "github.com/anhgelus/les-copaings-bot/xp"
@ -90,7 +91,7 @@ func ConfigXP(s *discordgo.Session, i *discordgo.InteractionCreate) {
RoleID: role.ID, RoleID: role.ID,
}) })
case "del": case "del":
pos, r := cfg.FindXpRole(exp, role.ID) _, r := cfg.FindXpRole(exp, role.ID)
if r == nil { if r == nil {
err := resp.Message("Le rôle n'a pas été trouvé dans la config.").Send() err := resp.Message("Le rôle n'a pas été trouvé dans la config.").Send()
if err != nil { if err != nil {
@ -98,7 +99,7 @@ func ConfigXP(s *discordgo.Session, i *discordgo.InteractionCreate) {
} }
return return
} }
cfg.XpRoles = append(cfg.XpRoles[:pos], cfg.XpRoles[pos+1:]...) gokord.DB.Delete(r)
case "edit": case "edit":
pos, r := cfg.FindXpRole(exp, role.ID) pos, r := cfg.FindXpRole(exp, role.ID)
if r == nil { if r == nil {