Merge remote-tracking branch 'origin/master'

This commit is contained in:
loicbersier 2020-08-03 11:07:50 +02:00
commit 32566d3730
5 changed files with 20 additions and 11 deletions

View file

@ -9,7 +9,7 @@ const downloader = require('../../utils/download');
class cursesCommand extends Command {
constructor() {
super('curses', {
aliases: ['curses'],
aliases: ['curses', 'curse'],
category: 'fun',
clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'],
args: [
@ -17,6 +17,11 @@ class cursesCommand extends Command {
id: 'link',
type: 'url',
},
{
id: 'webm',
match: 'flag',
flag: ['--webm']
},
],
description: {
content: 'Mess with video length. webm = expanding length and mp4 = very long length',
@ -38,12 +43,15 @@ class cursesCommand extends Command {
link = await attachment(message);
let ext = path.extname(link.toLowerCase());
if (ext !== '.webm' || ext !== '.mp4') {
console.log(ext);
if (ext !== '.webm' && ext !== '.mp4')
ext = '.mp4';
}
if (args.webm) ext = '.webm';
let loadingmsg = await message.channel.send('Processing <a:loadingmin:527579785212329984>');
downloader(link, null, `${os.tmpdir()}/${message.id}${ext}`)
downloader(link, [`--format=${ext.replace('.', '')}`], `${os.tmpdir()}/${message.id}${ext}`)
.on('error', async err => {
loadingmsg.delete();
console.error(err);
@ -53,14 +61,14 @@ class cursesCommand extends Command {
let file = fs.readFileSync(output).toString('hex');
let searchHex = '6d766864';
let replaceHex = '0000017FFFFFFF';
let replaceHex = '0000180FFFFFF7F';
let skipByte = 34;
let endResult;
if (ext === '.webm') {
searchHex = '2ad7b1';
replaceHex = '00000000';
replaceHex = '42FFB060';
skipByte = 8;
endResult = replaceAt(file, file.indexOf(searchHex) + file.substring(file.indexOf(searchHex)).indexOf('4489') + skipByte, replaceHex);
@ -69,7 +77,8 @@ class cursesCommand extends Command {
}
fs.writeFileSync(`${os.tmpdir()}/cursed${message.id}${ext}`, Buffer.from(endResult, 'hex'));
return message.channel.send({files: [`${os.tmpdir()}/cursed${message.id}${ext}`]})
message.delete();
return message.channel.send(`Cursed by ${message.author}`, {files: [`${os.tmpdir()}/cursed${message.id}${ext}`]})
.catch(err => {
console.error(err);
return message.channel.send('Video is too big! try again with something smaller');

View file

@ -85,7 +85,7 @@ class vidshittyfierCommand extends Command {
ffmpegCommand.on('end', () => {
loadingmsg.delete();
message.delete();
return message.channel.send({files: [output2]})
return message.channel.send(`Shittyfied by ${message.author}`, {files: [output2]})
.catch(err => {
console.error(err);
return message.channel.send(`${err.name}: ${err.message} ${err.message === 'Request entity too large' ? 'The file size is too big' : ''}`);

View file

@ -57,7 +57,7 @@ class gif2vidCommand extends Command {
ffmpegCommand.on('end', () => {
loadingmsg.delete();
message.delete();
return message.channel.send({files: [`${os.tmpdir()}/${message.id}g2v.mp4`]})
return message.channel.send(`Converted by ${message.author}`, {files: [`${os.tmpdir()}/${message.id}g2v.mp4`]})
.catch(err => {
console.error(err);
return message.channel.send(`${err.name}: ${err.message} ${err.message === 'Request entity too large' ? 'The file size is too big' : ''}`);

View file

@ -63,7 +63,7 @@ class vid2gifCommand extends Command {
ffmpegCommand.on('end', () => {
loadingmsg.delete();
message.delete();
return message.channel.send({files: [`${os.tmpdir()}/${message.id}v2g.gif`]})
return message.channel.send(`Converted by ${message.author}`, {files: [`${os.tmpdir()}/${message.id}v2g.gif`]})
.catch(err => {
console.error(err);
return message.channel.send(`${err.name}: ${err.message} ${err.message === 'Request entity too large' ? 'The file size is too big' : ''}`);

View file

@ -27,7 +27,7 @@ exports.random = function (text, message) {
},
{
name: /\[member\]/,
value: message.guild ? message.guild.members.cache.random().user.username : ''
value: message ? message.guild ? message.guild.members.cache.random().user.username : '' : '' // What the fuck am i doing
},
{
name: /\[memberRand\]/,