2018-12-30 01:20:24 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
2019-01-02 08:09:45 +01:00
|
|
|
const fetch = require('node-fetch');
|
2018-12-30 01:20:24 +01:00
|
|
|
|
|
|
|
class ImgurCommand extends Command {
|
2019-01-02 08:09:45 +01:00
|
|
|
constructor() {
|
|
|
|
super('imgur', {
|
2019-05-03 15:30:57 +02:00
|
|
|
aliases: ['imgur', 'badmeme'],
|
2019-03-30 04:43:44 +01:00
|
|
|
category: 'fun',
|
2019-11-09 12:04:01 +01:00
|
|
|
clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'],
|
2019-01-02 08:09:45 +01:00
|
|
|
description: {
|
2018-12-30 01:20:24 +01:00
|
|
|
content: 'Send some random images from imgur',
|
|
|
|
usage: '',
|
|
|
|
examples: ['']
|
|
|
|
}
|
2019-01-02 08:09:45 +01:00
|
|
|
});
|
|
|
|
}
|
2018-12-30 01:20:24 +01:00
|
|
|
|
2019-01-02 08:09:45 +01:00
|
|
|
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')
|
2020-07-16 09:42:07 +02:00
|
|
|
return message.channel.send('An error has occurred');
|
2018-12-30 01:20:24 +01:00
|
|
|
|
2019-01-02 08:09:45 +01:00
|
|
|
const i = Math.floor((Math.random() * response.data.length));
|
2018-12-30 01:20:24 +01:00
|
|
|
|
2019-01-02 08:09:45 +01:00
|
|
|
message.channel.send(`**${response.data[i].title}**\n${response.data[i].link}`);
|
|
|
|
});
|
|
|
|
}
|
2018-12-30 01:20:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ImgurCommand;
|