Discord.js Docs Command

This commit is contained in:
Dragon Fire
2018-07-27 12:30:33 -04:00
parent 2d29d386c1
commit f6a1b8692e
3 changed files with 50 additions and 2 deletions
+2 -1
View File
@@ -15,7 +15,7 @@ Xiao is a Discord bot coded in JavaScript with
The bot is no longer available for invite. You can self-host the bot, or use her The bot is no longer available for invite. You can self-host the bot, or use her
on the [home server](https://discord.gg/sbMe32W). on the [home server](https://discord.gg/sbMe32W).
## Commands (297) ## Commands (298)
### Utility: ### Utility:
* **eval**: Executes JavaScript code. * **eval**: Executes JavaScript code.
@@ -119,6 +119,7 @@ on the [home server](https://discord.gg/sbMe32W).
* **danbooru**: Responds with an image from Danbooru, with optional query. * **danbooru**: Responds with an image from Danbooru, with optional query.
* **deviantart**: Responds with an image from a DeviantArt section, with optional query. * **deviantart**: Responds with an image from a DeviantArt section, with optional query.
* **dictionary**: Defines a word. * **dictionary**: Defines a word.
* **discord-js-docs**: Searches the Discord.js docs for your query.
* **eshop**: Searches the Nintendo eShop for your query. * **eshop**: Searches the Nintendo eShop for your query.
* **flickr**: Searches Flickr for your query. * **flickr**: Searches Flickr for your query.
* **forecast**: Responds with the seven-day forecast for a specific location. * **forecast**: Responds with the seven-day forecast for a specific location.
+47
View File
@@ -0,0 +1,47 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const branches = ['stable', 'master', 'rpc', 'commando'];
module.exports = class DiscordJSDocsCommand extends Command {
constructor(client) {
super(client, {
name: 'discord-js-docs',
aliases: ['djs-docs', 'docs', 'djs', 'discord-js'],
group: 'search',
memberName: 'discord-js-docs',
description: 'Searches the Discord.js docs for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What would you like to search the docs for?',
type: 'string',
parse: query => query.toLowerCase()
}
]
});
}
async run(msg, { query }) {
let project = 'main';
let branch = query.split(' ');
if (branches.includes(branch[0])) {
query = branch.slice(1).join(' ');
branch = branch[0];
} else {
branch = 'master';
}
if (branch === 'commando' || branch === 'rpc') {
project = branch;
branch = 'master';
}
try {
const { body } = await request
.get(`https://djsdocs.sorta.moe/${project}/${branch}/embed`)
.query({ q: query });
return msg.embed(body);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xiao", "name": "xiao",
"version": "85.7.1", "version": "85.8.0",
"description": "Your personal server companion.", "description": "Your personal server companion.",
"main": "Xiao.js", "main": "Xiao.js",
"scripts": { "scripts": {