From d065f1152aece3cc1a6ecefd9335a62914b7d611 Mon Sep 17 00:00:00 2001 From: mantre Date: Thu, 9 Jan 2025 16:01:35 +0800 Subject: [PATCH] fix: use choice value as string --- internal/engine/command/command.go | 2 +- internal/engine/command/crowdfund/crowdfund.go | 3 ++- internal/platforms/discord/discord.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/engine/command/command.go b/internal/engine/command/command.go index 398df48..3ab9b58 100644 --- a/internal/engine/command/command.go +++ b/internal/engine/command/command.go @@ -79,7 +79,7 @@ func (ib *InputBox) UnmarshalYAML(unmarshal func(any) error) error { type Choice struct { Name string `yaml:"name"` - Value int `yaml:"value"` + Value string `yaml:"value"` } type Args struct { diff --git a/internal/engine/command/crowdfund/crowdfund.go b/internal/engine/command/crowdfund/crowdfund.go index 1fc4377..67bc1b1 100644 --- a/internal/engine/command/crowdfund/crowdfund.go +++ b/internal/engine/command/crowdfund/crowdfund.go @@ -2,6 +2,7 @@ package crowdfund import ( "context" + "fmt" "github.com/pagu-project/pagu/internal/engine/command" "github.com/pagu-project/pagu/internal/entity" @@ -69,7 +70,7 @@ func (c *CrowdfundCmd) GetCommand() *command.Command { for index, pkg := range activeCampaign.Packages { choice := command.Choice{ Name: pkg.Name, - Value: index + 1, + Value: fmt.Sprintf("%d", index+1), } purchaseChoices = append(purchaseChoices, choice) diff --git a/internal/platforms/discord/discord.go b/internal/platforms/discord/discord.go index a246bd1..ae387d6 100644 --- a/internal/platforms/discord/discord.go +++ b/internal/platforms/discord/discord.go @@ -374,7 +374,7 @@ func discordOptionType(inputBox command.InputBox) discordgo.ApplicationCommandOp case command.InputBoxToggle: return discordgo.ApplicationCommandOptionBoolean case command.InputBoxChoice: - return discordgo.ApplicationCommandOptionInteger + return discordgo.ApplicationCommandOptionString default: return discordgo.ApplicationCommandOptionString }