mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +02:00
Quote, Random in Gelbooru and Rule34, Reorder Groups
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class DanbooruCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'danbooru',
|
||||
group: 'search',
|
||||
memberName: 'danbooru',
|
||||
description: 'Searches Danbooru with optional query.',
|
||||
nsfw: true,
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
const { body } = await snekfetch
|
||||
.get('https://danbooru.donmai.us/posts.json')
|
||||
.query({
|
||||
tags: `${query ? `${query} ` : ''}order:random`,
|
||||
limit: 1
|
||||
});
|
||||
if (!body.length || !body[0].file_url) return msg.say('No Results');
|
||||
return msg.say(stripIndents`
|
||||
${query ? `Result for ${query}:` : 'Random Image:'}
|
||||
https://danbooru.donmai.us${body[0].file_url}
|
||||
`);
|
||||
}
|
||||
};
|
||||
@@ -1,43 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const xml = promisifyAll(require('xml2js'));
|
||||
|
||||
module.exports = class GelbooruCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'gelbooru',
|
||||
group: 'search',
|
||||
memberName: 'gelbooru',
|
||||
description: 'Searches Gelbooru for your query.',
|
||||
nsfw: true,
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
const { text } = await snekfetch
|
||||
.get('https://gelbooru.com/index.php')
|
||||
.query({
|
||||
page: 'dapi',
|
||||
s: 'post',
|
||||
q: 'index',
|
||||
tags: query,
|
||||
limit: 1
|
||||
});
|
||||
const { posts } = await xml.parseStringAsync(text);
|
||||
if (posts.$.count === '0') return msg.say('No Results.');
|
||||
return msg.say(stripIndents`
|
||||
Result for ${query}:
|
||||
https:${posts.post[0].$.file_url}
|
||||
`);
|
||||
}
|
||||
};
|
||||
@@ -1,38 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class KonachanCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'konachan',
|
||||
group: 'search',
|
||||
memberName: 'konachan',
|
||||
description: 'Searches Konachan with optional query.',
|
||||
nsfw: true,
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
const { body } = await snekfetch
|
||||
.get('https://konachan.net/post.json')
|
||||
.query({
|
||||
tags: `${query ? `${query} ` : ''}order:random`,
|
||||
limit: 1
|
||||
});
|
||||
if (!body.length) return msg.say('No Results.');
|
||||
return msg.say(stripIndents`
|
||||
${query ? `Result for ${query}:` : 'Random Image:'}
|
||||
https:${body[0].file_url}
|
||||
`);
|
||||
}
|
||||
};
|
||||
@@ -1,43 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const xml = promisifyAll(require('xml2js'));
|
||||
|
||||
module.exports = class Rule34Command extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'rule34',
|
||||
group: 'search',
|
||||
memberName: 'rule34',
|
||||
description: 'Searches Rule34 for your query.',
|
||||
nsfw: true,
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
const { text } = await snekfetch
|
||||
.get('https://rule34.xxx/index.php')
|
||||
.query({
|
||||
page: 'dapi',
|
||||
s: 'post',
|
||||
q: 'index',
|
||||
tags: query,
|
||||
limit: 1
|
||||
});
|
||||
const { posts } = await xml.parseStringAsync(text);
|
||||
if (posts.$.count === '0') return msg.say('No Results.');
|
||||
return msg.say(stripIndents`
|
||||
Result for ${query}:
|
||||
https:${posts.post[0].$.file_url}
|
||||
`);
|
||||
}
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class XKCDCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'xkcd',
|
||||
aliases: ['kcd'],
|
||||
group: 'search',
|
||||
memberName: 'xkcd',
|
||||
description: 'Gets an XKCD Comic, optionally opting for today\'s or a specific number.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'type',
|
||||
prompt: 'Please enter either a specific comic number, today, or random.',
|
||||
type: 'string',
|
||||
default: 'random',
|
||||
parse: (type) => type.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const { type } = args;
|
||||
const current = await snekfetch
|
||||
.get('https://xkcd.com/info.0.json');
|
||||
if (type === 'today') {
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(`${current.body.num} - ${current.body.title}`)
|
||||
.setURL(`https://xkcd.com/${current.body.num}`)
|
||||
.setImage(current.body.img)
|
||||
.setFooter(current.body.alt);
|
||||
return msg.embed(embed);
|
||||
} else if (type === 'random') {
|
||||
const random = Math.floor(Math.random() * current.body.num) + 1;
|
||||
const { body } = await snekfetch
|
||||
.get(`https://xkcd.com/${random}/info.0.json`);
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(`${body.num} - ${body.title}`)
|
||||
.setURL(`https://xkcd.com/${body.num}`)
|
||||
.setImage(body.img)
|
||||
.setFooter(body.alt);
|
||||
return msg.embed(embed);
|
||||
} else {
|
||||
const choice = parseInt(type, 10);
|
||||
if (isNaN(choice) || current.body.num < choice || choice < 1) return msg.say('Invalid Number.');
|
||||
const { body } = await snekfetch
|
||||
.get(`https://xkcd.com/${choice}/info.0.json`);
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(`${body.num} - ${body.title}`)
|
||||
.setURL(`https://xkcd.com/${body.num}`)
|
||||
.setImage(body.img)
|
||||
.setFooter(body.alt);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user