Haha-Yes/commands/fun/badmeme.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-10-02 10:43:17 +02:00
const { Command } = require('discord.js-commando');
const fetch = require('node-fetch')
2018-11-28 01:35:26 +01:00
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../blacklist');
2018-10-15 20:23:45 +02:00
2018-10-02 10:43:17 +02:00
module.exports = class BadMemeCommand extends Command {
constructor(client) {
super(client, {
name: 'badmeme',
group: 'fun',
memberName: 'badmeme',
description: `Take random images from imgur`,
2018-10-02 10:43:17 +02:00
});
}
async run(message) {
2018-11-28 01:35:26 +01:00
let blacklistJson = new SelfReloadJSON('json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
2018-10-02 10:43:17 +02:00
2018-10-02 11:55:58 +02:00
fetch("https://api.imgur.com/3/gallery/hot/day?showViral=true&mature=false&perPage=100&album_previews=true", {
2018-10-02 10:43:17 +02:00
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);
});
}};