Download from the server if Hapi server is down
Signed-off-by: loicbersier <loic.bersier1@gmail.com>
This commit is contained in:
parent
2487e6efcd
commit
33719b4f13
1 changed files with 10 additions and 4 deletions
|
@ -68,13 +68,15 @@ class DownloadCommand extends Command {
|
|||
|
||||
|
||||
if (Hapi) {
|
||||
Embed.setFooter(`Using Hapi | ${Embed.footer.text}`);
|
||||
compressEmbed.setFooter(`Using Hapi | ${compressEmbed.footer.text}`);
|
||||
let error = false;
|
||||
|
||||
const params = new URLSearchParams();
|
||||
params.append('url', args.link.href);
|
||||
fetch(`${Hapi}/download`, {method: 'POST', body: params})
|
||||
.then(async res => {
|
||||
Embed.setFooter(`Using Hapi | ${Embed.footer.text}`);
|
||||
compressEmbed.setFooter(`Using Hapi | ${compressEmbed.footer.text}`);
|
||||
|
||||
if (res.headers.get('content-type') == 'application/json; charset=utf-8') {
|
||||
let json = await res.json();
|
||||
let compressmsg = await message.channel.send(compressEmbed);
|
||||
|
@ -134,15 +136,19 @@ class DownloadCommand extends Command {
|
|||
message.channel.send({embed: Embed, files: [`${os.tmpdir()}/${message.id}.mp4`]});
|
||||
});
|
||||
}
|
||||
|
||||
message.delete();
|
||||
loadingmsg.delete();
|
||||
return;
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e);
|
||||
return message.channel.send('Hapi server returned an error.');
|
||||
error = true;
|
||||
message.channel.send('Hapi server returned an error or is unreachable. Trying standalone download.');
|
||||
});
|
||||
return;
|
||||
|
||||
if (!error)
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.listproxy) {
|
||||
|
|
Loading…
Reference in a new issue