From 218c0199896881ebd71cc29a1f72ccbf3471ddbf Mon Sep 17 00:00:00 2001 From: Siwoo Jeon Date: Fri, 23 May 2025 23:31:34 +0900 Subject: [PATCH] fix: edit type deferReply argument --- commands/dataLength.go | 4 +++- commands/deleteLearnedData.go | 4 +++- commands/learn.go | 4 +++- commands/learnedDataList.go | 4 +++- utils/interactions.go | 19 ++++++++----------- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/commands/dataLength.go b/commands/dataLength.go index 6f74d75..f0d17d9 100644 --- a/commands/dataLength.go +++ b/commands/dataLength.go @@ -47,7 +47,9 @@ var DataLengthCommand *Command = &Command{ dataLengthRun(ctx.Msg, ctx.Msg.Author.Username, ctx.Msg.Author.ID) }, ChatInputRun: func(ctx *ChatInputContext) { - ctx.Inter.DeferReply(true) + ctx.Inter.DeferReply(&discordgo.InteractionResponseData{ + Flags: discordgo.MessageFlagsEphemeral, + }) dataLengthRun(ctx.Inter, ctx.Inter.Member.User.Username, ctx.Inter.Member.User.ID) }, } diff --git a/commands/deleteLearnedData.go b/commands/deleteLearnedData.go index fc0f85e..fd4cd87 100644 --- a/commands/deleteLearnedData.go +++ b/commands/deleteLearnedData.go @@ -55,7 +55,9 @@ var DeleteLearnedDataCommand *Command = &Command{ deleteLearnedDataRun(ctx.Msg, strings.Join(*ctx.Args, " "), ctx.Msg.Author.ID) }, ChatInputRun: func(ctx *ChatInputContext) { - ctx.Inter.DeferReply(true) + ctx.Inter.DeferReply(&discordgo.InteractionResponseData{ + Flags: discordgo.MessageFlagsEphemeral, + }) var command string diff --git a/commands/learn.go b/commands/learn.go index a285f09..4d9d798 100644 --- a/commands/learn.go +++ b/commands/learn.go @@ -89,7 +89,9 @@ var LearnCommand *Command = &Command{ learnRun(ctx.Msg, ctx.Msg.Author.ID, strings.ReplaceAll((*ctx.Args)[0], "_", " "), strings.ReplaceAll((*ctx.Args)[1], "_", " ")) }, ChatInputRun: func(ctx *ChatInputContext) { - ctx.Inter.DeferReply(true) + ctx.Inter.DeferReply(&discordgo.InteractionResponseData{ + Flags: discordgo.MessageFlagsEphemeral, + }) var command, result string diff --git a/commands/learnedDataList.go b/commands/learnedDataList.go index 51103bb..298e4c7 100644 --- a/commands/learnedDataList.go +++ b/commands/learnedDataList.go @@ -124,7 +124,9 @@ var LearnedDataListCommand *Command = &Command{ learnedDataListRun(ctx.Msg.Session, ctx.Msg, ctx.Msg.Author.GlobalName, ctx.Msg.Author.AvatarURL("512"), filter, length) }, ChatInputRun: func(ctx *ChatInputContext) { - ctx.Inter.DeferReply(true) + ctx.Inter.DeferReply(&discordgo.InteractionResponseData{ + Flags: discordgo.MessageFlagsEphemeral, + }) var length int diff --git a/utils/interactions.go b/utils/interactions.go index e1e1ed4..b59b0ed 100644 --- a/utils/interactions.go +++ b/utils/interactions.go @@ -56,20 +56,17 @@ func GetInteractionOptions(i *discordgo.InteractionCreate) map[string]*discordgo } // DeferReply to this interaction. -func (i *InteractionCreate) DeferReply(ephemeral bool) { - var flags discordgo.MessageFlags - if ephemeral { - flags = discordgo.MessageFlagsEphemeral +func (i *InteractionCreate) DeferReply(data *discordgo.InteractionResponseData) error { + err := i.Session.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ + Type: discordgo.InteractionResponseDeferredChannelMessageWithSource, + Data: data, + }) + if err != nil { + return err } - i.Session.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ - Type: discordgo.InteractionResponseDeferredChannelMessageWithSource, - Data: &discordgo.InteractionResponseData{ - Flags: flags, - }, - }) - i.Deferred = true + return err } // DeferUpdate to this interaction.