diff options
| author | William Hergès <anhgelus.morhtuuzh@proton.me> | 2025-09-26 18:02:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-26 18:02:18 +0200 |
| commit | 80c147d5430bb3d8894231de3b6e960bcae43694 (patch) | |
| tree | c1aa0cdfec1b99761d393cb63b39057046be5b74 /config/guild.go | |
| parent | c4a5e7db48edb5c69af8bec3e60e444951146d46 (diff) | |
| parent | 30f110d8d49cd1174882c58916147f52e09dd51e (diff) | |
Merge pull request #14 from ascpial/new-config
[Feat] Finish upgrading config
Diffstat (limited to 'config/guild.go')
| -rw-r--r-- | config/guild.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/config/guild.go b/config/guild.go index 6310fa4..9cdb7e4 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,27 @@ 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 + for 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) { |
