mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +02:00
Discord.js Docs Command
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
@@ -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
@@ -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": {
|
||||||
|
|||||||
Reference in New Issue
Block a user