1
0
mirror of https://github.com/mgerb/go-discord-bot synced 2026-01-11 09:32:50 +00:00

audio clips - client done

This commit is contained in:
2017-10-04 20:56:55 -05:00
parent b487548ac6
commit 74976de6cf
18 changed files with 175 additions and 92 deletions

View File

@@ -2,6 +2,7 @@ package handlers
import (
"io/ioutil"
"log"
"strings"
"net/http"
@@ -58,3 +59,31 @@ func PopulateSoundList() error {
return nil
}
// ClipList -
func ClipList(w http.ResponseWriter, r *http.Request) {
clipList := []sound{}
files, err := ioutil.ReadDir(config.Config.ClipsPath)
if err != nil {
log.Println(err)
response.ERR(w, 500, response.DefaultInternalError)
return
}
for _, f := range files {
fileName := strings.Split(f.Name(), ".")[0]
extension := strings.Split(f.Name(), ".")[1]
listItem := sound{
Name: fileName,
Extension: extension,
}
clipList = append(clipList, listItem)
}
response.JSON(w, clipList)
}