diff --git a/src/commands/eris.ts b/src/commands/eris.ts new file mode 100644 index 0000000..f90b8ac --- /dev/null +++ b/src/commands/eris.ts @@ -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 '; + 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); + } + } +} diff --git a/src/commands/index.ts b/src/commands/index.ts index 92b76fc..0f3d8d9 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -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';