Merge remote-tracking branch 'origin/master'

merge-requests/5/merge
loicbersier 4 years ago
commit f0d9b853c5

@ -3,6 +3,8 @@ const YTPGenerator = require('ytpplus-node');
const os = require('os');
const fs = require('fs');
const youtubedl = require('youtube-dl');
const MAX_CLIPS = 20;
class ytpCommand extends Command {
constructor() {
@ -100,8 +102,6 @@ class ytpCommand extends Command {
}
async exec(message, args) {
let MAX_CLIPS = 20;
if (args.pool) {
let mp4 = [];
fs.readdirSync('./asset/ytp/userVid/').forEach(file => {
@ -123,7 +123,7 @@ class ytpCommand extends Command {
}
if (url) {
return youtubedl.exec(url, ['--no-playlist','--max-filesize', '50m', '--format=mp4', '-o', `./asset/ytp/userVid/${message.id}.mp4`], {}, function(err, output) {
return youtubedl.exec(url, ['--rm-cache-dir', '--no-playlist', '--max-filesize', '50m', '--format=mp4', '-o', `./asset/ytp/userVid/${message.id}.mp4`], {}, function(err, output) {
console.log(output);
if (err) {
console.error(err);

@ -69,10 +69,10 @@ class DownloadCommand extends Command {
if (fs.existsSync(`${os.tmpdir()}/${fileName}`)) {
fs.unlink(`${os.tmpdir()}/${fileName}`, (err) => {
if (err);
if (err) console.error(err);
});
}
return youtubedl.exec(link, ['-o', `${os.tmpdir()}/${fileName}`], {}, async function(err) {
return youtubedl.exec(link, ['--rm-cache-dir', '-o', `${os.tmpdir()}/${fileName}`], {}, async function(err) {
if (err) {
console.error(err);
loadingmsg.delete();
@ -84,7 +84,7 @@ class DownloadCommand extends Command {
if (fs.existsSync(`${os.tmpdir()}/${fileName}`)) {
ext = await filetype.fromFile(`${os.tmpdir()}/${fileName}`);
ext = ext.ext; // This look stupid but hey, it work
if (ext == '3gp') ext = 'mp4'; // Change 3gp file extension to mp4 so discord show the video ( and to stop people from complaining )
if (ext === '3gp') ext = 'mp4'; // Change 3gp file extension to mp4 so discord show the video ( and to stop people from complaining )
fs.renameSync(`${os.tmpdir()}/${fileName}`, `${os.tmpdir()}/${fileName}.${ext}`);
} else if (fs.existsSync(`${os.tmpdir()}/${fileName}.mkv`)) { // If it can't find the video assume it got merged and end with mkv
fs.renameSync(`${os.tmpdir()}/${fileName}.mkv`, `${os.tmpdir()}/${fileName}.mp4`); // Discord play mkv just fine but it need to end with mp4
@ -125,7 +125,7 @@ class DownloadCommand extends Command {
// Every 5 seconds update the compress message with the %
let editmsg = setInterval(() => {
compressEmbed.setDescription(`Ready in ${eta == '' ? 'soon enough' : eta}. ${percentComplete}% complete.`);
compressEmbed.setDescription(`Ready in ${eta === '' ? 'soon enough' : eta}. ${percentComplete}% complete.`);
compressmsg.edit(compressEmbed);
}, 5000);

@ -0,0 +1,16 @@
const { Listener } = require('discord-akairo');
class commandFinishedListener extends Listener {
constructor() {
super('commandFinished', {
emitter: 'commandHandler',
event: 'commandFinished'
});
}
async exec(message, command) {
console.timeEnd(command.id);
}
}
module.exports = commandFinishedListener;

@ -13,6 +13,8 @@ class commandStartedListener extends Listener {
}
async exec(message, command) {
console.time(command.id);
//This is for april fools
let today = new Date(), lastUpdate;
@ -27,7 +29,7 @@ class commandStartedListener extends Listener {
}
let curDate = dd + '.' + mm;
//Only execute when its april first
if (curDate == '01.04' && !serverID.includes(message.guild.id)) {
if (curDate === '01.04' && !serverID.includes(message.guild.id)) {
let count = Math.random() * 100;
if (count < 10) {
serverID.push(message.guild.id);
@ -49,7 +51,7 @@ class commandStartedListener extends Listener {
}
if (dailyStats) {
if (command.category.id == 'owner') return; // Don't count owner command
if (command.category.id === 'owner') return; // Don't count owner command
let obj = {
guild: message.guild.id,
command: command.id

@ -0,0 +1,16 @@
const { Listener } = require('discord-akairo');
class unhandledRejectionListener extends Listener {
constructor() {
super('uncaughtException', {
emitter: 'process',
event: 'uncaughtException'
});
}
async exec(error) {
return console.error(`\x1b[31mUncaughtException: ${error}\x1b[37m`);
}
}
module.exports = unhandledRejectionListener;

30
package-lock.json generated

@ -76,16 +76,6 @@
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.5.tgz",
"integrity": "sha512-CU1q0UXQUpFNzNB7gufgoisDHP7n+T3tkqTsp3MNUkVJ5+hS3BCvME8uCXAUFlz+6T2FbTCu75A+yQ7HMKqRKw=="
},
"@discordjs/form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
"integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
},
"@google-cloud/text-to-speech": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@google-cloud/text-to-speech/-/text-to-speech-2.3.0.tgz",
@ -2295,17 +2285,29 @@
"from": "github:1Computer1/discord-akairo#master"
},
"discord.js": {
"version": "github:discordjs/discord.js#026691702da7d1fcf9a959f00082f07f1e14b13d",
"version": "github:discordjs/discord.js#5b9cdc5cd243b1588c285e22b90d92535a30b993",
"from": "github:discordjs/discord.js#master",
"requires": {
"@discordjs/collection": "^0.1.5",
"@discordjs/form-data": "^3.0.1",
"abort-controller": "^3.0.0",
"form-data": "^3.0.0",
"node-fetch": "^2.6.0",
"prism-media": "^1.2.0",
"setimmediate": "^1.0.5",
"tweetnacl": "^1.0.3",
"ws": "^7.2.1"
},
"dependencies": {
"form-data": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz",
"integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
}
}
},
"doctrine": {
@ -2465,7 +2467,7 @@
}
},
"erlpack": {
"version": "github:discordapp/erlpack#c514d36ec81a7a61ef90b75df261025ab046574d",
"version": "github:discordapp/erlpack#5d0064f9e106841e1eead711a6451f99b0d289fd",
"from": "github:discordapp/erlpack",
"requires": {
"bindings": "^1.5.0",
@ -7894,7 +7896,7 @@
}
},
"ytpplus-node": {
"version": "git+https://git@github.com/loicbersier/ytpplus-node.git#6ebaa924f8e49b016f57610193517e65b7cce87d",
"version": "git+https://git@github.com/loicbersier/ytpplus-node.git#a9edb7a9596734d0b518cb32e1581f06ce5f7ad7",
"from": "git+https://git@github.com/loicbersier/ytpplus-node.git",
"requires": {
"ffmpeg-static": "^2.4.0",

Loading…
Cancel
Save