Add eris docs command

merge-requests/15/head
Bsian 2020-07-28 20:41:26 +01:00
parent 55e602d619
commit 600b9ab21d
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
2 changed files with 34 additions and 0 deletions

33
src/commands/eris.ts Normal file
View File

@ -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);
}
}
}

View File

@ -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';