Put link in embed ( so it look better than just plain link )
This commit is contained in:
parent
91ea715fe7
commit
3af87cab64
1 changed files with 16 additions and 4 deletions
|
@ -3,6 +3,7 @@ const fs = require('fs');
|
||||||
const youtubedl = require('youtube-dl');
|
const youtubedl = require('youtube-dl');
|
||||||
const hbjs = require('handbrake-js');
|
const hbjs = require('handbrake-js');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
class DownloadCommand extends Command {
|
class DownloadCommand extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -50,7 +51,7 @@ class DownloadCommand extends Command {
|
||||||
if (err);
|
if (err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return youtubedl.exec(args.link, ['--format=mp4', '-o', `${os.tmpdir()}/${fileName}.mp4`], {}, async function(err) {
|
return youtubedl.exec(link, ['--format=mp4', '-o', `${os.tmpdir()}/${fileName}.mp4`], {}, async function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
loadingmsg.delete();
|
loadingmsg.delete();
|
||||||
|
@ -90,7 +91,13 @@ class DownloadCommand extends Command {
|
||||||
handbrake.on('end', async function () {
|
handbrake.on('end', async function () {
|
||||||
message.delete();
|
message.delete();
|
||||||
compressmsg.delete();
|
compressmsg.delete();
|
||||||
return message.channel.send(`Downloaded by ${message.author.username}`, { files: [`${os.tmpdir()}/${fileName}compressed.mp4`] })
|
|
||||||
|
const Embed = new MessageEmbed()
|
||||||
|
.setColor(message.member.displayHexColor)
|
||||||
|
.setTitle(`Downloaded by ${message.author.username}`)
|
||||||
|
.setURL(link);
|
||||||
|
|
||||||
|
return message.channel.send({embed: Embed, files: [`${os.tmpdir()}/${fileName}compressed.mp4`]})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
compressmsg.delete();
|
compressmsg.delete();
|
||||||
|
@ -98,10 +105,15 @@ class DownloadCommand extends Command {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('file smaller than 8MB');
|
|
||||||
message.delete();
|
message.delete();
|
||||||
loadingmsg.delete();
|
loadingmsg.delete();
|
||||||
return message.channel.send(`Downloaded by ${message.author.username}`, { files: [`${os.tmpdir()}/${fileName}.mp4`] })
|
|
||||||
|
const Embed = new MessageEmbed()
|
||||||
|
.setColor(message.member.displayHexColor)
|
||||||
|
.setTitle(`Downloaded by ${message.author.username}`)
|
||||||
|
.setURL(link);
|
||||||
|
|
||||||
|
return message.channel.send({embed: Embed, files: [`${os.tmpdir()}/${fileName}.mp4`]})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
loadingmsg.delete();
|
loadingmsg.delete();
|
||||||
|
|
Loading…
Reference in a new issue