From 969ba3e0b9580cb0dedc1c78bcda726f18e3a76e Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Sat, 25 Oct 2025 22:58:16 +0200 Subject: build(gokord): upgrade to latest nightly --- dynamicid/handling.go | 5 +++-- events.go | 7 ++++--- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- main.go | 7 ++++--- rolereact/events.go | 4 ++++ user/level.go | 10 +++++----- 7 files changed, 32 insertions(+), 25 deletions(-) diff --git a/dynamicid/handling.go b/dynamicid/handling.go index 8369e27..e43d658 100644 --- a/dynamicid/handling.go +++ b/dynamicid/handling.go @@ -1,6 +1,7 @@ package dynamicid import ( + "context" "strings" "github.com/anhgelus/gokord" @@ -21,7 +22,7 @@ func HandleDynamicMessageComponent[DynamicData any]( ), base string, ) { - b.AddHandler(func(s bot.Session, i *event.InteractionCreate) { + b.AddHandler(func(_ context.Context, s bot.Session, i *event.InteractionCreate) { if i.Type != types.InteractionMessageComponent { return } @@ -51,7 +52,7 @@ func HandleDynamicModalComponent[DynamicData any]( ), base string, ) { - b.AddHandler(func(s bot.Session, i *event.InteractionCreate) { + b.AddHandler(func(_ context.Context, s bot.Session, i *event.InteractionCreate) { if i.Type != types.InteractionModalSubmit { return } diff --git a/events.go b/events.go index 9a3f508..5191120 100644 --- a/events.go +++ b/events.go @@ -1,6 +1,7 @@ package main import ( + "context" "fmt" "strings" "time" @@ -23,7 +24,7 @@ var ( connectedSince = map[string]int64{} ) -func OnMessage(s bot.Session, m *event.MessageCreate) { +func OnMessage(_ context.Context, s bot.Session, m *event.MessageCreate) { if m.Author.Bot { return } @@ -49,7 +50,7 @@ func OnMessage(s bot.Session, m *event.MessageCreate) { }) } -func OnVoiceUpdate(s bot.Session, e *event.VoiceStateUpdate) { +func OnVoiceUpdate(_ context.Context, s bot.Session, e *event.VoiceStateUpdate) { if e.Member.User.Bot { return } @@ -112,7 +113,7 @@ func onDisconnect(s bot.Session, e *event.VoiceStateUpdate) { }) } -func OnLeave(s bot.Session, e *event.GuildMemberRemove) { +func OnLeave(_ context.Context, s bot.Session, e *event.GuildMemberRemove) { s.Logger().Debug("leave event", "user", e.User.Username) if e.User.Bot { return diff --git a/go.mod b/go.mod index a4c194e..61005fc 100644 --- a/go.mod +++ b/go.mod @@ -5,10 +5,10 @@ go 1.24.0 toolchain go1.24.6 require ( - github.com/anhgelus/gokord v0.13.1 + github.com/anhgelus/gokord v0.13.2-0.20251025205525-12213d3f60bc github.com/jackc/pgx/v5 v5.7.5 github.com/joho/godotenv v1.5.1 - github.com/nyttikord/gokord v0.32.1 + github.com/nyttikord/gokord v0.32.2-0.20251025205355-aa6d1b6f6cf8 github.com/pelletier/go-toml/v2 v2.2.4 golang.org/x/image v0.30.0 gonum.org/v1/plot v0.16.0 @@ -24,16 +24,16 @@ require ( github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b // indirect github.com/campoy/embedmd v1.0.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/coder/websocket v1.8.14 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/gorilla/websocket v1.5.3 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/redis/go-redis/v9 v9.14.0 // indirect + github.com/redis/go-redis/v9 v9.16.0 // indirect golang.org/x/crypto v0.43.0 // indirect golang.org/x/sync v0.17.0 // indirect golang.org/x/sys v0.37.0 // indirect diff --git a/go.sum b/go.sum index f49ffa0..4594d5f 100644 --- a/go.sum +++ b/go.sum @@ -17,8 +17,8 @@ github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw= github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM= -github.com/anhgelus/gokord v0.13.1 h1:ggD5k6dWvtX7XzlM1dCNSuiIPwcZcuN6zcQ2ckef0Bc= -github.com/anhgelus/gokord v0.13.1/go.mod h1:xfeWgxMZERkl4fcSk0Teh2rKDPiYmVaWT3/PgzPUyhg= +github.com/anhgelus/gokord v0.13.2-0.20251025205525-12213d3f60bc h1:pZHCOh4uGzjta371cNT8RDDPXgBE5udXLX3JyclFwiM= +github.com/anhgelus/gokord v0.13.2-0.20251025205525-12213d3f60bc/go.mod h1:KOIi7EH/DzM9yUOTpuUHxPungpZYp7OLbwVyjQm3m2w= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= @@ -27,6 +27,8 @@ github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY= github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g= +github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -34,8 +36,6 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= -github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= @@ -51,14 +51,14 @@ github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/nyttikord/gokord v0.32.1 h1:sOqhTWnKKkCbarxYh5fsJFmLVfk4dd6hSfHdvNLWO1I= -github.com/nyttikord/gokord v0.32.1/go.mod h1:Oi0y5sfiYa+hVuV5ZSJ9UMWAGkcaLOhM7xB1TiCdX3U= +github.com/nyttikord/gokord v0.32.2-0.20251025205355-aa6d1b6f6cf8 h1:rR8eUz1X+1BRN95xGFgcLbFztoDwvbv+Qb9mkb9sTtA= +github.com/nyttikord/gokord v0.32.2-0.20251025205355-aa6d1b6f6cf8/go.mod h1:0DlJSojwCHLKvLcpCZLEfAaWaJniMNJsfwESo/+aI08= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/redis/go-redis/v9 v9.14.0 h1:u4tNCjXOyzfgeLN+vAZaW1xUooqWDqVEsZN0U01jfAE= -github.com/redis/go-redis/v9 v9.14.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= +github.com/redis/go-redis/v9 v9.16.0 h1:OotgqgLSRCmzfqChbQyG1PHC3tLNR89DG4jdOERSEP4= +github.com/redis/go-redis/v9 v9.16.0/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= diff --git a/main.go b/main.go index 9c0efd9..d2e6c01 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "context" _ "embed" "errors" "flag" @@ -196,7 +197,7 @@ func main() { // related to rolereact // TEMP BECAUSE (OLD) GOKORD DOES NOT SUPPORT COMMAND MESSAGE - b.AddHandler(func(s bot.Session, e *event.Ready) { + b.AddHandler(func(_ context.Context, s bot.Session, e *event.Ready) { guildID := "" if gokord.Debug { gs, err := s.GuildAPI().UserGuilds(1, "", "", false) @@ -220,7 +221,7 @@ func main() { } s.Logger().Debug("pushed rolereaction message command", "CommandID", c.ID) }) - b.AddHandler(func(s bot.Session, i *event.InteractionCreate) { + b.AddHandler(func(_ context.Context, s bot.Session, i *event.InteractionCreate) { if i.Type != types.InteractionApplicationCommand { return } @@ -278,7 +279,7 @@ func main() { b.AddHandler(OnVoiceUpdate) b.AddHandler(OnLeave) - b.Start() + b.Start(context.Background()) if stopPeriodicReducer != nil { stopPeriodicReducer <- true diff --git a/rolereact/events.go b/rolereact/events.go index 1de3fe0..54400eb 100644 --- a/rolereact/events.go +++ b/rolereact/events.go @@ -1,6 +1,8 @@ package rolereact import ( + "context" + "git.anhgelus.world/anhgelus/les-copaings-bot/config" oldGokord "github.com/anhgelus/gokord" "github.com/nyttikord/gokord/bot" @@ -12,6 +14,7 @@ type RoleReact struct { } func HandleReactionAdd( + _ context.Context, s bot.Session, e *event.MessageReactionAdd, ) { @@ -29,6 +32,7 @@ func HandleReactionAdd( } func HandleReactionRemove( + _ context.Context, s bot.Session, e *event.MessageReactionRemove, ) { diff --git a/user/level.go b/user/level.go index 4303b47..e7b96af 100644 --- a/user/level.go +++ b/user/level.go @@ -82,20 +82,20 @@ func PeriodicReducer(s *discordgo.Session) { } wg.Wait() i := 0 - for g := range s.GuildAPI().State.Guilds() { + for _, g := range s.GuildAPI().State.Guilds() { i++ wg.Add(1) go func() { defer wg.Done() - cfg := config.GetGuildConfig(g.ID) + cfg := config.GetGuildConfig(g) res := gokord.DB. Model(&CopaingXP{}). - Where("guild_id = ? and created_at < ?", g.ID, exp.TimeStampNDaysBefore(cfg.DaysXPRemains)). + Where("guild_id = ? and created_at < ?", g, exp.TimeStampNDaysBefore(cfg.DaysXPRemains)). Delete(&CopaingXP{}) if res.Error != nil { - s.Logger().Error("removing old xp", "error", res.Error, "guild", g.ID) + s.Logger().Error("removing old xp", "error", res.Error, "guild", g) } - s.Logger().Debug("guild cleaned", "guild", g.Name, "rows affected", res.RowsAffected) + s.Logger().Debug("guild cleaned", "guild", g, "rows affected", res.RowsAffected) }() } wg.Wait() -- cgit v1.2.3