Derpibooru Command

This commit is contained in:
Dragon Fire
2018-08-01 21:24:41 -04:00
parent b37755d940
commit e3da6ff719
3 changed files with 41 additions and 3 deletions
+3 -2
View File
@@ -8,14 +8,14 @@
Xiao is a Discord bot coded in JavaScript with
[discord.js](https://discord.js.org/) using the
[Commando](https://github.com/discordjs/Commando) command framework. With nearly
[Commando](https://github.com/discordjs/Commando) command framework. With
300 commands, she is one of the most feature-filled bots out there.
## Invite
The bot is no longer available for invite. You can self-host the bot, or use her
on the [home server](https://discord.gg/sbMe32W).
## Commands (299)
## Commands (300)
### Utility:
* **eval**: Executes JavaScript code.
@@ -117,6 +117,7 @@ on the [home server](https://discord.gg/sbMe32W).
* **bulbapedia**: Searches Bulbapedia for your query.
* **danbooru**: Responds with an image from Danbooru, with optional query.
* **derpibooru**: Responds with an image from Derpibooru.
* **deviantart**: Responds with an image from a DeviantArt section, with optional query.
* **dictionary**: Defines a word.
* **discord-js-docs**: Searches the Discord.js docs for your query.
+37
View File
@@ -0,0 +1,37 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
module.exports = class DerpibooruCommand extends Command {
constructor(client) {
super(client, {
name: 'derpibooru',
aliases: ['derpibooru-image'],
group: 'search',
memberName: 'derpibooru',
description: 'Responds with an image from Derpibooru.',
args: [
{
key: 'query',
prompt: 'What image would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, { query }) {
try {
const search = await request
.get('https://derpibooru.org/search.json')
.query({
q: query,
random_image: 1
});
if (!search.body) return msg.say('Could not find any results.');
const { body } = await request.get(`https://derpibooru.org/images/${search.body.id}.json`);
return msg.say(`https:${body.representations.full}`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "85.9.3",
"version": "85.10.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {