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 --- main.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 5bbc289..7b8e75f 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,7 @@ import ( "github.com/anhgelus/gokord/utils" "github.com/anhgelus/les-copaings-bot/commands" "github.com/anhgelus/les-copaings-bot/config" - "github.com/anhgelus/les-copaings-bot/xp" + "github.com/anhgelus/les-copaings-bot/user" "github.com/bwmarrin/discordgo" "time" ) @@ -36,18 +36,18 @@ func main() { panic(err) } - err = gokord.DB.AutoMigrate(&xp.Copaing{}, &config.GuildConfig{}, &config.XpRole{}) + err = gokord.DB.AutoMigrate(&user.Copaing{}, &config.GuildConfig{}, &config.XpRole{}) if err != nil { panic(err) } adm := gokord.AdminPermission - rankCmd := gokord.NewCommand("rank", "Affiche le niveau d'un copaing"). + rankCmd := gokord.NewCommand("rank", "Affiche le niveau d'un user"). HasOption(). AddOption(gokord.NewOption( discordgo.ApplicationCommandOptionUser, - "copaing", + "user", "Le niveau du Copaing que vous souhaitez obtenir", )). SetHandler(commands.Rank) @@ -58,7 +58,7 @@ func main() { gokord.NewCommand("show", "Affiche la config").SetHandler(commands.ConfigShow), ). AddSub( - gokord.NewCommand("xp", "Modifie l'xp"). + gokord.NewCommand("exp", "Modifie l'exp"). HasOption(). AddOption(gokord.NewOption( discordgo.ApplicationCommandOptionString, @@ -114,16 +114,16 @@ func main() { HasOption(). SetHandler(commands.Top) - resetCmd := gokord.NewCommand("reset", "Reset l'xp"). + resetCmd := gokord.NewCommand("reset", "Reset l'exp"). HasOption(). SetHandler(commands.Reset). SetPermission(&adm) - resetUserCmd := gokord.NewCommand("reset-user", "Reset l'xp d'un utilisation"). + resetUserCmd := gokord.NewCommand("reset-user", "Reset l'exp d'un utilisation"). HasOption(). AddOption(gokord.NewOption( discordgo.ApplicationCommandOptionUser, - "copaing", + "user", "Copaing a reset", ).IsRequired()). SetHandler(commands.ResetUser). @@ -176,14 +176,14 @@ func main() { stopPeriodicReducer <- true } - xp.CloseRedisClient() + config.CloseRedisClient() } func afterInit(dg *discordgo.Session) { // handlers - dg.AddHandler(xp.OnMessage) - dg.AddHandler(xp.OnVoiceUpdate) - dg.AddHandler(xp.OnLeave) + dg.AddHandler(OnMessage) + dg.AddHandler(OnVoiceUpdate) + dg.AddHandler(OnLeave) // setup timer for periodic reducer d := 24 * time.Hour @@ -192,6 +192,6 @@ func afterInit(dg *discordgo.Session) { d = time.Minute } stopPeriodicReducer = utils.NewTimer(d, func(stop chan<- interface{}) { - xp.PeriodicReducer(dg) + user.PeriodicReducer(dg) }) } -- cgit v1.2.3 From 01bafe9bf1de5be4e770b9500480807d4973d8d6 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 13 May 2025 16:15:47 +0200 Subject: feat(top): implements new kind of tops --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 7b8e75f..b1f137d 100644 --- a/main.go +++ b/main.go @@ -17,10 +17,10 @@ var ( //go:embed updates.json updatesData []byte Version = gokord.Version{ - Major: 2, - Minor: 4, + Major: 3, + Minor: 0, Patch: 0, - } // git version: 0.4.0 (it's the v2 of the bot) + } stopPeriodicReducer chan<- interface{} ) -- cgit v1.2.3 From 61c7bf4567249da0d13c2f738e56754a2c181c99 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 13 May 2025 16:52:04 +0200 Subject: fix(db): wrong relation and bad where condition --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.go') diff --git a/main.go b/main.go index b1f137d..a1fc1af 100644 --- a/main.go +++ b/main.go @@ -36,7 +36,7 @@ func main() { panic(err) } - err = gokord.DB.AutoMigrate(&user.Copaing{}, &config.GuildConfig{}, &config.XpRole{}) + err = gokord.DB.AutoMigrate(&user.Copaing{}, &config.GuildConfig{}, &config.XpRole{}, &user.CopaingXP{}) if err != nil { panic(err) } -- cgit v1.2.3 From a02a0d8e3e45d738c5a1a07dbc925c329ddf6278 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 13 May 2025 18:24:27 +0200 Subject: fix(command): using wrong key for /rank due to previous automatic refactor --- main.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index a1fc1af..6b714f1 100644 --- a/main.go +++ b/main.go @@ -43,11 +43,11 @@ func main() { adm := gokord.AdminPermission - rankCmd := gokord.NewCommand("rank", "Affiche le niveau d'un user"). + rankCmd := gokord.NewCommand("rank", "Affiche le niveau d'un copaing"). HasOption(). AddOption(gokord.NewOption( discordgo.ApplicationCommandOptionUser, - "user", + "copaing", "Le niveau du Copaing que vous souhaitez obtenir", )). SetHandler(commands.Rank) @@ -185,13 +185,7 @@ func afterInit(dg *discordgo.Session) { dg.AddHandler(OnVoiceUpdate) dg.AddHandler(OnLeave) - // setup timer for periodic reducer - d := 24 * time.Hour - if gokord.Debug { - // reduce time for debug - d = time.Minute - } - stopPeriodicReducer = utils.NewTimer(d, func(stop chan<- interface{}) { + stopPeriodicReducer = utils.NewTimer(24*time.Hour, func(stop chan<- interface{}) { user.PeriodicReducer(dg) }) } -- cgit v1.2.3 From 8b174209e193746216e711423cb26cebd0786581 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 13 May 2025 20:50:32 +0200 Subject: fix(command): automatic refactor changing names at wrong place --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 6b714f1..2035cb5 100644 --- a/main.go +++ b/main.go @@ -58,7 +58,7 @@ func main() { gokord.NewCommand("show", "Affiche la config").SetHandler(commands.ConfigShow), ). AddSub( - gokord.NewCommand("exp", "Modifie l'exp"). + gokord.NewCommand("xp", "Modifie l'xp"). HasOption(). AddOption(gokord.NewOption( discordgo.ApplicationCommandOptionString, @@ -114,12 +114,12 @@ func main() { HasOption(). SetHandler(commands.Top) - resetCmd := gokord.NewCommand("reset", "Reset l'exp"). + resetCmd := gokord.NewCommand("reset", "Reset l'xp"). HasOption(). SetHandler(commands.Reset). SetPermission(&adm) - resetUserCmd := gokord.NewCommand("reset-user", "Reset l'exp d'un utilisation"). + resetUserCmd := gokord.NewCommand("reset-user", "Reset l'xp d'un utilisation"). HasOption(). AddOption(gokord.NewOption( discordgo.ApplicationCommandOptionUser, -- cgit v1.2.3 From f56e10514e0fe74599fcdaea553f59cfe0cf5f70 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 13 May 2025 21:07:04 +0200 Subject: feat(command): /config for days before reduction --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 2035cb5..4b4062e 100644 --- a/main.go +++ b/main.go @@ -99,6 +99,16 @@ func main() { ).IsRequired()). SetHandler(commands.ConfigChannel), ). + AddSub( + gokord.NewCommand("period-before-reduce", "Temps avant la perte d'xp (affecte aussi le /top)"). + HasOption(). + AddOption(gokord.NewOption( + discordgo.ApplicationCommandOptionInteger, + "days", + "Nombre de jours avant la perte d'xp (doit être égal ou plus grand que 30)", + ).IsRequired()). + SetHandler(commands.ConfigPeriodBeforeReduce), + ). AddSub( gokord.NewCommand("fallback-channel", "Modifie le salon textuel par défaut"). HasOption(). -- cgit v1.2.3