Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

added discordjs docs command #1164

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
35 changes: 35 additions & 0 deletions src/commands/utility/djsdocs.js
Original file line number Diff line number Diff line change
@@ -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 DjsDocs 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())
}
}
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!"
},
"djsdocs": {
"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