aboutsummaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/config.go6
-rw-r--r--commands/credits.go2
-rw-r--r--commands/deploy.go2
-rw-r--r--commands/rank.go5
-rw-r--r--commands/reset.go4
-rw-r--r--commands/stats.go9
-rw-r--r--commands/top.go2
7 files changed, 16 insertions, 14 deletions
diff --git a/commands/config.go b/commands/config.go
index d9b04ec..37aa953 100644
--- a/commands/config.go
+++ b/commands/config.go
@@ -121,7 +121,7 @@ func ConfigResponse(ctx context.Context, guildID string) *interaction.Response {
}
func ConfigCommand(ctx context.Context, dg bot.Session, i *interaction.ApplicationCommand) {
- err := dg.InteractionAPI().Respond(i.Interaction, ConfigResponse(ctx, i.GuildID)).Do(ctx)
+ err := interaction.Respond(i.Interaction, ConfigResponse(ctx, i.GuildID)).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("sending config", "error", err)
}
@@ -131,7 +131,7 @@ func ConfigMessageComponent(ctx context.Context, dg bot.Session, i *interaction.
response := ConfigResponse(ctx, i.GuildID)
response.Type = types.InteractionResponseUpdateMessage
- err := dg.InteractionAPI().Respond(i.Interaction, response).Do(ctx)
+ err := interaction.Respond(i.Interaction, response).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("sending config", "error", err)
}
@@ -141,7 +141,7 @@ func ConfigModal(ctx context.Context, dg bot.Session, i *interaction.ModalSubmit
response := ConfigResponse(ctx, i.GuildID)
response.Type = types.InteractionResponseUpdateMessage
- err := dg.InteractionAPI().Respond(i.Interaction, response).Do(ctx)
+ err := interaction.Respond(i.Interaction, response).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("sending config", "error", err)
}
diff --git a/commands/credits.go b/commands/credits.go
index a27d2cc..403329e 100644
--- a/commands/credits.go
+++ b/commands/credits.go
@@ -15,7 +15,7 @@ func Credits(ctx context.Context, dg bot.Session, i *interaction.ApplicationComm
msg += "Utilise :\n- [nyttikord/gokord](<https://github.com/nyttikord/gokord>)\n"
msg += "- [Inter](<https://github.com/rsms/inter>)"
resp := interaction.NewMessageResponse().Message(msg).Response()
- err := dg.InteractionAPI().Respond(i.Interaction, resp).Do(ctx)
+ err := interaction.Respond(i.Interaction, resp).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("sending credits", "error", err)
}
diff --git a/commands/deploy.go b/commands/deploy.go
index ee98d07..e652d43 100644
--- a/commands/deploy.go
+++ b/commands/deploy.go
@@ -73,6 +73,6 @@ func Deploy(ctx context.Context, dg bot.Session) error {
guildID = dg.GuildAPI().State.Guilds()[0]
bot.Logger(ctx).Debug("using guild as debug", "guild", guildID)
}
- _, err := dg.InteractionAPI().CommandBulkOverwrite(dg.SessionState().Application().ID, guildID, commands).Do(ctx)
+ _, err := interaction.OverwriteCommands(dg.SessionState().Application().ID, guildID, commands).Do(ctx)
return err
}
diff --git a/commands/rank.go b/commands/rank.go
index 07bbe75..aea2aa8 100644
--- a/commands/rank.go
+++ b/commands/rank.go
@@ -7,6 +7,7 @@ import (
"git.anhgelus.world/anhgelus/les-copaings-bot/exp"
"git.anhgelus.world/anhgelus/les-copaings-bot/user"
"github.com/nyttikord/gokord/bot"
+ "github.com/nyttikord/gokord/guild"
"github.com/nyttikord/gokord/interaction"
)
@@ -17,7 +18,7 @@ func Rank(ctx context.Context, dg bot.Session, i *interaction.ApplicationCommand
opts := i.OptionMap()
resp := interaction.NewMessageResponse()
defer func() {
- err := dg.InteractionAPI().Respond(i.Interaction, resp.Response()).Do(ctx)
+ err := interaction.Respond(i.Interaction, resp.Response()).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("replying to interaction", "error", err)
}
@@ -29,7 +30,7 @@ func Rank(ctx context.Context, dg bot.Session, i *interaction.ApplicationCommand
resp.IsEphemeral().Message("Imagine si les bots avaient un niveau :rolling_eyes:")
return
}
- m, err = dg.GuildAPI().Member(i.GuildID, u.ID).Do(ctx)
+ m, err = guild.GetMember(i.GuildID, u.ID).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("fetching guild member", "error", err, "user", u.Username, "guild", i.GuildID)
resp.IsEphemeral().Message("Erreur : impossible de récupérer le membre")
diff --git a/commands/reset.go b/commands/reset.go
index 85f8f0d..f9c81d2 100644
--- a/commands/reset.go
+++ b/commands/reset.go
@@ -14,7 +14,7 @@ func Reset(ctx context.Context, dg bot.Session, i *interaction.ApplicationComman
//TODO: delete everything from cache
common.GetDB(ctx).Where("guild_id = ?", i.GuildID).Delete(&copaings)
resp := interaction.NewMessageResponse().IsEphemeral().Message("L'XP a été reset.").Response()
- err := dg.InteractionAPI().Respond(i.Interaction, resp).Do(ctx)
+ err := interaction.Respond(i.Interaction, resp).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("sending reset success", "error", err)
}
@@ -23,7 +23,7 @@ func Reset(ctx context.Context, dg bot.Session, i *interaction.ApplicationComman
func ResetUser(ctx context.Context, dg bot.Session, i *interaction.ApplicationCommand) {
resp := interaction.NewMessageResponse().IsEphemeral()
defer func() {
- err := dg.InteractionAPI().Respond(i.Interaction, resp.Response()).Do(ctx)
+ err := interaction.Respond(i.Interaction, resp.Response()).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("replying to interaction", "error", err)
}
diff --git a/commands/stats.go b/commands/stats.go
index 971d36a..2cc0b3e 100644
--- a/commands/stats.go
+++ b/commands/stats.go
@@ -19,6 +19,7 @@ import (
"github.com/jackc/pgx/v5/pgtype"
"github.com/nyttikord/gokord/bot"
"github.com/nyttikord/gokord/discord/request"
+ "github.com/nyttikord/gokord/guild"
"github.com/nyttikord/gokord/interaction"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
@@ -56,14 +57,14 @@ func Stats(ctx context.Context, dg bot.Session, i *interaction.ApplicationComman
days = 90
}
- err := dg.InteractionAPI().Respond(i.Interaction, interaction.NewDeferredResponse()).Do(ctx)
+ err := interaction.Respond(i.Interaction, interaction.NewDeferredResponse()).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("sending deferred", "error", err)
}
resp := interaction.NewMessageResponse()
defer func() {
- _, err = dg.InteractionAPI().ResponseEdit(i.Interaction, resp.WebhookEdit()).Do(ctx)
+ _, err = interaction.EditResponse(i.Interaction, resp.WebhookEdit()).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("replying to interaction", "error", err)
}
@@ -118,7 +119,7 @@ func statsAll(ctx context.Context, dg bot.Session, i *interaction.ApplicationCom
}
func statsMember(ctx context.Context, dg bot.Session, i *interaction.ApplicationCommand, days int, discordID string) (io.WriterTo, error) {
- _, err := dg.GuildAPI().Member(i.GuildID, discordID).Do(ctx)
+ _, err := guild.GetMember(i.GuildID, discordID).Do(ctx)
if err != nil {
return nil, err
}
@@ -236,7 +237,7 @@ func generatePlot(ctx context.Context, dg bot.Session, i *interaction.Applicatio
cnt := 0
for in, c := range copaings {
- m, err := dg.GuildAPI().Member(i.GuildID, c.DiscordID).Do(ctx)
+ m, err := guild.GetMember(i.GuildID, c.DiscordID).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("fetching guild member", "error", err)
return nil, err
diff --git a/commands/top.go b/commands/top.go
index 7b57d8f..aa0c288 100644
--- a/commands/top.go
+++ b/commands/top.go
@@ -50,7 +50,7 @@ func Top(ctx context.Context, dg bot.Session, i *interaction.ApplicationCommand)
resp.AddEmbed(embeds[1]).
AddEmbed(embeds[2])
}
- err := dg.InteractionAPI().Respond(i.Interaction, resp.Response()).Do(ctx)
+ err := interaction.Respond(i.Interaction, resp.Response()).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("sending response top", "error", err)
}