mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-10 02:45:22 +02:00
Sakugabooru Command
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class SakugabooruCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'sakugabooru',
|
||||
aliases: ['sakuga'],
|
||||
group: 'search',
|
||||
memberName: 'sakugabooru',
|
||||
description: 'Responds with an image from Sakugabooru, with optional query.',
|
||||
nsfw: true,
|
||||
credit: [
|
||||
{
|
||||
name: 'Danbooru',
|
||||
url: 'https://danbooru.donmai.us/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://www.sakugabooru.com/post.json')
|
||||
.query({
|
||||
tags: `${query} order:random`,
|
||||
limit: 1
|
||||
});
|
||||
if (!body.length || !body[0].file_url) return msg.say('Could not find any results.');
|
||||
return msg.say(body[0].file_url);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "132.4.0",
|
||||
"version": "132.5.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user