Added command

merge-requests/1/merge
Bsian 2019-11-21 14:35:21 +00:00
parent b623654412
commit 7316b62282
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
2 changed files with 36 additions and 0 deletions

View File

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

35
src/commands/unban.ts Normal file
View File

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