aboutsummaryrefslogtreecommitdiff
path: root/config/guild.go
diff options
context:
space:
mode:
authorascpial <mail@ascpial.fr>2025-09-20 23:33:29 +0200
committerascpial <mail@ascpial.fr>2025-09-20 23:47:08 +0200
commit8a7189c3835a431b7fc16b189162f6f343e80b84 (patch)
treed0b69fad502c61c54020f44614e07d3637247176 /config/guild.go
parentc4a5e7db48edb5c69af8bec3e60e444951146d46 (diff)
feat(config): finish upgrading config
Diffstat (limited to 'config/guild.go')
-rw-r--r--config/guild.go27
1 files changed, 25 insertions, 2 deletions
diff --git a/config/guild.go b/config/guild.go
index 6310fa4..8096096 100644
--- a/config/guild.go
+++ b/config/guild.go
@@ -4,6 +4,7 @@ import (
"strings"
"github.com/anhgelus/gokord"
+ discordgo "github.com/nyttikord/gokord"
)
type GuildConfig struct {
@@ -31,8 +32,30 @@ func (cfg *GuildConfig) Save() error {
return gokord.DB.Save(cfg).Error
}
-func (cfg *GuildConfig) IsDisabled(channelID string) bool {
- return strings.Contains(cfg.DisabledChannels, channelID)
+func (cfg *GuildConfig) IsDisabled(s *discordgo.Session, channelID string) bool {
+ ok := true
+ s.LogInfo("Configuration: %s", cfg.DisabledChannels)
+ s.LogInfo("Channel %s, ok %t", channelID, ok)
+ for channelID != "" && ok {
+ s.LogInfo("Channel %s, ok %t", channelID, ok)
+ ok = !strings.Contains(cfg.DisabledChannels, channelID)
+ c, err := s.State.Channel(channelID)
+ if err != nil {
+ s.LogError(err, "Unable to find channel %s in state", c)
+ c, err = s.ChannelAPI().Channel(channelID)
+ if err == nil {
+ s.State.ChannelAdd(c)
+ } else {
+ s.LogError(err, "Unable to fetch channel %s", s)
+ return false
+ }
+ }
+ if err != nil {
+ return false
+ }
+ channelID = c.ParentID
+ }
+ return !ok
}
func (cfg *GuildConfig) FindXpRole(roleID string) (int, *XpRole) {