Add eris docs command
parent
55e602d619
commit
600b9ab21d
|
@ -0,0 +1,33 @@
|
|||
import { Message, EmbedOptions } from 'eris';
|
||||
import axios, { AxiosResponse, AxiosError } from 'axios';
|
||||
import { Client, Command, RichEmbed } from '../class';
|
||||
|
||||
export default class Eris extends Command {
|
||||
constructor(client: Client) {
|
||||
super(client);
|
||||
this.name = 'eris';
|
||||
this.description = 'Get information about Eris.';
|
||||
this.usage = 'eris <query>';
|
||||
this.permissions = 0;
|
||||
this.guildOnly = false;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
|
||||
let res: AxiosResponse<{embed: EmbedOptions}>;
|
||||
try {
|
||||
res = await axios.get('https://erisdocs.cloud.libraryofcode.org/docs', { params: { search: args[0] } });
|
||||
} catch (err) {
|
||||
if (err.code === 404) return this.error(message.channel, 'Could not find information. Try something else.');
|
||||
return this.error(message.channel, 'Please try again later, something unexpected happened.');
|
||||
}
|
||||
|
||||
return message.channel.createMessage(res.data);
|
||||
} catch (err) {
|
||||
return this.client.util.handleError(err, message, this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ export { default as delnote } from './delnote';
|
|||
export { default as delrank } from './delrank';
|
||||
export { default as delredirect } from './delredirect';
|
||||
export { default as djs } from './djs';
|
||||
export { default as eris } from './eris';
|
||||
export { default as eval } from './eval';
|
||||
export { default as game } from './game';
|
||||
export { default as help } from './help';
|
||||
|
|
Loading…
Reference in New Issue