From 4ee179f3598d5c95df21b2fc7e496f37987750e2 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Tue, 25 Jul 2017 21:31:14 +0000 Subject: [PATCH] Quote, Random in Gelbooru and Rule34, Reorder Groups --- commands/{random-res => games}/fishy.js | 2 +- commands/{search => random-img}/danbooru.js | 2 +- commands/{search => random-img}/gelbooru.js | 11 ++++--- commands/{search => random-img}/konachan.js | 2 +- commands/{search => random-img}/rule34.js | 11 ++++--- commands/random-img/xiao.js | 2 +- commands/random-res/quote.js | 32 +++++++++++++++++++ commands/{random => random-res}/today.js | 4 +-- .../{random-img => random-res}/vocaloid.js | 2 +- .../would-you-rather.js | 2 +- commands/{search => random}/xkcd.js | 2 +- package.json | 2 +- 12 files changed, 54 insertions(+), 20 deletions(-) rename commands/{random-res => games}/fishy.js (93%) rename commands/{search => random-img}/danbooru.js (97%) rename commands/{search => random-img}/gelbooru.js (80%) rename commands/{search => random-img}/konachan.js (97%) rename commands/{search => random-img}/rule34.js (79%) create mode 100644 commands/random-res/quote.js rename commands/{random => random-res}/today.js (96%) rename commands/{random-img => random-res}/vocaloid.js (93%) rename commands/{random => random-res}/would-you-rather.js (96%) rename commands/{search => random}/xkcd.js (98%) diff --git a/commands/random-res/fishy.js b/commands/games/fishy.js similarity index 93% rename from commands/random-res/fishy.js rename to commands/games/fishy.js index 0c45aa4e..1a31b029 100644 --- a/commands/random-res/fishy.js +++ b/commands/games/fishy.js @@ -5,7 +5,7 @@ module.exports = class FishyCommand extends Command { constructor(client) { super(client, { name: 'fishy', - group: 'random-res', + group: 'games', memberName: 'fishy', description: 'Catches a fish.' }); diff --git a/commands/search/danbooru.js b/commands/random-img/danbooru.js similarity index 97% rename from commands/search/danbooru.js rename to commands/random-img/danbooru.js index b01f5178..ea2adc65 100644 --- a/commands/search/danbooru.js +++ b/commands/random-img/danbooru.js @@ -6,7 +6,7 @@ module.exports = class DanbooruCommand extends Command { constructor(client) { super(client, { name: 'danbooru', - group: 'search', + group: 'random-img', memberName: 'danbooru', description: 'Searches Danbooru with optional query.', nsfw: true, diff --git a/commands/search/gelbooru.js b/commands/random-img/gelbooru.js similarity index 80% rename from commands/search/gelbooru.js rename to commands/random-img/gelbooru.js index 4931a5c4..5bba2c30 100644 --- a/commands/search/gelbooru.js +++ b/commands/random-img/gelbooru.js @@ -8,15 +8,16 @@ module.exports = class GelbooruCommand extends Command { constructor(client) { super(client, { name: 'gelbooru', - group: 'search', + group: 'random-img', memberName: 'gelbooru', - description: 'Searches Gelbooru for your query.', + description: 'Searches Gelbooru with optional query.', nsfw: true, args: [ { key: 'query', prompt: 'What would you like to search for?', - type: 'string' + type: 'string', + default: '' } ] }); @@ -31,13 +32,13 @@ module.exports = class GelbooruCommand extends Command { s: 'post', q: 'index', tags: query, - limit: 1 + 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[0].$.file_url} + https:${posts.post[Math.floor(Math.random * posts.post.length)].$.file_url} `); } }; diff --git a/commands/search/konachan.js b/commands/random-img/konachan.js similarity index 97% rename from commands/search/konachan.js rename to commands/random-img/konachan.js index cf308325..ed4d6bc2 100644 --- a/commands/search/konachan.js +++ b/commands/random-img/konachan.js @@ -6,7 +6,7 @@ module.exports = class KonachanCommand extends Command { constructor(client) { super(client, { name: 'konachan', - group: 'search', + group: 'random-img', memberName: 'konachan', description: 'Searches Konachan with optional query.', nsfw: true, diff --git a/commands/search/rule34.js b/commands/random-img/rule34.js similarity index 79% rename from commands/search/rule34.js rename to commands/random-img/rule34.js index ad02eda6..9a94a2e4 100644 --- a/commands/search/rule34.js +++ b/commands/random-img/rule34.js @@ -8,15 +8,16 @@ module.exports = class Rule34Command extends Command { constructor(client) { super(client, { name: 'rule34', - group: 'search', + group: 'random-img', memberName: 'rule34', - description: 'Searches Rule34 for your query.', + description: 'Searches Rule34 with optional query.', nsfw: true, args: [ { key: 'query', prompt: 'What would you like to search for?', - type: 'string' + type: 'string', + default: '' } ] }); @@ -31,13 +32,13 @@ module.exports = class Rule34Command extends Command { s: 'post', q: 'index', tags: query, - limit: 1 + 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[0].$.file_url} + https:${posts.post[Math.floor(Math.random() * posts.post.length)].$.file_url} `); } }; diff --git a/commands/random-img/xiao.js b/commands/random-img/xiao.js index 3bf92a06..a33b5dbf 100644 --- a/commands/random-img/xiao.js +++ b/commands/random-img/xiao.js @@ -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.', diff --git a/commands/random-res/quote.js b/commands/random-res/quote.js new file mode 100644 index 00000000..90cf53e3 --- /dev/null +++ b/commands/random-res/quote.js @@ -0,0 +1,32 @@ +const Command = require('../../structures/Command'); +const { MessageEmbed } = require('discord.js'); +const snekfetch = require('snekfetch'); + +module.exports = class QuoteCommand extends Command { + constructor(client) { + super(client, { + name: 'quote', + group: 'random-res', + memberName: 'quote', + description: 'Responds with a random quote.', + clientPermissions: ['EMBED_LINKS'] + }); + } + + async run(msg) { + const { body } = await snekfetch + .get('https://api.forismatic.com/api/1.0/') + .query({ + method: 'getQuote', + lang: 'en', + format: 'json' + }); + const embed = new MessageEmbed() + .setColor(0x9797FF) + .setURL(body.quoteLink) + .setAuthor(body.quoteAuthor) + .setDescription(body.quoteText); + return msg.embed(embed); + } +}; + diff --git a/commands/random/today.js b/commands/random-res/today.js similarity index 96% rename from commands/random/today.js rename to commands/random-res/today.js index 908dc619..b51c42cc 100644 --- a/commands/random/today.js +++ b/commands/random-res/today.js @@ -6,8 +6,8 @@ module.exports = class TodayCommand extends Command { constructor(client) { super(client, { name: 'today', - aliases: ['event'], - group: 'random', + aliases: ['event', 'history'], + group: 'random-res', memberName: 'today', description: 'Responds with an event that occurred today in history, or on a specific day.', clientPermissions: ['EMBED_LINKS'], diff --git a/commands/random-img/vocaloid.js b/commands/random-res/vocaloid.js similarity index 93% rename from commands/random-img/vocaloid.js rename to commands/random-res/vocaloid.js index 115c7348..f0d91937 100644 --- a/commands/random-img/vocaloid.js +++ b/commands/random-res/vocaloid.js @@ -5,7 +5,7 @@ module.exports = class VocaloidCommand extends Command { constructor(client) { super(client, { name: 'vocaloid', - group: 'random-img', + group: 'random-res', memberName: 'vocaloid', description: 'Responds with a random VOCALOID song.' }); diff --git a/commands/random/would-you-rather.js b/commands/random-res/would-you-rather.js similarity index 96% rename from commands/random/would-you-rather.js rename to commands/random-res/would-you-rather.js index 686a0e0f..7ab00482 100644 --- a/commands/random/would-you-rather.js +++ b/commands/random-res/would-you-rather.js @@ -7,7 +7,7 @@ module.exports = class WouldYouRatherCommand extends Command { super(client, { name: 'would-you-rather', aliases: ['wy-rather'], - group: 'random', + group: 'random-res', memberName: 'would-you-rather', description: 'Responds with a random would you rather question.', clientPermissions: ['EMBED_LINKS'] diff --git a/commands/search/xkcd.js b/commands/random/xkcd.js similarity index 98% rename from commands/search/xkcd.js rename to commands/random/xkcd.js index a50635de..daa814e5 100644 --- a/commands/search/xkcd.js +++ b/commands/random/xkcd.js @@ -7,7 +7,7 @@ module.exports = class XKCDCommand extends Command { super(client, { name: 'xkcd', aliases: ['kcd'], - group: 'search', + group: 'random', memberName: 'xkcd', description: 'Gets an XKCD Comic, optionally opting for today\'s or a specific number.', clientPermissions: ['EMBED_LINKS'], diff --git a/package.json b/package.json index e1d2d201..ab787b4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "27.6.1", + "version": "27.7.0", "description": "Your personal server companion.", "main": "Shard.js", "scripts": {