Merge branch 'master' of gitlab.libraryofcode.org:engineering/cloudservices
commit
3a99c9efa4
|
@ -27,6 +27,7 @@ export default class Account extends Route {
|
|||
res.status(200).json({ code: this.constants.codes.SUCCESS, message: acc });
|
||||
} catch (error) {
|
||||
this.handleError(error, res);
|
||||
this.server.client.util.handleError(error);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -42,6 +43,7 @@ export default class Account extends Route {
|
|||
}
|
||||
} catch (error) {
|
||||
this.handleError(error, res);
|
||||
this.server.client.util.handleError(error);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -51,6 +53,7 @@ export default class Account extends Route {
|
|||
res.status(200).json({ code: this.constants.codes.SUCCESS, message: data });
|
||||
} catch (error) {
|
||||
this.handleError(error, res);
|
||||
this.server.client.util.handleError(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ export default class Root extends Route {
|
|||
res.status(200).json({ code: this.constants.codes.SUCCESS, message: response });
|
||||
} catch (error) {
|
||||
this.handleError(error, res);
|
||||
this.server.client.util.handleError(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ export { default as Pull } from './pull';
|
|||
export { default as Restart } from './restart';
|
||||
export { default as SecureSign } from './securesign';
|
||||
export { default as Sysinfo } from './sysinfo';
|
||||
export { default as Unban } from './unban';
|
||||
export { default as Unlock } from './unlock';
|
||||
export { default as Warn } from './warn';
|
||||
export { default as Whois } from './whois';
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
import { Message } from 'eris';
|
||||
import { Client } from '..';
|
||||
import { Command } from '../class';
|
||||
|
||||
export default class Unban extends Command {
|
||||
constructor(client: Client) {
|
||||
super(client);
|
||||
|
||||
this.name = 'unban';
|
||||
this.description = 'Unban an IP from Cloud/NGINX';
|
||||
this.aliases = ['unbanip'];
|
||||
this.usage = `${this.client.config.prefix}unban [service] [ip]`;
|
||||
this.permissions = { roles: ['455972169449734144', '643619219988152321'] };
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[1]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const msg = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Unbanning IP...***`);
|
||||
try {
|
||||
await this.client.util.exec(`sudo fail2ban-client set ${args[0]} unbanip ${args[1]}`);
|
||||
} catch (error) {
|
||||
if (error.message.includes('is not banned')) return msg.edit(`${this.client.stores.emojis.error} ***IP address not banned***`);
|
||||
if (error.message.includes(`'${args[0]}'`)) return msg.edit(`${this.client.stores.emojis.error} ***Invalid service***`);
|
||||
throw error;
|
||||
}
|
||||
|
||||
message.delete();
|
||||
return msg.edit(`${this.client.stores.emojis.success} ***IP address ${args[1]} unbanned from ${args[0].toUpperCase()}***`);
|
||||
} catch (error) {
|
||||
return this.client.util.handleError(error, message, this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ export default class Whois_User extends Command {
|
|||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
let account: AccountInterface;
|
||||
if (!args[0]) account = await this.client.db.Account.findOne({ userID: message.author.id });
|
||||
else account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0] }] });
|
||||
|
@ -45,5 +46,8 @@ export default class Whois_User extends Command {
|
|||
embed.setTimestamp();
|
||||
// @ts-ignore
|
||||
message.channel.createMessage({ embed });
|
||||
} catch (error) {
|
||||
this.client.util.handleError(error, message, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue