forked from Supositware/Haha-Yes
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.
33 lines
893 B
JavaScript
33 lines
893 B
JavaScript
6 years ago
|
const { Command } = require('discord-akairo');
|
||
6 years ago
|
const fetch = require('node-fetch');
|
||
6 years ago
|
|
||
|
class ImgurCommand extends Command {
|
||
6 years ago
|
constructor() {
|
||
|
super('imgur', {
|
||
5 years ago
|
aliases: ['imgur', 'badmeme'],
|
||
![]()
6 years ago
|
category: 'fun',
|
||
6 years ago
|
description: {
|
||
6 years ago
|
content: 'Send some random images from imgur',
|
||
|
usage: '',
|
||
|
examples: ['']
|
||
|
}
|
||
6 years ago
|
});
|
||
|
}
|
||
6 years ago
|
|
||
6 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');
|
||
6 years ago
|
|
||
6 years ago
|
const i = Math.floor((Math.random() * response.data.length));
|
||
6 years ago
|
|
||
6 years ago
|
message.channel.send(`**${response.data[i].title}**\n${response.data[i].link}`);
|
||
|
});
|
||
|
}
|
||
6 years ago
|
}
|
||
|
|
||
|
module.exports = ImgurCommand;
|