diff --git a/src/commands/systemd_restart.ts b/src/commands/systemd_restart.ts index 14428b9..3e3db9b 100644 --- a/src/commands/systemd_restart.ts +++ b/src/commands/systemd_restart.ts @@ -20,7 +20,7 @@ export default class SystemD_Restart extends Command { message.delete(); return this.success(message.channel, 'Service restarted.'); } 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()); } } catch (err) { diff --git a/src/commands/systemd_start.ts b/src/commands/systemd_start.ts index 2b57db9..1d6029f 100644 --- a/src/commands/systemd_start.ts +++ b/src/commands/systemd_start.ts @@ -20,7 +20,7 @@ export default class SystemD_Start extends Command { message.delete(); return this.success(message.channel, 'Service started.'); } 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()); } } catch (err) { diff --git a/src/commands/systemd_status.ts b/src/commands/systemd_status.ts index e789b9f..bf38471 100644 --- a/src/commands/systemd_status.ts +++ b/src/commands/systemd_status.ts @@ -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]); 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.'); - 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]}'`); - if (cmd.includes('could not be found')) return this.error(message.channel, 'The service name you provided doesn\'t exist.'); + let cmd: string; + 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(); embed.setTitle(`SystemD Status | ${args[0]}`); embed.setDescription(`\`\`\`sh\n${cmd}\n\`\`\``); diff --git a/src/commands/systemd_stop.ts b/src/commands/systemd_stop.ts index b7e4ef6..9bf44d0 100644 --- a/src/commands/systemd_stop.ts +++ b/src/commands/systemd_stop.ts @@ -20,7 +20,7 @@ export default class SystemD_Stop extends Command { message.delete(); return this.success(message.channel, 'Service stopped.'); } 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()); } } catch (err) {