From e754e4e32c5f8dd4c9aade77dedd3e01b4623349 Mon Sep 17 00:00:00 2001
From: supositware <loic.bersier1@gmail.com>
Date: Wed, 26 Aug 2020 19:21:59 +0200
Subject: [PATCH] Fix when downloading without proxy

Signed-off-by: supositware <loic.bersier1@gmail.com>
---
 commands/fun/ytp.js | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/commands/fun/ytp.js b/commands/fun/ytp.js
index c7c1aceb..83fefddc 100644
--- a/commands/fun/ytp.js
+++ b/commands/fun/ytp.js
@@ -178,7 +178,14 @@ class ytpCommand extends Command {
 				url = await attachment(message);
 
 			if (url) {
-				return downloader(url, ['--format=mp4', '--proxy', proxy[args.proxy].ip], `./asset/ytp/userVid/${message.id}.mp4`)
+				let options = ['--format=mp4'];
+
+				if (args.proxy) {
+					options.push('--proxy');
+					options.push(proxy[args.proxy].ip);
+				}
+
+				return downloader(url, options, `./asset/ytp/userVid/${message.id}.mp4`)
 					.on('error', (err) => {
 						loadingmsg.delete();
 						return message.channel.send(err, { code: true });
@@ -201,7 +208,7 @@ class ytpCommand extends Command {
 								return message.reply('Video too big.. Not adding.');
 							}
 
-							const body = {hash: hash, link: url, messageID: message.id};
+							const body = {hash: hash, link: args.link, messageID: message.id};
 							await ytpHash.create(body);
 						}