From 5da9dafaf4fa8dc5fa89e5af8e326f60cd973c15 Mon Sep 17 00:00:00 2001 From: DerpyXD Date: Fri, 4 Sep 2020 15:18:32 -0300 Subject: [PATCH 1/3] added docs command --- src/commands/utility/docs.js | 24 ++++++++++++++++++++++++ src/locales/en-US/commands.json | 5 +++++ 2 files changed, 29 insertions(+) create mode 100644 src/commands/utility/docs.js diff --git a/src/commands/utility/docs.js b/src/commands/utility/docs.js new file mode 100644 index 000000000..e33ccb87a --- /dev/null +++ b/src/commands/utility/docs.js @@ -0,0 +1,24 @@ +const { Command } = require('../../') +const fetch = require('node-fetch') + +module.exports = class Docs extends Command { + constructor (client) { + super({ + name: 'docs', + category: 'utility', + parameters: [{ + type: 'string', + full: true, + missingError: 'commands:docs.noQueryProvided' + }] + }, client) + } + + async run ({ channel }, query) { + const queryParams = new URLSearchParams({ src: 'stable', q: query }) + const embed = await fetch(`https://djsdocs.sorta.moe/v2/embed?${queryParams.toString()}`) + .then(res => res.json()) + + channel.send({ embed }).then(() => channel.stopTyping()) + } +} diff --git a/src/locales/en-US/commands.json b/src/locales/en-US/commands.json index 528a453a2..ce8758191 100644 --- a/src/locales/en-US/commands.json +++ b/src/locales/en-US/commands.json @@ -14,6 +14,11 @@ "commandUsage": "", "noSentence": "You have to give me some text to reverse!" }, + "docs": { + "commandDescription": "Shows information from the discord.js documentation.", + "commandUsage": "", + "noQueryProvided": "You have to give me a search query!" + }, "hmmm": { "commandDescription": "Shows a random image from /r/hmmm." }, From ae4229c43fd7a8d9705d27e0bb150faae8eb88e4 Mon Sep 17 00:00:00 2001 From: DerpyXD Date: Sun, 6 Sep 2020 20:59:45 -0300 Subject: [PATCH 2/3] command name changed, command aliases and sources documentation added --- src/commands/utility/djsdocs.js | 35 +++++++++++++++++++++++++++++++++ src/commands/utility/docs.js | 24 ---------------------- 2 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 src/commands/utility/djsdocs.js delete mode 100644 src/commands/utility/docs.js diff --git a/src/commands/utility/djsdocs.js b/src/commands/utility/djsdocs.js new file mode 100644 index 000000000..8aa004d04 --- /dev/null +++ b/src/commands/utility/djsdocs.js @@ -0,0 +1,35 @@ +const { Command } = require('../..') +const fetch = require('node-fetch') +const VALID_SOURCES = ['stable', 'master', 'commando', 'rpc', 'akairo-master', 'collection'] + +module.exports = class Docs extends Command { + constructor (client) { + super({ + name: 'djsdocs', + aliases: ['djdocs'], + category: 'utility', + parameters: [{ + type: 'string', + full: true, + clean: false, + missingError: 'commands:docs.noQueryProvided' + }, [{ + type: 'string', + name: 'source', + aliases: ['src'], + required: false + }]] + }, client) + } + + async run ({ channel, flags }, query) { + const { source } = flags + const src = VALID_SOURCES.includes(source) ? source : 'stable' + + const queryParams = new URLSearchParams({ src, q: query }) + const embed = await fetch(`https://djsdocs.sorta.moe/v2/embed?${queryParams.toString()}`) + .then(res => res.json()) + + channel.send({ embed }).then(() => channel.stopTyping()) + } +} diff --git a/src/commands/utility/docs.js b/src/commands/utility/docs.js deleted file mode 100644 index e33ccb87a..000000000 --- a/src/commands/utility/docs.js +++ /dev/null @@ -1,24 +0,0 @@ -const { Command } = require('../../') -const fetch = require('node-fetch') - -module.exports = class Docs extends Command { - constructor (client) { - super({ - name: 'docs', - category: 'utility', - parameters: [{ - type: 'string', - full: true, - missingError: 'commands:docs.noQueryProvided' - }] - }, client) - } - - async run ({ channel }, query) { - const queryParams = new URLSearchParams({ src: 'stable', q: query }) - const embed = await fetch(`https://djsdocs.sorta.moe/v2/embed?${queryParams.toString()}`) - .then(res => res.json()) - - channel.send({ embed }).then(() => channel.stopTyping()) - } -} From 28341b74247dc837a4cce2f9a8fa757d75a0a545 Mon Sep 17 00:00:00 2001 From: DerpyXD Date: Sun, 6 Sep 2020 21:07:22 -0300 Subject: [PATCH 3/3] "docs" changed to "djsdocs" in command class name and commands.json file --- src/commands/utility/djsdocs.js | 2 +- src/locales/en-US/commands.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/utility/djsdocs.js b/src/commands/utility/djsdocs.js index 8aa004d04..34d4ff7bf 100644 --- a/src/commands/utility/djsdocs.js +++ b/src/commands/utility/djsdocs.js @@ -2,7 +2,7 @@ const { Command } = require('../..') const fetch = require('node-fetch') const VALID_SOURCES = ['stable', 'master', 'commando', 'rpc', 'akairo-master', 'collection'] -module.exports = class Docs extends Command { +module.exports = class DjsDocs extends Command { constructor (client) { super({ name: 'djsdocs', diff --git a/src/locales/en-US/commands.json b/src/locales/en-US/commands.json index ce8758191..4dc80987a 100644 --- a/src/locales/en-US/commands.json +++ b/src/locales/en-US/commands.json @@ -14,7 +14,7 @@ "commandUsage": "", "noSentence": "You have to give me some text to reverse!" }, - "docs": { + "djsdocs": { "commandDescription": "Shows information from the discord.js documentation.", "commandUsage": "", "noQueryProvided": "You have to give me a search query!"