forked from notnull/apradiobot
add error handling for reset, fix .flat() not supported
This commit is contained in:
parent
8f5510993c
commit
17b3cc0c42
@ -45,9 +45,9 @@ const clearAllPlaylists = event => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const addAllPlaylists = async event => {
|
const addAllPlaylists = async event => {
|
||||||
const files = fs.readdirSync('./playlists')
|
|
||||||
const tracks = readPlaylists(files)
|
|
||||||
try {
|
try {
|
||||||
|
const files = fs.readdirSync('./playlists')
|
||||||
|
const tracks = readPlaylists(files)
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
tracks.map(t => insertTrackAsync(t.split(' # ')[0]))
|
tracks.map(t => insertTrackAsync(t.split(' # ')[0]))
|
||||||
).then(() => {
|
).then(() => {
|
||||||
@ -61,13 +61,8 @@ const addAllPlaylists = async event => {
|
|||||||
|
|
||||||
const readPlaylists = files =>
|
const readPlaylists = files =>
|
||||||
files
|
files
|
||||||
.map(f =>
|
.map(f => fs.readFileSync('./playlists/' + f, 'utf-8').split('\n'))
|
||||||
fs
|
.reduce((a, b) => a.concat(b))
|
||||||
.readFileSync('./playlists/' + f)
|
|
||||||
.toString()
|
|
||||||
.split('\n')
|
|
||||||
)
|
|
||||||
.flat()
|
|
||||||
|
|
||||||
const handleError = (err, event) => {
|
const handleError = (err, event) => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user