Added reload command

merge-requests/1/merge
Bsian 2019-11-30 23:47:47 +00:00
parent a7966d7adb
commit ceb613c95f
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
2 changed files with 65 additions and 23 deletions

View File

@ -1,23 +1,24 @@
export { default as Announce } from './announce'; export { default as announce } from './announce';
export { default as Bearer } from './bearer'; export { default as bearer } from './bearer';
export { default as CreateAccount } from './createaccount'; export { default as createAccount } from './createaccount';
export { default as CWG } from './cwg'; export { default as cwg } from './cwg';
export { default as DeleteAccount } from './deleteaccount'; export { default as deleteaccount } from './deleteaccount';
export { default as Disk } from './disk'; export { default as disk } from './disk';
export { default as Eval } from './eval'; export { default as eval } from './eval';
export { default as Exec } from './exec'; export { default as exec } from './exec';
export { default as Help } from './help'; export { default as help } from './help';
export { default as Lock } from './lock'; export { default as load } from './load';
export { default as Modlogs } from './modlogs'; export { default as lock } from './lock';
export { default as Notify } from './notify'; export { default as modlogs } from './modlogs';
export { default as Parse } from './parse'; export { default as notify } from './notify';
export { default as Parseall } from './parseall'; export { default as parse } from './parse';
export { default as Ping } from './ping'; export { default as parseall } from './parseall';
export { default as Pull } from './pull'; export { default as ping } from './ping';
export { default as Restart } from './restart'; export { default as pull } from './pull';
export { default as SecureSign } from './securesign'; export { default as restart } from './restart';
export { default as Sysinfo } from './sysinfo'; export { default as securesign } from './securesign';
export { default as Unban } from './unban'; export { default as sysinfo } from './sysinfo';
export { default as Unlock } from './unlock'; export { default as unban } from './unban';
export { default as Warn } from './warn'; export { default as unlock } from './unlock';
export { default as Whois } from './whois'; export { default as warn } from './warn';
export { default as whois } from './whois';

41
src/commands/load.ts Normal file
View File

@ -0,0 +1,41 @@
import { Message } from 'eris';
import { Client } from '..';
import { Command } from '../class';
export default class Ping extends Command {
constructor(client: Client) {
super(client);
this.name = 'load';
this.description = '(Re)loads command, config or util';
this.aliases = ['reload'];
this.enabled = true;
}
public async run(message: Message, args: string[]) {
try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const allowed = ['config', 'util', 'command', 'function'];
const type = args[0].toLowerCase();
if (!allowed.includes(type)) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid type to (re)load***`);
const corepath = '/var/CloudServices/dist';
if (type === 'config') this.client.config = require(`${corepath}/config.json`);
else if (type === 'util') {
const Util = require(`${corepath}/class/Util`);
this.client.util = new Util(this.client);
} else {
try {
const Cmd = require(`${corepath}/commands`)[args[1]];
this.client.commands.remove(args[1]);
this.client.loadCommand(Cmd);
} catch (error) {
if (error.message.includes('Cannot find module')) return message.channel.createMessage(`${this.client.stores.emojis} ***Cannot find file***`);
throw error;
}
}
return message.channel.createMessage(`${this.client.stores.emojis.success} Reloaded ${type}`);
} catch (error) {
return this.client.util.handleError(error, message, this);
}
}
}