Quote, Random in Gelbooru and Rule34, Reorder Groups

This commit is contained in:
Daniel Odendahl Jr
2017-07-25 21:31:14 +00:00
parent 0d51d7ca78
commit 4ee179f359
12 changed files with 54 additions and 20 deletions
+38
View File
@@ -0,0 +1,38 @@
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: 'random-img',
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}
`);
}
};
+44
View File
@@ -0,0 +1,44 @@
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: 'random-img',
memberName: 'gelbooru',
description: 'Searches Gelbooru 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 { text } = await snekfetch
.get('https://gelbooru.com/index.php')
.query({
page: 'dapi',
s: 'post',
q: 'index',
tags: query,
limit: 200
});
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[Math.floor(Math.random * posts.post.length)].$.file_url}
`);
}
};
+38
View File
@@ -0,0 +1,38 @@
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: 'random-img',
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}
`);
}
};
+44
View File
@@ -0,0 +1,44 @@
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: 'random-img',
memberName: 'rule34',
description: 'Searches Rule34 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 { text } = await snekfetch
.get('https://rule34.xxx/index.php')
.query({
page: 'dapi',
s: 'post',
q: 'index',
tags: query,
limit: 200
});
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[Math.floor(Math.random() * posts.post.length)].$.file_url}
`);
}
};
-18
View File
@@ -1,18 +0,0 @@
const Command = require('../../structures/Command');
const songs = require('../../assets/json/vocaloid');
module.exports = class VocaloidCommand extends Command {
constructor(client) {
super(client, {
name: 'vocaloid',
group: 'random-img',
memberName: 'vocaloid',
description: 'Responds with a random VOCALOID song.'
});
}
run(msg) {
const song = songs[Math.floor(Math.random() * songs.length)];
return msg.say(song);
}
};
+1 -1
View File
@@ -5,7 +5,7 @@ module.exports = class XiaoCommand extends Command {
constructor(client) {
super(client, {
name: 'xiao',
aliases: ['xiao-pai'],
aliases: ['xiao-pai', 'iao'],
group: 'random-img',
memberName: 'xiao',
description: 'Responds with a random image of Xiao Pai.',