From ce09c7ce094fa74195dceaed3943d4cd7c6fd243 Mon Sep 17 00:00:00 2001
From: loicbersier <loic.bersier1@gmail.com>
Date: Mon, 29 Jul 2019 23:35:31 +0200
Subject: [PATCH] check for nolight.png

---
 commands/images/nolight.js | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/commands/images/nolight.js b/commands/images/nolight.js
index 2d9b82c4..290fa259 100644
--- a/commands/images/nolight.js
+++ b/commands/images/nolight.js
@@ -49,9 +49,11 @@ class nolightCommand extends Command {
 		});
 
 		async function apng() {
-			fs.unlink('./img/nolight.png', (err) => {
-				if (err) throw err;
-			});
+			if (fs.readFileSync('./img/nolight.png')) {
+				fs.unlink('./img/nolight.png', (err) => {
+					if (err) throw err;
+				});
+			}
 			const { stdout, stderr } = await exec('apngasm -o img/nolight.png img/frame00*.png -s')
 				.then(() => message.channel.send({files: ['./img/nolight.png']}));
 			console.log(`stdout: ${stdout}`);