aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--commands/deploy.go6
-rw-r--r--commands/stats.go11
-rw-r--r--config/guild.go6
-rw-r--r--justfile2
-rw-r--r--main.go3
6 files changed, 18 insertions, 16 deletions
diff --git a/README.md b/README.md
index 31d37dc..67f3bd1 100644
--- a/README.md
+++ b/README.md
@@ -58,7 +58,11 @@ Every time you edit this file, you must restart the bot.
## Config
-The main config file is `config/config.toml`.
+Use the flag `-deploy` to deploy commands.
+
+Use the flag `-v` to increase verbosity of the logging (already enabled in debug mode).
+
+The main config file is `config.toml`.
The default configuration is
```toml
diff --git a/commands/deploy.go b/commands/deploy.go
index c388228..ee98d07 100644
--- a/commands/deploy.go
+++ b/commands/deploy.go
@@ -71,11 +71,7 @@ func Deploy(ctx context.Context, dg bot.Session) error {
guildID := ""
if common.IsDebug(ctx) {
guildID = dg.GuildAPI().State.Guilds()[0]
- gld, err := dg.GuildAPI().State.Guild(guildID)
- if err != nil {
- return err
- }
- bot.Logger(ctx).Debug("using guild as debug", "guild", gld.Name)
+ bot.Logger(ctx).Debug("using guild as debug", "guild", guildID)
}
_, err := dg.InteractionAPI().CommandBulkOverwrite(dg.SessionState().Application().ID, guildID, commands).Do(ctx)
return err
diff --git a/commands/stats.go b/commands/stats.go
index 017cfc6..fbacb88 100644
--- a/commands/stats.go
+++ b/commands/stats.go
@@ -53,9 +53,14 @@ func Stats(ctx context.Context, dg bot.Session, i *interaction.ApplicationComman
days = 90
}
+ err := dg.InteractionAPI().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().Respond(i.Interaction, resp.Response()).Do(ctx)
+ _, err := dg.InteractionAPI().ResponseEdit(i.Interaction, resp.WebhookEdit()).Do(ctx)
if err != nil {
bot.Logger(ctx).Error("replying to interaction", "error", err)
}
@@ -71,10 +76,6 @@ func Stats(ctx context.Context, dg bot.Session, i *interaction.ApplicationComman
}
days = int(in)
}
- err := dg.InteractionAPI().Respond(i.Interaction, interaction.NewDeferredResponse()).Do(ctx)
- if err != nil {
- bot.Logger(ctx).Error("sending deferred", "error", err)
- }
var w io.WriterTo
if v, ok := opts["copaing"]; ok {
w, err = statsMember(ctx, dg, i, days, v.UserValue(ctx).ID)
diff --git a/config/guild.go b/config/guild.go
index 756c0a4..6cdc06b 100644
--- a/config/guild.go
+++ b/config/guild.go
@@ -9,9 +9,9 @@ import (
)
type Guild struct {
- ID uint `gorm:"primarykey"`
- GuildID string `gorm:"not null;unique"`
- XpRoles []XpRole
+ ID uint `gorm:"primarykey"`
+ GuildID string `gorm:"not null;unique"`
+ XpRoles []XpRole `gorm:"foreignKey:GuildConfigID"`
DisabledChannels string
FallbackChannel string
DaysXPRemains uint `gorm:"default:90"` // 30 * 3 = 90 (three months)
diff --git a/justfile b/justfile
index e66752f..c1dd592 100644
--- a/justfile
+++ b/justfile
@@ -12,7 +12,7 @@ update:
go run .
stop:
- podman stop postgres adminer || (echo "no container")
+ podman stop postgres adminer || echo "no container"
podman network rm db || echo "no network"
build:
diff --git a/main.go b/main.go
index 8f76d80..c119191 100644
--- a/main.go
+++ b/main.go
@@ -98,7 +98,7 @@ func main() {
ctx = common.SetAuthor(ctx, cfg.Author)
logLevel := slog.LevelInfo
- if verbose {
+ if verbose || cfg.Debug {
logLevel = slog.LevelDebug
}
dg := gokord.NewWithLogLevel("Bot "+token, logLevel)
@@ -155,6 +155,7 @@ func main() {
intrs.HandleCommand("reset", commands.Reset)
intrs.HandleCommand("reset-user", commands.ResetUser)
intrs.HandleCommand("credits", commands.Credits)
+ intrs.HandleCommand("stats", commands.Stats)
intrs.HandleCommand("rolereact", rolereact.HandleCommand)
intrs.HandleCommand("Modifier", rolereact.HandleModifyCommand)