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

33
main.go
View File

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