fix: Add disappeared cancel button interaction
This commit is contained in:
parent
2ca7ce9465
commit
5fd5504744
3 changed files with 22 additions and 2 deletions
|
@ -24,6 +24,18 @@ var DeleteLearnedDataComponent *commands.Component = &commands.Component{
|
|||
}
|
||||
|
||||
userId = customId[len(utils.DeleteLearnedDataCancel):]
|
||||
if i.Member.User.ID == userId {
|
||||
i.Update(&discordgo.InteractionResponseData{
|
||||
Embeds: []*discordgo.MessageEmbed{
|
||||
{
|
||||
Title: "❌ 취소",
|
||||
Description: "지식 삭제 작업ㅇ을 취소했어요.",
|
||||
Color: utils.EmbedFail,
|
||||
},
|
||||
},
|
||||
})
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
if !strings.HasPrefix(customId, utils.DeleteLearnedDataUserId) {
|
||||
return false
|
||||
|
@ -39,7 +51,7 @@ var DeleteLearnedDataComponent *commands.Component = &commands.Component{
|
|||
{
|
||||
Title: "❌ 오류",
|
||||
Description: "당신은 해당 권한이 없ㅇ어요.",
|
||||
Color: int(utils.EmbedFail),
|
||||
Color: utils.EmbedFail,
|
||||
},
|
||||
},
|
||||
Components: []discordgo.MessageComponent{},
|
||||
|
|
2
main.go
2
main.go
|
@ -39,7 +39,7 @@ func main() {
|
|||
dg.Open()
|
||||
|
||||
for _, cmd := range commands.Discommand.Commands {
|
||||
dg.ApplicationCommandCreate(dg.State.User.ID, "", cmd.ApplicationCommand)
|
||||
go dg.ApplicationCommandCreate(dg.State.User.ID, "", cmd.ApplicationCommand)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
|
|
|
@ -54,3 +54,11 @@ func (i *InteractionCreate) DeferUpdate() {
|
|||
func (i *InteractionCreate) EditReply(data *discordgo.WebhookEdit) {
|
||||
i.Session.InteractionResponseEdit(i.Interaction, data)
|
||||
}
|
||||
|
||||
// Update to this interaction.
|
||||
func (i *InteractionCreate) Update(data *discordgo.InteractionResponseData) {
|
||||
i.Session.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseUpdateMessage,
|
||||
Data: data,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue