diff --git a/src/commands/index.ts b/src/commands/index.ts index 13ec317..36aa044 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -1,31 +1,32 @@ -export { default as announce } from './announce'; -export { default as bearer } from './bearer'; -export { default as cloudflare } from './cloudflare'; -export { default as createaccount } from './createaccount'; -export { default as cwg } from './cwg'; -export { default as deleteaccount } from './deleteaccount'; -export { default as disk } from './disk'; -export { default as emailcode } from './emailcode'; -export { default as eval } from './eval'; -export { default as exec } from './exec'; -export { default as help } from './help'; -export { default as limits } from './limits'; -export { default as load } from './load'; -export { default as lock } from './lock'; -export { default as modlogs } from './modlogs'; -export { default as notify } from './notify'; -export { default as parse } from './parse'; -export { default as parseall } from './parseall'; -export { default as ping } from './ping'; -export { default as pull } from './pull'; -export { default as resetpassword } from './resetpassword'; -export { default as restart } from './restart'; -export { default as securesign } from './securesign'; -export { default as setlimit } from './setlimit'; -export { default as sysinfo } from './sysinfo'; -export { default as tier } from './tier'; -export { default as unban } from './unban'; -export { default as unlock } from './unlock'; -export { default as warn } from './warn'; -export { default as whois } from './whois'; -export { default as whoisold } from './whoisold'; +export { default as announce } from './announce'; +export { default as bearer } from './bearer'; +export { default as cloudflare } from './cloudflare'; +export { default as createaccount } from './createaccount'; +export { default as cwg } from './cwg'; +export { default as deleteaccount } from './deleteaccount'; +export { default as disk } from './disk'; +export { default as emailcode } from './emailcode'; +export { default as eval } from './eval'; +export { default as exec } from './exec'; +export { default as help } from './help'; +export { default as limits } from './limits'; +export { default as load } from './load'; +export { default as lock } from './lock'; +export { default as modlogs } from './modlogs'; +export { default as notify } from './notify'; +export { default as parse } from './parse'; +export { default as parseall } from './parseall'; +export { default as ping } from './ping'; +export { default as pull } from './pull'; +export { default as resetpassword } from './resetpassword'; +export { default as restart } from './restart'; +export { default as securesign } from './securesign'; +export { default as setlimit } from './setlimit'; +export { default as sysinfo } from './sysinfo'; +export { default as systemd } from './systemd'; +export { default as tier } from './tier'; +export { default as unban } from './unban'; +export { default as unlock } from './unlock'; +export { default as warn } from './warn'; +export { default as whois } from './whois'; +export { default as whoisold } from './whoisold'; diff --git a/src/commands/systemd.ts b/src/commands/systemd.ts new file mode 100644 index 0000000..643eb89 --- /dev/null +++ b/src/commands/systemd.ts @@ -0,0 +1,23 @@ +import { Message } from 'eris'; +import { Command } from '../class'; +import { Client } from '..'; +import SystemD_Linger from './systemd_linger'; + +export default class SystemD extends Command { + constructor(client: Client) { + super(client); + this.name = 'systemd'; + this.description = 'Manages various aspects for your user SystemD.'; + this.usage = `Run ${this.client.config.prefix}${this.name} [subcommand] for usage information`; + this.subcmds = [SystemD_Linger]; + this.enabled = true; + } + + public run(message: Message) { + try { + return this.client.commands.get('help').run(message, [this.name]); + } catch (error) { + return this.client.util.handleError(error, message, this); + } + } +} diff --git a/src/commands/systemd_linger.ts b/src/commands/systemd_linger.ts new file mode 100644 index 0000000..2235ec7 --- /dev/null +++ b/src/commands/systemd_linger.ts @@ -0,0 +1,37 @@ +/* eslint-disable consistent-return */ +import { Message } from 'eris'; +import { Command } from '../class'; +import { Client } from '..'; + +export default class SystemdD_Linger extends Command { + constructor(client: Client) { + super(client); + this.name = 'linger'; + this.description = 'Enables login linger for your user, this means your SystemD services will start on reboot.'; + this.usage = `${this.client.config.prefix}systemd linger `; + 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 account = await this.client.db.Account.findOne({ userID: message.author.id }).lean().exec(); + if (!account) return this.error(message.channel, 'You do not have a Cloud Services account.'); + switch (args[0]) { + case 'enable': + await this.client.util.exec(`loginctl enable-linger ${account.username}`); + this.success(message.channel, 'Successfully activated SystemdD linger.'); + break; + case 'disable': + await this.client.util.exec(`loginctl disable-linger ${account.username}`); + this.success(message.channel, 'Successfully deactivated SystemD linger.'); + break; + default: + this.error(message.channel, 'Invalid argument provided.'); + break; + } + } catch (err) { + this.client.util.handleError(err, message, this); + } + } +}