You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Haha-Yes/commands/general/badmeme.js

33 lines
897 B
JavaScript

const { Command } = require('discord-akairo');
5 years ago
const fetch = require('node-fetch');
class ImgurCommand extends Command {
5 years ago
constructor() {
super('imgur', {
aliases: ['badmeme', 'imgur'],
category: 'general',
description: {
content: 'Send some random images from imgur',
usage: '',
examples: ['']
}
5 years ago
});
}
5 years ago
async exec(message) {
fetch('https://api.imgur.com/3/gallery/hot/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.channel.send('An error has occured');
5 years ago
const i = Math.floor((Math.random() * response.data.length));
5 years ago
message.channel.send(`**${response.data[i].title}**\n${response.data[i].link}`);
});
}
}
module.exports = ImgurCommand;