From 4734b5cf4d5ffbe1b4bf46433c820d04d526c207 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 2 Oct 2018 10:43:17 +0200 Subject: [PATCH] Take images from imgur --- commands/fun/badmeme.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 commands/fun/badmeme.js diff --git a/commands/fun/badmeme.js b/commands/fun/badmeme.js new file mode 100644 index 00000000..efbad40d --- /dev/null +++ b/commands/fun/badmeme.js @@ -0,0 +1,29 @@ +const { Command } = require('discord.js-commando'); +const Discord = require('discord.js'); +const fetch = require('node-fetch') +module.exports = class BadMemeCommand extends Command { + constructor(client) { + super(client, { + name: 'badmeme', + group: 'fun', + memberName: 'badmeme', + description: `Show a random dog`, + }); + } + + async run(message) { + + fetch("https://api.imgur.com/3/gallery/hot/top/day?showViral=true&mature=false&perPage=100&album_previews=true", { + headers: { "Authorization": "Client-ID e4cb6948f80f295" }, + }).then((response) => { + return response.json(); +}).then((response) => { + if (response.success == 'false') + return message.say('An error has occured') + + const i = Math.floor((Math.random() * response.data.length)); + + message.say(`**${response.data[i].title}**`) + message.say(response.data[i].link); + }); +}}; \ No newline at end of file