From bef1f3e59f13ebe859192c1b7d7fa85631ececea Mon Sep 17 00:00:00 2001 From: Hiroyuki Date: Sun, 12 Sep 2021 21:35:35 -0400 Subject: [PATCH] fix: usermod command logistics --- src/commands/usermod.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/commands/usermod.ts b/src/commands/usermod.ts index fd3c8e1..06eebfa 100644 --- a/src/commands/usermod.ts +++ b/src/commands/usermod.ts @@ -43,23 +43,26 @@ export default class Usermod extends Command { const modifyingPropertyResponse = await this.loading(message.channel, `Modifying \`${property}\` of \`${account.username}\`'s account...`); try { - await this.client.commands.get('lock') + await this.client.commands.get('notify') .run(message, [account.username, ...`Changing your username from \`${account.username}\` to \`${value}\`. DN/C`.split(' ')]); + await this.client.util.exec(`lock ${account.username}`); await this.client.util.exec(`usermod -l ${value} ${account.username}`); - await this.client.util.exec(`usermod -d /home/${value} ${account.username}`); + await this.client.util.exec(`usermod -d /home/${value} ${value}`); await account.updateOne({ username: value, homepath: `/home/${value}`, }); - await this.client.commands.get('unlock') + await this.client.commands.get('notify') .run(message, [value, ...`Your username has been successfully changed. Remember to use \`ssh ${value}@cloud.libraryofcode.org\` when logging in.`.split(' ')]); } catch (error) { - await this.client.commands.get('unlock') + await this.client.commands.get('notify') .run(message, [account.username, ...'Your username change was unsuccessful. Please contact a Technician for more details.'.split(' ')]); this.error(message.channel, 'Failed to modify username.'); return this.client.util.handleError(error); + } finally { + await this.client.util.exec(`unlock ${account.username}`); } modifyingPropertyResponse.delete();