aboutsummaryrefslogtreecommitdiff
path: root/config/guild.go
diff options
context:
space:
mode:
Diffstat (limited to 'config/guild.go')
-rw-r--r--config/guild.go23
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