From 0a445aa1c73bc1410899c53778ae090a24c38dac Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 13 May 2025 12:13:55 +0200 Subject: fix(config): limits one config per guild --- config/guild.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'config/guild.go') diff --git a/config/guild.go b/config/guild.go index 242cc89..b4b7014 100644 --- a/config/guild.go +++ b/config/guild.go @@ -9,8 +9,8 @@ import ( type GuildConfig struct { gorm.Model - GuildID string `gorm:"not null"` - XpRoles []XpRole + GuildID string `gorm:"not null;unique"` + XpRoles []*XpRole DisabledChannels string FallbackChannel string } @@ -46,7 +46,7 @@ func (cfg *GuildConfig) IsDisabled(channelID string) bool { func (cfg *GuildConfig) FindXpRole(roleID string) (int, *XpRole) { for i, r := range cfg.XpRoles { if r.RoleID == roleID { - return i, &r + return i, r } } return 0, nil -- cgit v1.2.3 From c408afc8797b0da5e1d73d190a8f5884870b510c Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 13 May 2025 12:50:20 +0200 Subject: style(files): reorganize everything --- config/guild.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config/guild.go') diff --git a/config/guild.go b/config/guild.go index b4b7014..0971837 100644 --- a/config/guild.go +++ b/config/guild.go @@ -10,7 +10,7 @@ import ( type GuildConfig struct { gorm.Model GuildID string `gorm:"not null;unique"` - XpRoles []*XpRole + XpRoles []XpRole DisabledChannels string FallbackChannel string } @@ -46,7 +46,7 @@ func (cfg *GuildConfig) IsDisabled(channelID string) bool { func (cfg *GuildConfig) FindXpRole(roleID string) (int, *XpRole) { for i, r := range cfg.XpRoles { if r.RoleID == roleID { - return i, r + return i, &r } } return 0, nil -- cgit v1.2.3 From 6b6c775ab3af659e26f0c79dbabd86d88d2451d5 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 13 May 2025 13:15:59 +0200 Subject: refactor(gorm): remove ...At fields from model --- config/guild.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'config/guild.go') diff --git a/config/guild.go b/config/guild.go index 0971837..5e41465 100644 --- a/config/guild.go +++ b/config/guild.go @@ -3,12 +3,11 @@ package config import ( "github.com/anhgelus/gokord" "github.com/anhgelus/gokord/utils" - "gorm.io/gorm" "strings" ) type GuildConfig struct { - gorm.Model + ID uint `gorm:"primarykey"` GuildID string `gorm:"not null;unique"` XpRoles []XpRole DisabledChannels string @@ -16,7 +15,7 @@ type GuildConfig struct { } type XpRole struct { - gorm.Model + ID uint `gorm:"primarykey"` XP uint RoleID string GuildConfigID uint -- cgit v1.2.3 From 799df74fcda5266fd295b49fc759c605c815cad9 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 13 May 2025 14:11:11 +0200 Subject: feat(xp): new add --- config/guild.go | 1 + 1 file changed, 1 insertion(+) (limited to 'config/guild.go') diff --git a/config/guild.go b/config/guild.go index 5e41465..fb7eaef 100644 --- a/config/guild.go +++ b/config/guild.go @@ -12,6 +12,7 @@ type GuildConfig struct { XpRoles []XpRole DisabledChannels string FallbackChannel string + DaysXPRemains uint `gorm:"default:90"` // 30 * 3 = 90 (three months) } type XpRole struct { -- cgit v1.2.3