minor UX tweaks

This commit is contained in:
2026-03-05 21:42:56 -05:00
parent 890a0dd5c9
commit 13bd3b82db
3 changed files with 15 additions and 12 deletions

View File

@@ -20,7 +20,7 @@ func startAsyncDownload(s *discordgo.Session, i *discordgo.InteractionCreate, re
// Handle panic from DownloadVideo
resultChan <- DownloadResult{
Success: false,
Message: fmt.Sprintf("Download failed: %v", r),
Message: fmt.Sprintf("❌ **Download Failed**: %v", r),
URL: url,
Format: fmt.Sprintf("video: %s, audio: %s", videoFormatID, audioFormatID),
Error: fmt.Errorf("%v", r),
@@ -39,7 +39,7 @@ func startAsyncDownload(s *discordgo.Session, i *discordgo.InteractionCreate, re
// If we reach here, download was successful
resultChan <- DownloadResult{
Success: true,
Message: "Video Downloaded Successfully!",
Message: "✅ **Successfully Downloaded**",
URL: url,
Format: fmt.Sprintf("video: %s, audio: %s", videoFormatID, audioFormatID),
Error: nil,
@@ -49,7 +49,7 @@ func startAsyncDownload(s *discordgo.Session, i *discordgo.InteractionCreate, re
// Handle progress and results asynchronously
go func() {
_, err := s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: ptr("<a:loading:1479131733910618153> downloading: starting..."),
Content: ptr(fmt.Sprintf("%s **Starting Download**", loading_emoji)),
})
if err != nil {
log.Printf("Error updating interaction: %v", err)
@@ -65,7 +65,7 @@ func startAsyncDownload(s *discordgo.Session, i *discordgo.InteractionCreate, re
var content string
if prog.Phase == "post-processing" {
content = "<a:loading:1479131733910618153> post-processing"
content = fmt.Sprintf("%s **Post Processing**", loading_emoji)
} else {
var progressStr string
if prog.DownloadedBytes > 0 {
@@ -73,7 +73,7 @@ func startAsyncDownload(s *discordgo.Session, i *discordgo.InteractionCreate, re
} else {
progressStr = "starting..."
}
content = fmt.Sprintf("<a:loading:1479131733910618153> Downloading Video: %s", progressStr)
content = fmt.Sprintf("%s **Downloading Video**: %s", loading_emoji, progressStr)
}
_, err := s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
@@ -86,7 +86,7 @@ func startAsyncDownload(s *discordgo.Session, i *discordgo.InteractionCreate, re
case result := <-resultChan:
if result.Success {
_, err = s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: ptr("✅ Success"),
Content: ptr("✅ **Successfully Downloaded**"),
})
_, err = s.FollowupMessageCreate(i.Interaction, false, &discordgo.WebhookParams{
Content: fmt.Sprintf("## Video Downloaded \n**URL**: %s \n**Quality**: %s + %s \n**Requested By**: <@%s> \n", result.URL, videoFormatName, audioFormatName, requester),
@@ -96,7 +96,7 @@ func startAsyncDownload(s *discordgo.Session, i *discordgo.InteractionCreate, re
}
} else {
_, err = s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: ptr("❌ Download failed: " + result.Message),
Content: ptr("❌ **Download Failed**: " + result.Message),
})
if err != nil {
log.Printf("Error updating interaction: %v", err)

View File

@@ -13,7 +13,6 @@ import (
)
func main() {
out_dir := os.Getenv("OUT_PATH")
temp_dir := os.Getenv("TEMP_PATH")
bot_token := os.Getenv("DISCORD_TOKEN")
@@ -273,8 +272,7 @@ func main() {
response := ""
if state.URL != "" {
// Respond immediately to prevent timeout
response = fmt.Sprintf("🚀 Starting download...\nURL: %s\nVideo: %s\nAudio: %s\n\nYou'll receive an update when the download completes!",
state.URL, state.VideoFormatID, state.AudioFormatID)
response = fmt.Sprintf("%s **Starting download**", loading_emoji)
// Start async download after responding
go func() {
@@ -327,7 +325,7 @@ func main() {
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "🔍 Fetching available formats...",
Content: fmt.Sprintf("%s Fetching available formats...", loading_emoji),
Flags: discordgo.MessageFlagsEphemeral,
},
})

View File

@@ -1,6 +1,11 @@
package main
import "fmt"
import (
"fmt"
"os"
)
var loading_emoji = os.Getenv("LOADING_EMOJI")
// Helper function to create string pointer
func ptr(s string) *string {