From 4891189daf5a8a5760671229e75bbb7e7c9a034e Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 19 Jul 2020 11:56:33 +0200 Subject: [PATCH] remove the variable "files" and use "mp4" instead Signed-off-by: loicbersier --- commands/fun/ytp.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/commands/fun/ytp.js b/commands/fun/ytp.js index 7ebd768..9408f22 100644 --- a/commands/fun/ytp.js +++ b/commands/fun/ytp.js @@ -186,18 +186,18 @@ class ytpCommand extends Command { // Read userVid folder and select random vid and only take .mp4 let mp4 = []; let asset = []; - let files = fs.readdirSync('./asset/ytp/userVid/'); // Count number of total vid - files.forEach(file => { + fs.readdirSync('./asset/ytp/userVid/').forEach(file => { if (file.endsWith('mp4')) { mp4.push(file); } }); + // Select random vid depending on the amount of MAX_CLIPS for (let i = 0; i < MAX_CLIPS; i++) { - let random = Math.floor(Math.random() * files.length); - let vid = `./asset/ytp/userVid/${files[random]}`; - if (files[random].endsWith('mp4')) { + let random = Math.floor(Math.random() * mp4.length); + let vid = `./asset/ytp/userVid/${mp4[random]}`; + if (mp4[random].endsWith('mp4')) { if (!asset.includes(vid)) { asset.push(vid); }