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'],
|
2019-03-30 04:43:44 +01:00
|
|
|
category: 'fun',
|
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) {
|
2019-03-24 17:30:45 +01:00
|
|
|
if (!args.link || !args.link.includes('shitpostbot.com/template/')) {
|
2019-03-24 17:34:14 +01:00
|
|
|
return message.channel.send('Need a Shitpostbot 5000 template link!\nYou can find them here! <https://www.shitpostbot.com/gallery/templates>');
|
2019-03-21 20:40:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
let link = args.link.replace('template', 'preview');
|
|
|
|
|
|
|
|
fetch(link)
|
|
|
|
.then(res => {
|
2019-03-23 19:04:30 +01:00
|
|
|
const dest = fs.createWriteStream('./img/spb.png');
|
2019-03-21 20:40:55 +01:00
|
|
|
res.body.pipe(dest);
|
2019-03-21 20:57:51 +01:00
|
|
|
dest.on('finish', () => {
|
2019-03-23 19:04:30 +01:00
|
|
|
return message.channel.send({files: ['./img/spb.png']});
|
2019-03-21 20:57:51 +01:00
|
|
|
});
|
2019-03-21 20:40:55 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = spbCommand;
|