diff options
| author | William Hergès <william@herges.fr> | 2025-09-26 18:30:57 +0200 |
|---|---|---|
| committer | William Hergès <william@herges.fr> | 2025-09-26 18:30:57 +0200 |
| commit | b61a834b608df3d5e617912eefb28924ef3a46df (patch) | |
| tree | 00d2e373ba52b6091585c6a2c91e4b9f36c9af86 /commands | |
| parent | 80c147d5430bb3d8894231de3b6e960bcae43694 (diff) | |
build(gokord): bump to latest nightly
Diffstat (limited to 'commands')
| -rw-r--r-- | commands/config.go | 27 | ||||
| -rw-r--r-- | commands/credits.go | 5 | ||||
| -rw-r--r-- | commands/rank.go | 5 | ||||
| -rw-r--r-- | commands/reset.go | 7 | ||||
| -rw-r--r-- | commands/stats.go | 13 | ||||
| -rw-r--r-- | commands/top.go | 5 |
6 files changed, 34 insertions, 28 deletions
diff --git a/commands/config.go b/commands/config.go index fc15a5c..7ffd4af 100644 --- a/commands/config.go +++ b/commands/config.go @@ -8,10 +8,11 @@ import ( "git.anhgelus.world/anhgelus/les-copaings-bot/config" "git.anhgelus.world/anhgelus/les-copaings-bot/exp" "github.com/anhgelus/gokord/cmd" - discordgo "github.com/nyttikord/gokord" + "github.com/nyttikord/gokord/bot" "github.com/nyttikord/gokord/channel" "github.com/nyttikord/gokord/component" "github.com/nyttikord/gokord/discord/types" + "github.com/nyttikord/gokord/event" "github.com/nyttikord/gokord/interaction" ) @@ -20,7 +21,7 @@ const ( OpenConfig = "config" ) -func ConfigResponse(i *discordgo.InteractionCreate) *interaction.Response { +func ConfigResponse(i *event.InteractionCreate) *interaction.Response { cfg := config.GetGuildConfig(i.GuildID) roles := "" l := len(cfg.XpRoles) - 1 @@ -38,7 +39,7 @@ func ConfigResponse(i *discordgo.InteractionCreate) *interaction.Response { roles = "Aucun rôle configuré" } disChans := strings.Split(cfg.DisabledChannels, ";") - disChansDefault := []component.SelectMenuDefaultValue{} + var disChansDefault []component.SelectMenuDefaultValue for _, c := range disChans { if c != "" { disChansDefault = append(disChansDefault, component.SelectMenuDefaultValue{ @@ -47,7 +48,7 @@ func ConfigResponse(i *discordgo.InteractionCreate) *interaction.Response { }) } } - defaultChan := []component.SelectMenuDefaultValue{} + var defaultChan []component.SelectMenuDefaultValue if len(cfg.FallbackChannel) > 0 { defaultChan = append(defaultChan, component.SelectMenuDefaultValue{ ID: cfg.FallbackChannel, @@ -121,21 +122,21 @@ func ConfigResponse(i *discordgo.InteractionCreate) *interaction.Response { } func ConfigCommand( - session *discordgo.Session, - i *discordgo.InteractionCreate, + s bot.Session, + i *event.InteractionCreate, _ cmd.OptionMap, resp *cmd.ResponseBuilder, ) { - err := session.InteractionAPI().Respond(i.Interaction, ConfigResponse(i)) + err := s.InteractionAPI().Respond(i.Interaction, ConfigResponse(i)) if err != nil { - session.LogError(err, "config/guild.go - Sending config") + s.LogError(err, "config/guild.go - Sending config") } } func ConfigMessageComponent( - s *discordgo.Session, - i *discordgo.InteractionCreate, + s bot.Session, + i *event.InteractionCreate, _ *interaction.MessageComponentData, _ *cmd.ResponseBuilder, ) { @@ -149,10 +150,10 @@ func ConfigMessageComponent( } func ConfigModal( - s *discordgo.Session, - i *discordgo.InteractionCreate, + s bot.Session, + i *event.InteractionCreate, _ *interaction.ModalSubmitData, - resp *cmd.ResponseBuilder, + _ *cmd.ResponseBuilder, ) { response := ConfigResponse(i) response.Type = types.InteractionResponseUpdateMessage diff --git a/commands/credits.go b/commands/credits.go index e5fd711..b303834 100644 --- a/commands/credits.go +++ b/commands/credits.go @@ -3,10 +3,11 @@ package commands import ( "github.com/anhgelus/gokord" "github.com/anhgelus/gokord/cmd" - discordgo "github.com/nyttikord/gokord" + "github.com/nyttikord/gokord/bot" + "github.com/nyttikord/gokord/event" ) -func Credits(s *discordgo.Session, i *discordgo.InteractionCreate, _ cmd.OptionMap, resp *cmd.ResponseBuilder) { +func Credits(s bot.Session, _ *event.InteractionCreate, _ cmd.OptionMap, resp *cmd.ResponseBuilder) { msg := "**Les Copaings**, le bot gérant les serveurs privés de [anhgelus](<https://anhgelus.world/>).\n" msg += "Code source : <https://git.anhgelus.world/anhgelus/les-copaings-bot>\n\n" msg += "Host du bot : " + gokord.BaseCfg.GetAuthor() + ".\n\n" diff --git a/commands/rank.go b/commands/rank.go index d3a9f70..8f3090f 100644 --- a/commands/rank.go +++ b/commands/rank.go @@ -6,10 +6,11 @@ import ( "git.anhgelus.world/anhgelus/les-copaings-bot/exp" "git.anhgelus.world/anhgelus/les-copaings-bot/user" "github.com/anhgelus/gokord/cmd" - discordgo "github.com/nyttikord/gokord" + "github.com/nyttikord/gokord/bot" + "github.com/nyttikord/gokord/event" ) -func Rank(s *discordgo.Session, i *discordgo.InteractionCreate, optMap cmd.OptionMap, resp *cmd.ResponseBuilder) { +func Rank(s bot.Session, i *event.InteractionCreate, optMap cmd.OptionMap, resp *cmd.ResponseBuilder) { c := user.GetCopaing(i.Member.User.ID, i.GuildID) // current user = member who used /rank msg := "Votre niveau" m := i.Member diff --git a/commands/reset.go b/commands/reset.go index 77561c1..7caa238 100644 --- a/commands/reset.go +++ b/commands/reset.go @@ -4,10 +4,11 @@ import ( "git.anhgelus.world/anhgelus/les-copaings-bot/user" "github.com/anhgelus/gokord" "github.com/anhgelus/gokord/cmd" - discordgo "github.com/nyttikord/gokord" + "github.com/nyttikord/gokord/bot" + "github.com/nyttikord/gokord/event" ) -func Reset(s *discordgo.Session, i *discordgo.InteractionCreate, _ cmd.OptionMap, resp *cmd.ResponseBuilder) { +func Reset(s bot.Session, i *event.InteractionCreate, _ cmd.OptionMap, resp *cmd.ResponseBuilder) { var copaings []*user.Copaing gokord.DB.Where("guild_id = ?", i.GuildID).Delete(&copaings) if err := resp.IsEphemeral().SetMessage("L'XP a été reset.").Send(); err != nil { @@ -15,7 +16,7 @@ func Reset(s *discordgo.Session, i *discordgo.InteractionCreate, _ cmd.OptionMap } } -func ResetUser(s *discordgo.Session, i *discordgo.InteractionCreate, optMap cmd.OptionMap, resp *cmd.ResponseBuilder) { +func ResetUser(s bot.Session, i *event.InteractionCreate, optMap cmd.OptionMap, resp *cmd.ResponseBuilder) { resp.IsEphemeral() v, ok := optMap["user"] if !ok { diff --git a/commands/stats.go b/commands/stats.go index fcb0c29..2c22f0d 100644 --- a/commands/stats.go +++ b/commands/stats.go @@ -16,8 +16,9 @@ import ( "github.com/anhgelus/gokord" "github.com/anhgelus/gokord/cmd" "github.com/jackc/pgx/v5/pgtype" - discordgo "github.com/nyttikord/gokord" + "github.com/nyttikord/gokord/bot" "github.com/nyttikord/gokord/channel" + "github.com/nyttikord/gokord/event" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/vg" @@ -45,7 +46,7 @@ var colors = []color.RGBA{ {193, 18, 31, 255}, } -func Stats(s *discordgo.Session, i *discordgo.InteractionCreate, opt cmd.OptionMap, resp *cmd.ResponseBuilder) { +func Stats(s bot.Session, i *event.InteractionCreate, opt cmd.OptionMap, resp *cmd.ResponseBuilder) { cfg := config.GetGuildConfig(i.GuildID) days := 15 if gokord.Debug { @@ -97,13 +98,13 @@ func Stats(s *discordgo.Session, i *discordgo.InteractionCreate, opt cmd.OptionM }() } -func statsAll(s *discordgo.Session, i *discordgo.InteractionCreate, days int) (io.WriterTo, error) { +func statsAll(s bot.Session, i *event.InteractionCreate, days int) (io.WriterTo, error) { return stats(s, i, days, func(before, after string) *gorm.DB { return gokord.DB.Raw(before+"WHERE guild_id = ? and created_at > ?"+after, i.GuildID, exp.TimeStampNDaysBefore(uint(days))) }) } -func statsMember(s *discordgo.Session, i *discordgo.InteractionCreate, days int, discordID string) (io.WriterTo, error) { +func statsMember(s bot.Session, i *event.InteractionCreate, days int, discordID string) (io.WriterTo, error) { _, err := s.GuildAPI().Member(i.GuildID, discordID) if err != nil { return nil, err @@ -116,7 +117,7 @@ func statsMember(s *discordgo.Session, i *discordgo.InteractionCreate, days int, }) } -func stats(s *discordgo.Session, i *discordgo.InteractionCreate, days int, execSql func(before, after string) *gorm.DB) (io.WriterTo, error) { +func stats(s bot.Session, i *event.InteractionCreate, days int, execSql func(before, after string) *gorm.DB) (io.WriterTo, error) { var rawData []*data if gokord.Debug { var rawCopaingData []*user.CopaingXP @@ -193,7 +194,7 @@ func stats(s *discordgo.Session, i *discordgo.InteractionCreate, days int, execS return generatePlot(s, i, copaings, stats) } -func generatePlot(s *discordgo.Session, i *discordgo.InteractionCreate, copaings map[int]*user.Copaing, stats map[int][]plotter.XY) (io.WriterTo, error) { +func generatePlot(s bot.Session, i *event.InteractionCreate, copaings map[int]*user.Copaing, stats map[int][]plotter.XY) (io.WriterTo, error) { p := plot.New() fontSizeTitle := vg.Length(16) fontSize := vg.Length(12) diff --git a/commands/top.go b/commands/top.go index 195ee9b..751f7fa 100644 --- a/commands/top.go +++ b/commands/top.go @@ -8,11 +8,12 @@ import ( "git.anhgelus.world/anhgelus/les-copaings-bot/exp" "git.anhgelus.world/anhgelus/les-copaings-bot/user" "github.com/anhgelus/gokord/cmd" - discordgo "github.com/nyttikord/gokord" + "github.com/nyttikord/gokord/bot" "github.com/nyttikord/gokord/channel" + "github.com/nyttikord/gokord/event" ) -func Top(s *discordgo.Session, i *discordgo.InteractionCreate, _ cmd.OptionMap, resp *cmd.ResponseBuilder) { +func Top(s bot.Session, i *event.InteractionCreate, _ cmd.OptionMap, resp *cmd.ResponseBuilder) { err := resp.IsDeferred().Send() if err != nil { s.LogError(err, "sending deferred") |
