Haha-Yes/commands/fun/spb.js

42 lines
1,010 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'],
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) {
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 => {
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;