Skip to content

Commit

Permalink
refactor: minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTipo01 committed May 29, 2023
1 parent f79a28e commit af568b2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions download.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ func downloadAndPlay(s *discordgo.Session, guildID, link, user string, i *discor
go deleteInteraction(s, i, c)
}

var elements = make([]Queue.Element, len(splittedOut))
elements := make([]Queue.Element, 0, len(splittedOut))

// We parse every track as individual json, because yt-dlp
for j, singleJSON := range splittedOut {
for _, singleJSON := range splittedOut {
_ = json.Unmarshal([]byte(singleJSON), &ytdl)

el = Queue.Element{
Expand Down Expand Up @@ -108,7 +108,7 @@ func downloadAndPlay(s *discordgo.Session, guildID, link, user string, i *discor
}

// We add the song to the db, for faster parsing
addToDb(el, exist)
go addToDb(el, exist)

// Checks if video is already downloaded
info, err := os.Stat(cachePath + el.ID + audioExtension)
Expand All @@ -132,7 +132,7 @@ func downloadAndPlay(s *discordgo.Session, guildID, link, user string, i *discor
el.Closer = f
}

elements[j] = el
elements = append(elements, el)
}

server[guildID].AddSong(elements...)
Expand Down

0 comments on commit af568b2

Please sign in to comment.