delay sub response to give more time if bot is running with a bad connection

This commit is contained in:
Arkitu 2026-01-20 12:37:49 +01:00
parent 488d08179b
commit 18d2ebcd23

17
main.go
View File

@ -96,17 +96,14 @@ func init() {
func send_error(s *dg.Session, i *dg.Interaction, reason string) { func send_error(s *dg.Session, i *dg.Interaction, reason string) {
log.Printf("Sending error (\"%s\")", reason) log.Printf("Sending error (\"%s\")", reason)
s.InteractionRespond(i, &dg.InteractionResponse{ s.InteractionResponseEdit(i, &dg.WebhookEdit{
Type: dg.InteractionResponseChannelMessageWithSource, Embeds: &[]*dg.MessageEmbed{
Data: &dg.InteractionResponseData{
Embeds: []*dg.MessageEmbed{
{ {
Title: "⚠️ Error", Title: "⚠️ Error",
Description: reason, Description: reason,
Color: 0xFF0000, Color: 0xFF0000,
}, },
}, },
},
}) })
} }
@ -121,6 +118,9 @@ var handlers = map[string]func(*dg.Session, *dg.InteractionCreate){
}) })
}, },
"sub": func(s *dg.Session, i *dg.InteractionCreate) { "sub": func(s *dg.Session, i *dg.InteractionCreate) {
s.InteractionRespond(i.Interaction, &dg.InteractionResponse{
Type: dg.InteractionResponseDeferredChannelMessageWithSource,
})
red := 0 red := 0
green := 0 green := 0
guesses := []string{} guesses := []string{}
@ -182,17 +182,14 @@ var handlers = map[string]func(*dg.Session, *dg.InteractionCreate){
} else { } else {
title = "Guess by " + cmdAuthor title = "Guess by " + cmdAuthor
} }
s.InteractionRespond(i.Interaction, &dg.InteractionResponse{ s.InteractionResponseEdit(i.Interaction, &dg.WebhookEdit{
Type: dg.InteractionResponseChannelMessageWithSource, Embeds: &[]*dg.MessageEmbed{
Data: &dg.InteractionResponseData{
Embeds: []*dg.MessageEmbed{
{ {
Title: title, Title: title,
Description: strings.Join(guesses, "\n") + "\n\n**" + strconv.Itoa(green) + " 🟩**\n**" + strconv.Itoa(red) + " 🟥**", Description: strings.Join(guesses, "\n") + "\n\n**" + strconv.Itoa(green) + " 🟩**\n**" + strconv.Itoa(red) + " 🟥**",
Color: stg.Color, Color: stg.Color,
}, },
}, },
},
}) })
if green == len(stg.students) { if green == len(stg.students) {
var winTitle string var winTitle string