optimize codebase
All checks were successful
Build only (for PRs) / build-only (pull_request) Successful in 4m43s
All checks were successful
Build only (for PRs) / build-only (pull_request) Successful in 4m43s
main.go: - Eliminated ~160 lines of duplicate code: Extracted 3 new helper functions at the bottom of the file: buildVideoMenuOptions([]VideoOption) — builds the Discord select menu options for video formats buildAudioMenuOptions([]AudioOption) — same for audio fetchAndShowFormats(s, i, url) — fetches formats, sorts them, builds menus, stores state, and edits the interaction; previously duplicated identically in both the download and download video command handlers - Fixed time.Sleep ordering bug: The startAsyncDownload goroutine was launched before InteractionRespond with a 100ms sleep to compensate. Now the download is launched after InteractionRespond returns — no sleep needed. Removed "time" import. - Used helpers in video_select handler: The two inline menu-building loops in that handler now call buildAudioMenuOptions / buildVideoMenuOptions misc.go: - Moved regexp.MustCompile(...) to a package-level var urlPattern — previously it recompiled the regex on every call to extractURLFromString - Simplified the function body to a single return line
This commit is contained in:
@@ -2,13 +2,9 @@ module git.dubyatp.xyz/williamp/yt-dlp-bot
|
||||
|
||||
go 1.25.2
|
||||
|
||||
//replace github.com/lrstanley/go-ytdlp => /home/williamp/go-ytdlp
|
||||
|
||||
replace github.com/lrstanley/go-ytdlp => github.com/dubyatp/go-ytdlp v0.0.0-20260308044557-db32b29c1590
|
||||
|
||||
require (
|
||||
github.com/bwmarrin/discordgo v0.29.0
|
||||
github.com/lrstanley/go-ytdlp v1.3.2
|
||||
github.com/lrstanley/go-ytdlp v1.3.3
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
Reference in New Issue
Block a user