mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 21:40:51 +02:00
Remove useless aliases, bug fixes
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const branches = ['stable', 'master', 'rpc', 'commando'];
|
||||
|
||||
module.exports = class DocsCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'docs',
|
||||
aliases: ['discord-js-docs', 'djs-docs', 'djs', 'discord-js'],
|
||||
group: 'search',
|
||||
memberName: '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 });
|
||||
if (!body) return msg.say('Could not find any results.');
|
||||
return msg.embed(body);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user