fix: resolve timeout issues and implement format retrieval retries
All checks were successful
Build only (for PRs) / build-only (pull_request) Successful in 3m36s
All checks were successful
Build only (for PRs) / build-only (pull_request) Successful in 3m36s
This commit is contained in:
25
app/main.go
25
app/main.go
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"sort"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
@@ -365,8 +366,20 @@ func main() {
|
||||
h(s, i)
|
||||
}
|
||||
case discordgo.InteractionMessageComponent:
|
||||
if h, ok := componentHandlers[i.MessageComponentData().CustomID]; ok {
|
||||
customID := i.MessageComponentData().CustomID
|
||||
if h, ok := componentHandlers[customID]; ok {
|
||||
h(s, i)
|
||||
} else if strings.HasPrefix(customID, "retry:") {
|
||||
url := strings.TrimPrefix(customID, "retry:")
|
||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseUpdateMessage,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Content: fmt.Sprintf("%s Fetching available formats...", loading_emoji),
|
||||
Components: []discordgo.MessageComponent{},
|
||||
Flags: discordgo.MessageFlagsEphemeral,
|
||||
},
|
||||
})
|
||||
go fetchAndShowFormats(s, i, url)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -444,6 +457,16 @@ func fetchAndShowFormats(s *discordgo.Session, i *discordgo.InteractionCreate, u
|
||||
if err != nil {
|
||||
_, err = s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
|
||||
Content: ptr("❌ Error fetching formats: " + err.Error()),
|
||||
Components: &[]discordgo.MessageComponent{
|
||||
&discordgo.ActionsRow{
|
||||
Components: []discordgo.MessageComponent{
|
||||
discordgo.Button{
|
||||
Label: "Retry",
|
||||
CustomID: fmt.Sprintf("retry:%s", url),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Error updating interaction: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user