Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Loïc Bersier
Haha Yes
Commits
33719b4f
Commit
33719b4f
authored
Feb 04, 2021
by
Loïc Bersier
😎
Browse files
Download from the server if Hapi server is down
Signed-off-by:
loicbersier
<
loic.bersier1@gmail.com
>
parent
2487e6ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
commands/utility/download.js
commands/utility/download.js
+10
-4
No files found.
commands/utility/download.js
View file @
33719b4f
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment