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

View File

@@ -13,7 +13,6 @@ import (
) )
func main() { func main() {
out_dir := os.Getenv("OUT_PATH") out_dir := os.Getenv("OUT_PATH")
temp_dir := os.Getenv("TEMP_PATH") temp_dir := os.Getenv("TEMP_PATH")
bot_token := os.Getenv("DISCORD_TOKEN") bot_token := os.Getenv("DISCORD_TOKEN")
@@ -273,8 +272,7 @@ func main() {
response := "" response := ""
if state.URL != "" { if state.URL != "" {
// Respond immediately to prevent timeout // 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!", response = fmt.Sprintf("%s **Starting download**", loading_emoji)
state.URL, state.VideoFormatID, state.AudioFormatID)
// Start async download after responding // Start async download after responding
go func() { go func() {
@@ -327,7 +325,7 @@ func main() {
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource, Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{ Data: &discordgo.InteractionResponseData{
Content: "🔍 Fetching available formats...", Content: fmt.Sprintf("%s Fetching available formats...", loading_emoji),
Flags: discordgo.MessageFlagsEphemeral, Flags: discordgo.MessageFlagsEphemeral,
}, },
}) })

View File

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