mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 08:12:04 +02:00
Add Gelbooru, Danbooru, and Konachan commands
This commit is contained in:
@@ -47,7 +47,7 @@ Xiao is a Discord bot coded in JavaScript with
|
||||
7. Run `npm i -g pm2` to install PM2.
|
||||
8. Run `pm2 start Xiao.js --name xiao` to run the bot.
|
||||
|
||||
## Commands (333)
|
||||
## Commands (336)
|
||||
### Utility:
|
||||
|
||||
* **eval:** Executes JavaScript code.
|
||||
@@ -160,6 +160,7 @@ Xiao is a Discord bot coded in JavaScript with
|
||||
* **azur-lane:** Responds with information on an Azur Lane ship.
|
||||
* **book:** Searches Google Books for a book.
|
||||
* **bulbapedia:** Searches Bulbapedia for your query.
|
||||
* **danbooru:** Responds with an image from Danbooru, with optional query.
|
||||
* **define:** Defines a word.
|
||||
* **derpibooru:** Responds with an image from Derpibooru.
|
||||
* **deviantart:** Responds with an image from a DeviantArt section, with optional query.
|
||||
@@ -168,6 +169,7 @@ Xiao is a Discord bot coded in JavaScript with
|
||||
* **esrb:** Searches ESRB for your query.
|
||||
* **flickr:** Searches Flickr for your query.
|
||||
* **forecast:** Responds with the seven-day forecast for a specific location.
|
||||
* **gelbooru:** Responds with an image from Gelbooru, with optional query.
|
||||
* **giphy:** Searches Giphy for your query.
|
||||
* **github:** Responds with information on a GitHub repository.
|
||||
* **google-autofill:** Responds with a list of the Google Autofill results for a particular query.
|
||||
@@ -181,6 +183,7 @@ Xiao is a Discord bot coded in JavaScript with
|
||||
* **kh-wiki:** Searches the Kingdom Hearts Wiki for your query.
|
||||
* **kickstarter:** Searches Kickstarter for your query.
|
||||
* **know-your-meme:** Searches Know Your Meme for your query.
|
||||
* **konachan:** Responds with an image from Konachan, with optional query.
|
||||
* **league-of-legends:** Responds with information on a League of Legends champion.
|
||||
* **manga:** Searches AniList for your query, getting manga results.
|
||||
* **map:** Responds with a map of a specific location.
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class DanbooruCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'danbooru',
|
||||
group: 'search',
|
||||
memberName: 'danbooru',
|
||||
description: 'Responds with an image from Danbooru, with optional query.',
|
||||
nsfw: true,
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What image would you like to search for?',
|
||||
type: 'string',
|
||||
default: '',
|
||||
validate: query => {
|
||||
if (!query.includes(' ')) return true;
|
||||
return 'Invalid query, please only search for one tag at a time.';
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://danbooru.donmai.us/posts.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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class GelbooruCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'gelbooru',
|
||||
group: 'search',
|
||||
memberName: 'gelbooru',
|
||||
description: 'Responds with an image from Gelbooru, with optional query.',
|
||||
nsfw: true,
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What image would you like to search for?',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://gelbooru.org/index.php')
|
||||
.query({
|
||||
page: 'dapi',
|
||||
s: 'post',
|
||||
q: 'index',
|
||||
json: 1,
|
||||
tags: query,
|
||||
limit: 200
|
||||
});
|
||||
return msg.say(body[Math.floor(Math.random() * body.length)].file_url);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class KonachanCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'konachan',
|
||||
group: 'search',
|
||||
memberName: 'konachan',
|
||||
description: 'Responds with an image from Konachan, with optional query.',
|
||||
nsfw: true,
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What image would you like to search for?',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://konachan.net/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(`https:${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": "98.3.1",
|
||||
"version": "98.4.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user