From bde108f25821764face42e936841fddacdf0840a Mon Sep 17 00:00:00 2001
From: loicbersier <loic.bersier1@gmail.com>
Date: Mon, 22 Jun 2020 15:26:40 +0200
Subject: [PATCH] Memer club api

---
 commands/general/memerclub.js | 46 +++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 commands/general/memerclub.js

diff --git a/commands/general/memerclub.js b/commands/general/memerclub.js
new file mode 100644
index 00000000..9c68cac5
--- /dev/null
+++ b/commands/general/memerclub.js
@@ -0,0 +1,46 @@
+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',
+					match: 'rest'
+				}
+			],
+			description: {
+				content: 'Post whatever you like on https://memerclub.gamingti.me! ( no rules, go wild )',
+				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) => {
+            message.channel.send(`Go check your epic post!\nhttps://memerclub.gaminigti.me/post/${response.uuid}`)
+        });
+    }
+}
+
+module.exports = memerclubCommand;
\ No newline at end of file