diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-03-07 13:20:56 +0100 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-03-07 13:29:46 +0100 |
| commit | 89b23632f5ceeebd82132210c1407dc9514a547b (patch) | |
| tree | 647782dc5f1b1148893c10bc8b3e712b6ea8362b /config/guild.go | |
| parent | 9da4d0379b10da8b33563dcd280aa2a9586aa3fb (diff) | |
feat(gokord): replace snowflake by uintrefactor/leave-old-gokord
Diffstat (limited to 'config/guild.go')
| -rw-r--r-- | config/guild.go | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/config/guild.go b/config/guild.go index 6c46a1a..bcebd65 100644 --- a/config/guild.go +++ b/config/guild.go @@ -2,6 +2,7 @@ package config import ( "context" + "fmt" "strings" "git.anhgelus.world/anhgelus/les-copaings-bot/common" @@ -11,19 +12,19 @@ import ( type Guild struct { ID uint `gorm:"primarykey"` - GuildID string `gorm:"not null;unique"` + GuildID uint64 `gorm:"not null;unique"` XpRoles []XpRole `gorm:"foreignKey:GuildConfigID"` DisabledChannels string - FallbackChannel string + FallbackChannel uint64 DaysXPRemains uint `gorm:"default:90"` // 30 * 3 = 90 (three months) RrMessages []RoleReactMessage } type RoleReactMessage struct { ID uint `gorm:"primarykey"` - MessageID string `gorm:"not null;unique"` - ChannelID string - GuildID string + MessageID uint64 `gorm:"not null;unique"` + ChannelID uint64 + GuildID uint64 Note string Roles []*RoleReact GuildConfigID uint @@ -32,12 +33,12 @@ type RoleReactMessage struct { type RoleReact struct { ID uint `gorm:"primarykey"` Reaction string - RoleID string + RoleID uint64 RoleReactMessageID uint CounterID uint `gorm:"-"` } -func GetGuildConfig(ctx context.Context, guildID string) *Guild { +func GetGuildConfig(ctx context.Context, guildID uint64) *Guild { cfg := Guild{GuildID: guildID} if err := cfg.Load(ctx); err != nil { panic(err) @@ -53,10 +54,10 @@ func (cfg *Guild) Save(ctx context.Context) error { return common.GetDB(ctx).Save(cfg).Error } -func (cfg *Guild) IsDisabled(ctx context.Context, dg bot.Session, channelID string) bool { +func (cfg *Guild) IsDisabled(ctx context.Context, dg bot.Session, channelID uint64) bool { ok := true - for channelID != "" && ok { - ok = !strings.Contains(cfg.DisabledChannels, channelID) + for channelID != 0 && ok { + ok = !strings.Contains(cfg.DisabledChannels, fmt.Sprintf("%d", channelID)) c, err := dg.ChannelState().GetChannel(channelID) if err != nil { bot.Logger(ctx).Error("unable to find channel %s in state", "error", err, "channel", c) @@ -74,7 +75,7 @@ func (cfg *Guild) IsDisabled(ctx context.Context, dg bot.Session, channelID stri return !ok } -func (cfg *Guild) FindXpRole(roleID string) (int, *XpRole) { +func (cfg *Guild) FindXpRole(roleID uint64) (int, *XpRole) { for i, r := range cfg.XpRoles { if r.RoleID == roleID { return i, &r |
