This commit is contained in:
Flummi 2016-09-10 11:57:03 +02:00
parent d1373f94b4
commit d250f32e7f

View File

@ -1,6 +1,7 @@
var fs = require('fs-extra'); var fs = require('fs-extra');
var ytdl = require('ytdl-core'); var ytdl = require('ytdl-core');
var uuid = require('uuid'); var uuid = require('uuid');
var cfg = require('../../cfg/main.json');
module.exports = (bot, lib) => { module.exports = (bot, lib) => {
lib.trigger.add({ lib.trigger.add({
@ -24,10 +25,10 @@ module.exports = (bot, lib) => {
try { try {
ytdl.downloadFromInfo(info, { filter: (format) => { return format.container === 'webm'; } }) ytdl.downloadFromInfo(info, { filter: (format) => { return format.container === 'webm'; } })
.on('response', (res) => { .on('response', (res) => {
if(res.headers['content-length'] > lib.cfg.maxFileSize) { if(res.headers['content-length'] > cfg.maxFileSize) {
res.destroy(); res.destroy();
dl = false; dl = false;
e.reply('f0ck! your file is too big (~'+lib.formatSize(res.headers['content-length'])+'), max '+lib.formatSize(lib.cfg.maxFileSize)+' allowed'); e.reply('f0ck! your file is too big (~'+lib.formatSize(res.headers['content-length'])+'), max '+lib.formatSize(cfg.maxFileSize)+' allowed');
} }
}) })
.on('error', (err) => { .on('error', (err) => {