Haha-Yes/commands/general/memerclub.js

49 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2020-06-22 15:26:40 +02:00
const { Command } = require('discord-akairo');
const fetch = require('node-fetch');
const { memerToken } = require('../../config.json');
class memerclubCommand extends Command {
constructor() {
super('memerclub', {
aliases: ['memerclub'],
category: 'general',
clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'],
args: [
{
id: 'text',
type: 'string',
2020-06-22 16:07:23 +02:00
default: '',
2020-06-22 15:26:40 +02:00
match: 'rest'
}
],
description: {
2020-06-22 15:31:01 +02:00
content: 'Post whatever you like on https://memerclub.gamingti.me ! ( no rules, go wild )',
2020-06-22 15:26:40 +02:00
usage: '',
examples: ['']
}
});
}
async exec(message, args) {
let Attachment = (message.attachments).array();
let img = '';
if (!Attachment[0] && !args.text) return message.channel.send('You need to input something for me to post!');
if (Attachment[0]) {
img = Attachment[0].url;
}
if (args.text)
if (args.text.includes('discord.gg')) return message.channel.send('No discord invite allowed.');
fetch(`https://memerclub.gamingti.me/api/post/?token=${memerToken}&text=${encodeURI(args.text)}&image=${img}`)
.then((response) => {
return response.json();
}).then((response) => {
2020-06-22 15:30:23 +02:00
console.log(response);
2020-06-22 15:41:43 +02:00
if (response.error) return message.channel.send(response.error);
2020-06-22 15:32:08 +02:00
message.channel.send(`Go check your epic post!\nhttps://memerclub.gamingti.me/post/${response.uuid}`)
2020-06-22 15:30:23 +02:00
});
2020-06-22 15:26:40 +02:00
}
}
module.exports = memerclubCommand;