Haha-Yes/commands/general/spb.js

42 lines
927 B
JavaScript
Raw Normal View History

2019-03-21 20:40:55 +01:00
const { Command } = require('discord-akairo');
const fs = require('fs');
const fetch = require('node-fetch');
class spbCommand extends Command {
constructor() {
super('spb', {
2019-03-22 00:11:34 +01:00
aliases: ['spb'],
category: 'general',
2019-03-21 20:40:55 +01:00
args: [
{
id: 'link',
type: 'string'
}
],
description: {
content: 'Generate a meme from template you send with spb5k (ONLY WORK WITH TEMPLATES)',
usage: '',
examples: ['']
}
});
}
async exec(message, args) {
if (!args.link.includes('shitpostbot.com/template/')) {
return message.channel.send('Need a template Shitpostbot 5000 link!');
}
let link = args.link.replace('template', 'preview');
fetch(link)
.then(res => {
const dest = fs.createWriteStream('./img/spb.png');
2019-03-21 20:40:55 +01:00
res.body.pipe(dest);
dest.on('finish', () => {
return message.channel.send({files: ['./img/spb.png']});
});
2019-03-21 20:40:55 +01:00
});
}
}
module.exports = spbCommand;