1
0
Fork 0
refactor/models
Matthew 2020-07-01 16:42:43 -04:00
parent 4bfee04aa2
commit ba0ac57000
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
4 changed files with 9 additions and 5 deletions

View File

@ -20,7 +20,7 @@ export default class SystemD_Restart extends Command {
message.delete(); message.delete();
return this.success(message.channel, 'Service restarted.'); return this.success(message.channel, 'Service restarted.');
} catch (err) { } catch (err) {
if (err.includes('not found')) return this.error(message.channel, 'Service not found.'); if (err.toString().includes('could not be found')) return this.error(message.channel, 'Service not found.');
return this.error(message.channel, err.toString()); return this.error(message.channel, err.toString());
} }
} catch (err) { } catch (err) {

View File

@ -20,7 +20,7 @@ export default class SystemD_Start extends Command {
message.delete(); message.delete();
return this.success(message.channel, 'Service started.'); return this.success(message.channel, 'Service started.');
} catch (err) { } catch (err) {
if (err.includes('not found')) return this.error(message.channel, 'Service not found.'); if (err.toString().includes('could not be found')) return this.error(message.channel, 'Service not found.');
return this.error(message.channel, err.toString()); return this.error(message.channel, err.toString());
} }
} catch (err) { } catch (err) {

View File

@ -15,8 +15,12 @@ export default class SystemD_Status extends Command {
if (!args[0]) return this.client.commands.get('help').run(message, ['systemd', this.name]); if (!args[0]) return this.client.commands.get('help').run(message, ['systemd', this.name]);
const account = await this.client.db.Account.findOne({ userID: message.author.id }).lean().exec(); 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.'); if (!account) return this.error(message.channel, 'You do not have a Cloud Services account.');
const cmd = await this.client.util.exec(`runuser ${account.username} -c 'DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/\${UID}/bus" systemctl --user status ${args[0]}'`); let cmd: string;
if (cmd.includes('could not be found')) return this.error(message.channel, 'The service name you provided doesn\'t exist.'); try {
cmd = await this.client.util.exec(`runuser ${account.username} -c 'DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/\${UID}/bus" systemctl --user status ${args[0]}'`);
} catch (err) {
if (err.toString().includes('could not be found')) return this.error(message.channel, 'The service name you provided doesn\'t exist.');
}
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setTitle(`SystemD Status | ${args[0]}`); embed.setTitle(`SystemD Status | ${args[0]}`);
embed.setDescription(`\`\`\`sh\n${cmd}\n\`\`\``); embed.setDescription(`\`\`\`sh\n${cmd}\n\`\`\``);

View File

@ -20,7 +20,7 @@ export default class SystemD_Stop extends Command {
message.delete(); message.delete();
return this.success(message.channel, 'Service stopped.'); return this.success(message.channel, 'Service stopped.');
} catch (err) { } catch (err) {
if (err.includes('not found')) return this.error(message.channel, 'Service not found.'); if (err.toString().includes('not found')) return this.error(message.channel, 'Service not found.');
return this.error(message.channel, err.toString()); return this.error(message.channel, err.toString());
} }
} catch (err) { } catch (err) {