11import { Message } from "discord.js" ;
22import { Command } from "discord-akairo" ;
33import fetch from "node-fetch" ;
4- import * as qs from "querystring" ;
4+ import { stringify } from "querystring" ;
55
66export default class DiscordCommand extends Command {
77 public constructor ( ) {
@@ -10,7 +10,7 @@ export default class DiscordCommand extends Command {
1010 description : {
1111 content : "Searches discord.js documentation for what it thinks you mean. Defaults to using the master branch" ,
1212 usage : "<query> <optional branch>" ,
13- examples : [ "Guild#Members" , "Guild#Members -branch stable " ] ,
13+ examples : [ "Guild#Members" , "Guild#Members master " ] ,
1414 } ,
1515 channel : "guild" ,
1616 clientPermissions : [ "EMBED_LINKS" ] ,
@@ -27,23 +27,23 @@ export default class DiscordCommand extends Command {
2727 } ,
2828 {
2929 id : "branch" ,
30- flag : [ "-b " , "--b " , "-branch " , "--branch " ] ,
31- match : "option" ,
30+ flag : [ "master" , "stable" ] ,
31+ match : "flag" ,
32+ default : "stable" ,
3233 } ,
3334 ] ,
3435 } ) ;
3536 }
3637
37- public async exec ( message : Message , { query, branch } ) : Promise < Message | Message [ ] > {
38+ public async exec ( message : Message , { query, branch } : { query : string ; branch : string } ) : Promise < Message | Message [ ] > {
3839 const str = query . split ( " " ) ;
3940
40- const source = branch == "stable" ? "stable" : "master" ;
41+ const source = branch ? "stable" : "master" ;
4142
4243 //src and q being the params accepted by the API
43- const queryString = qs . stringify ( { src : source , q : str . join ( " " ) } ) ;
44+ const queryString = stringify ( { src : source , q : str . join ( " " ) } ) ;
4445 const res = await fetch ( `https://djsdocs.sorta.moe/v2/embed?${ queryString } ` ) ;
4546 const embedObj = await res . json ( ) ;
46- console . log ( embedObj ) ;
4747
4848 if ( ! embedObj ) return ;
4949
0 commit comments