feat(commands): send command data alongside interaction data

This commit is contained in:
Guz
2024-11-19 10:55:24 -03:00
parent e5f7c26a6c
commit 507a9127ad
3 changed files with 19 additions and 13 deletions

View File

@@ -22,9 +22,11 @@ func (c *mockCommand) Info() *discordgo.ApplicationCommand {
}
}
func (c *mockCommand) Handle(s *discordgo.Session, i *discordgo.InteractionCreate) error {
data := i.ApplicationCommandData()
func (c *mockCommand) Handle(
s *discordgo.Session,
ic *discordgo.InteractionCreate,
data discordgo.ApplicationCommandInteractionData,
) error {
if len(data.Options) == 0 {
return errors.New("Option \"message\" is not defined")
}
@@ -34,7 +36,7 @@ func (c *mockCommand) Handle(s *discordgo.Session, i *discordgo.InteractionCreat
return errors.New("Failed to convert \"message\" into string")
}
return s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
return s.InteractionRespond(ic.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: fmt.Sprintf("Hello user! Your text is %q", text),