From 70b4b6402e0f9a443c8d640175eab12aeae94419 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 18 Sep 2020 16:40:06 +0200 Subject: [PATCH] if there is an error making a ytp try again Signed-off-by: loicbersier --- commands/fun/ytp.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/commands/fun/ytp.js b/commands/fun/ytp.js index 5a4c215c..047ea453 100644 --- a/commands/fun/ytp.js +++ b/commands/fun/ytp.js @@ -321,11 +321,20 @@ class ytpCommand extends Command { .catch(err => { console.error(err); loadingmsg.delete(); - return message.reply({files: [Math.random() < 0.5 ? './asset/ytp/error1.mp4' : './asset/ytp/error2.mp4']}) - .catch(err => { // In case it can't send the video for some reason - console.error(err); - return message.channel.send('Oh no, an error has occurred! please try again. If this happens alot, you should report this to the developers.'); - }); + if (!args.retry) + args.retry = 0; + else + args.retry += 1; + + if (args.retry === 3) { + return message.reply({files: [Math.random() < 0.5 ? './asset/ytp/error1.mp4' : './asset/ytp/error2.mp4']}) + .catch(err => { // In case it can't send the video for some reason + console.error(err); + return message.channel.send('Oh no, an error has occurred! please try again. If this happens alot, you should report this to the developers.'); + }); + } + + return this.client.commandHandler.runCommand(message, this.client.commandHandler.findCommand('ytp'), args); }); } }