diff --git a/src/commands/usermod.ts b/src/commands/usermod.ts index 06eebfa..d8e6c0d 100644 --- a/src/commands/usermod.ts +++ b/src/commands/usermod.ts @@ -45,7 +45,10 @@ export default class Usermod extends Command { try { 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}`); + if (!account.locked) { + await account.updateOne({ locked: true }); + 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} ${value}`); @@ -59,10 +62,13 @@ export default class Usermod extends Command { } catch (error) { 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); + await this.client.util.handleError(error); + return this.error(message.channel, 'Failed to modify username. Please check <#595788220764127272> for more information.'); } finally { - await this.client.util.exec(`unlock ${account.username}`); + if (account.locked) { + await this.client.util.exec(`unlock ${account.username}`); + await account.updateOne({ locked: false }); + } } modifyingPropertyResponse.delete();