5
5
"fmt"
6
6
"github.com/bwmarrin/discordgo"
7
7
"github.com/zmb3/spotify"
8
- "io/ioutil"
9
8
"os"
10
9
"os/exec"
11
10
"runtime"
@@ -16,28 +15,6 @@ import (
16
15
func downloadAndPlay (s * discordgo.Session , guildID , channelID , link , user , txtChannel string ) {
17
16
go sendAndDeleteEmbed (s , NewEmbed ().SetTitle (s .State .User .Username ).AddField ("Enqueued" , link ).SetColor (0x7289DA ).MessageEmbed , txtChannel )
18
17
19
- files , _ := ioutil .ReadDir ("./audio_cache" )
20
-
21
- //We check if the song is already downloaded
22
- for _ , f := range files {
23
- //This one is how we handle id
24
- realId := strings .TrimSuffix (f .Name (), ".dca" )
25
- //This one is for caching purposes
26
- id := strings .Split (realId , "-" )[0 ]
27
- //If for reasons, the id is empty we just skip
28
- if id == "" {
29
- break
30
- }
31
-
32
- if strings .Contains (link , id ) && f .Size () != 0 {
33
- el := Queue {"" , "" , realId , link , user , nil , 0 , "" }
34
- queue [guildID ] = append (queue [guildID ], el )
35
- addInfo (id , guildID )
36
- playSound (s , guildID , channelID , f .Name (), txtChannel , findQueuePointer (guildID , realId ))
37
- return
38
- }
39
- }
40
-
41
18
//Gets info about songs
42
19
out , _ := exec .Command ("youtube-dl" , "--ignore-errors" , "-q" , "--no-warnings" , "-j" , link ).Output ()
43
20
@@ -75,7 +52,6 @@ func downloadAndPlay(s *discordgo.Session, guildID, channelID, link, user, txtCh
75
52
queue [guildID ] = append (queue [guildID ], el )
76
53
go playSound (s , guildID , channelID , fileName + ".dca" , txtChannel , findQueuePointer (guildID , fileName ))
77
54
78
- break
79
55
}
80
56
81
57
}
0 commit comments