From 5c81b5ddab37f7ed6160745740f2aeb0ea5f9e4e Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 23 Jan 2019 10:12:12 +0100 Subject: [PATCH] Don't make bot crash --- commands/utility/download.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/commands/utility/download.js b/commands/utility/download.js index f3c859bc..b06a8e29 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -37,12 +37,17 @@ class DownloadCommand extends Command { message.channel.send('An error has occured, I can\'t download from the link you provided.'); }); video.on('info', function(info) { - let duration = info.duration.replace(/:/g, ''); - if (duration > 500) { - video.pause(); - video.unpipe(); - return message.channel.send('Can\'t download video longer than 5 minutes'); + let duration = info.duration; + if (duration) { + duration = duration.replace(/:/g, ''); + + if (duration > 500) { + video.pause(); + video.unpipe(); + return message.channel.send('Can\'t download video longer than 5 minutes'); + } } + console.log('Download started'); console.log('filename: ' + info._filename); console.log('size: ' + info.size);