Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/commands/utility/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { Command } = require('../../')
const fetch = require('node-fetch')

module.exports = class Docs extends Command {
constructor (client) {
super({
name: 'docs',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be djsdocs and aliases like djdocs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I'd say use "discordjs" as the main name and have a few derivatives from it, like "djsdocs", etc. Never just "docs", because we'll surely have docs commands for other things in the future.

category: 'utility',
parameters: [{
type: 'string',
full: true,
missingError: 'commands:docs.noQueryProvided'
}]
}, client)
}

async run ({ channel }, query) {
const queryParams = new URLSearchParams({ src: 'stable', q: query })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if i dont want search in the stable branch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to hop in and suggest using a flag like --branch to choose a branch.

const embed = await fetch(`https://djsdocs.sorta.moe/v2/embed?${queryParams.toString()}`)
.then(res => res.json())

channel.send({ embed }).then(() => channel.stopTyping())
}
}
5 changes: 5 additions & 0 deletions src/locales/en-US/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"commandUsage": "<text>",
"noSentence": "You have to give me some text to reverse!"
},
"docs": {
"commandDescription": "Shows information from the discord.js documentation.",
"commandUsage": "<query>",
"noQueryProvided": "You have to give me a search query!"
},
"hmmm": {
"commandDescription": "Shows a random image from /r/hmmm."
},
Expand Down