From 0fdfd1cbd75fbd16f0b8dfc249f43ebb6f0e3e09 Mon Sep 17 00:00:00 2001 From: Siwoo Jeon Date: Fri, 23 May 2025 23:28:37 +0900 Subject: [PATCH] fix: edit type editReply argument --- components/deleteLearnedData.go | 2 +- utils/interactions.go | 16 ++++++++++++++-- utils/messageBuilder.go | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/components/deleteLearnedData.go b/components/deleteLearnedData.go index 2902e25..55645df 100644 --- a/components/deleteLearnedData.go +++ b/components/deleteLearnedData.go @@ -70,7 +70,7 @@ var DeleteLearnedDataComponent *commands.Component = &commands.Component{ databases.Database.Learns.DeleteOne(context.TODO(), bson.D{{Key: "_id", Value: id}}) - i.EditReply(&discordgo.WebhookEdit{ + i.EditReply(&utils.InteractionEdit{ Embeds: &[]*discordgo.MessageEmbed{ { Title: "✅ 삭제 완료", diff --git a/utils/interactions.go b/utils/interactions.go index 382f57a..e1e1ed4 100644 --- a/utils/interactions.go +++ b/utils/interactions.go @@ -16,6 +16,15 @@ type ModalData struct { Components []discordgo.MessageComponent `json:"components"` } +type InteractionEdit struct { + Content *string `json:"content,omitempty"` + Components *[]discordgo.MessageComponent `json:"components,omitempty"` + Embeds *[]*discordgo.MessageEmbed `json:"embeds,omitempty"` + Flags *discordgo.MessageFlags `json:"flags,omitempty"` + Attachments *[]*discordgo.MessageAttachment `json:"attachments,omitempty"` + AllowedMentions *discordgo.MessageAllowedMentions `json:"allowed_mentions,omitempty"` +} + // InteractionCreate custom data of discordgo.InteractionCreate type InteractionCreate struct { *discordgo.InteractionCreate @@ -73,10 +82,13 @@ func (i *InteractionCreate) DeferUpdate() { } // EditReply to this interaction. -func (i *InteractionCreate) EditReply(data *discordgo.WebhookEdit) { - i.Session.InteractionResponseEdit(i.Interaction, data) +func (i *InteractionCreate) EditReply(data *InteractionEdit) error { + endpoint := discordgo.EndpointWebhookMessage(i.AppID, i.Token, "@original") + + _, err := i.Session.RequestWithBucketID("PATCH", endpoint, *data, discordgo.EndpointWebhookToken("", "")) i.Replied = true + return err } // Update to this interaction. diff --git a/utils/messageBuilder.go b/utils/messageBuilder.go index 3c211a8..4e1d0ea 100644 --- a/utils/messageBuilder.go +++ b/utils/messageBuilder.go @@ -76,7 +76,7 @@ func (s *MessageSender) Send() { } if m.Replied || m.Deferred { - m.EditReply(&discordgo.WebhookEdit{ + err := m.EditReply(&InteractionEdit{ Content: &s.Content, Embeds: &s.Embeds, Components: &s.Components,