fix: edit type deferReply argument

This commit is contained in:
Siwoo Jeon 2025-05-23 23:31:34 +09:00
parent 0fdfd1cbd7
commit 218c019989
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
5 changed files with 20 additions and 15 deletions

View file

@ -47,7 +47,9 @@ var DataLengthCommand *Command = &Command{
dataLengthRun(ctx.Msg, ctx.Msg.Author.Username, ctx.Msg.Author.ID) dataLengthRun(ctx.Msg, ctx.Msg.Author.Username, ctx.Msg.Author.ID)
}, },
ChatInputRun: func(ctx *ChatInputContext) { 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) dataLengthRun(ctx.Inter, ctx.Inter.Member.User.Username, ctx.Inter.Member.User.ID)
}, },
} }

View file

@ -55,7 +55,9 @@ var DeleteLearnedDataCommand *Command = &Command{
deleteLearnedDataRun(ctx.Msg, strings.Join(*ctx.Args, " "), ctx.Msg.Author.ID) deleteLearnedDataRun(ctx.Msg, strings.Join(*ctx.Args, " "), ctx.Msg.Author.ID)
}, },
ChatInputRun: func(ctx *ChatInputContext) { ChatInputRun: func(ctx *ChatInputContext) {
ctx.Inter.DeferReply(true) ctx.Inter.DeferReply(&discordgo.InteractionResponseData{
Flags: discordgo.MessageFlagsEphemeral,
})
var command string var command string

View file

@ -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], "_", " ")) learnRun(ctx.Msg, ctx.Msg.Author.ID, strings.ReplaceAll((*ctx.Args)[0], "_", " "), strings.ReplaceAll((*ctx.Args)[1], "_", " "))
}, },
ChatInputRun: func(ctx *ChatInputContext) { ChatInputRun: func(ctx *ChatInputContext) {
ctx.Inter.DeferReply(true) ctx.Inter.DeferReply(&discordgo.InteractionResponseData{
Flags: discordgo.MessageFlagsEphemeral,
})
var command, result string var command, result string

View file

@ -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) learnedDataListRun(ctx.Msg.Session, ctx.Msg, ctx.Msg.Author.GlobalName, ctx.Msg.Author.AvatarURL("512"), filter, length)
}, },
ChatInputRun: func(ctx *ChatInputContext) { ChatInputRun: func(ctx *ChatInputContext) {
ctx.Inter.DeferReply(true) ctx.Inter.DeferReply(&discordgo.InteractionResponseData{
Flags: discordgo.MessageFlagsEphemeral,
})
var length int var length int

View file

@ -56,20 +56,17 @@ func GetInteractionOptions(i *discordgo.InteractionCreate) map[string]*discordgo
} }
// DeferReply to this interaction. // DeferReply to this interaction.
func (i *InteractionCreate) DeferReply(ephemeral bool) { func (i *InteractionCreate) DeferReply(data *discordgo.InteractionResponseData) error {
var flags discordgo.MessageFlags err := i.Session.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
if ephemeral { Type: discordgo.InteractionResponseDeferredChannelMessageWithSource,
flags = discordgo.MessageFlagsEphemeral 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 i.Deferred = true
return err
} }
// DeferUpdate to this interaction. // DeferUpdate to this interaction.