aboutsummaryrefslogtreecommitdiff
path: root/rolereact
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-03-07 13:20:56 +0100
committerAnhgelus Morhtuuzh <william@herges.fr>2026-03-07 13:29:46 +0100
commit89b23632f5ceeebd82132210c1407dc9514a547b (patch)
tree647782dc5f1b1148893c10bc8b3e712b6ea8362b /rolereact
parent9da4d0379b10da8b33563dcd280aa2a9586aa3fb (diff)
feat(gokord): replace snowflake by uintrefactor/leave-old-gokord
Diffstat (limited to 'rolereact')
-rw-r--r--rolereact/events.go2
-rw-r--r--rolereact/manager.go8
-rw-r--r--rolereact/rolereact.go12
-rw-r--r--rolereact/views.go8
4 files changed, 18 insertions, 12 deletions
diff --git a/rolereact/events.go b/rolereact/events.go
index 537b6dd..ac5ad60 100644
--- a/rolereact/events.go
+++ b/rolereact/events.go
@@ -11,7 +11,7 @@ import (
)
type RoleReact struct {
- RoleID string
+ RoleID uint64
}
func HandleReactionAdd(ctx context.Context, dg bot.Session, e *event.MessageReactionAdd) {
diff --git a/rolereact/manager.go b/rolereact/manager.go
index 84081e5..91e1bcd 100644
--- a/rolereact/manager.go
+++ b/rolereact/manager.go
@@ -22,7 +22,7 @@ func MessageContent(message *config.RoleReactMessage) string {
content = fmt.Sprintf("%s\n%s", content, message.Note)
}
for _, role := range message.Roles {
- if role.Reaction != "" && role.RoleID != "" {
+ if role.Reaction != "" && role.RoleID != 0 {
content += fmt.Sprintf("\n> -# %s <@&%s>", FormatEmoji(role.Reaction), role.RoleID)
}
}
@@ -45,7 +45,7 @@ func ApplyMessageChange(ctx context.Context, dg bot.Session, i *interaction.Inte
return "Impossible de mettre à jour le message."
}
for _, role := range message.Roles {
- if role.Reaction != "" && role.RoleID != "" && err == nil {
+ if role.Reaction != "" && role.RoleID != 0 && err == nil {
err = channel.AddReaction(message.ChannelID, message.MessageID, role.Reaction).Do(ctx)
}
}
@@ -91,7 +91,7 @@ func ApplyMessageChange(ctx context.Context, dg bot.Session, i *interaction.Inte
return "Message de réaction mis à jour avec succès !"
}
-func WaitForEmoji(ctx context.Context, dg bot.Session, userID string, messageID string) (string, bool) {
+func WaitForEmoji(ctx context.Context, dg bot.Session, userID, messageID uint64) (string, bool) {
ctx, cancel := context.WithTimeout(ctx, 1*time.Minute)
defer cancel()
@@ -122,7 +122,7 @@ func GetMessageFromEditID(ctx context.Context, i *interaction.Interaction, editI
return m, true
}
-func GetGuildConfigPreloaded(ctx context.Context, guildID string) *config.Guild {
+func GetGuildConfigPreloaded(ctx context.Context, guildID uint64) *config.Guild {
cfg := config.Guild{GuildID: guildID}
// err := oldGokord.DB.Where("guild_id = ?", cfg.GuildID).Preload("XpRoles").Preload("RrMessages.Roles").FirstOrCreate(cfg).Error
err := common.GetDB(ctx).Where("guild_id = ?", cfg.GuildID).Preload("RrMessages.Roles").FirstOrCreate(&cfg).Error
diff --git a/rolereact/rolereact.go b/rolereact/rolereact.go
index dce4e81..44aad2a 100644
--- a/rolereact/rolereact.go
+++ b/rolereact/rolereact.go
@@ -3,6 +3,7 @@ package rolereact
import (
"context"
"slices"
+ "strconv"
"git.anhgelus.world/anhgelus/les-copaings-bot/config"
"git.anhgelus.world/anhgelus/les-copaings-bot/dynamicid"
@@ -54,9 +55,9 @@ func HandleCommand(ctx context.Context, dg bot.Session, i *interaction.Applicati
}
o := i.OptionMap()
c := o["salon"]
- var channelID string
+ var channelID uint64
if c != nil {
- channelID = c.Value.(string)
+ channelID = c.ChannelValue(ctx, dg.ChannelState()).ID
} else {
channelID = i.ChannelID
}
@@ -362,7 +363,12 @@ func HandleSetRole(ctx context.Context, dg bot.Session, i *interaction.MessageCo
},
}
} else {
- role.RoleID = i.Data.Values[0]
+ var err error
+ role.RoleID, err = strconv.ParseUint(i.Data.Values[0], 10, 64)
+ if err != nil {
+ // panic because must ensure before that the value is valid
+ panic(err)
+ }
responseData = MessageModifyRoleData(ctx, i.Interaction, params, "")
}
err := interaction.Respond(i.Interaction, &interaction.Response{
diff --git a/rolereact/views.go b/rolereact/views.go
index 47aa4f6..72a1ea0 100644
--- a/rolereact/views.go
+++ b/rolereact/views.go
@@ -47,8 +47,8 @@ func MessageModifyComponents(ctx context.Context, i *interaction.Interaction, pa
reaction = ":no_entry_sign:"
}
var roleMention string
- if role.RoleID != "" {
- roleMention = fmt.Sprintf("<@&%s>", role.RoleID)
+ if role.RoleID != 0 {
+ roleMention = fmt.Sprintf("<@&%d>", role.RoleID)
} else {
roleMention = "*Pas de rôle sélectionné*"
}
@@ -147,13 +147,13 @@ func MessageModifyRoleComponents(ctx context.Context, i *interaction.Interaction
}
reactionButton.CustomID = dynamicid.FormatCustomID(SetRoleReaction, *params)
defaultRoleValues := make([]component.SelectMenuDefaultValue, 0)
- if role.RoleID != "" {
+ if role.RoleID != 0 {
defaultRoleValues = append(defaultRoleValues, component.SelectMenuDefaultValue{
Type: types.SelectMenuDefaultValueRole,
ID: role.RoleID,
})
}
- disableBack = disableBack || (role.RoleID == "")
+ disableBack = disableBack || (role.RoleID == 0)
one := 1
components := []component.Message{
&component.TextDisplay{Content: "## Modifier un message de réaction"},