1
0
Fork 0

fix: usermod command logistics

master
Hiroyuki 2021-09-12 21:35:35 -04:00
parent 7fd95aa586
commit bef1f3e59f
No known key found for this signature in database
GPG Key ID: AF65958B7B7362E6
1 changed files with 7 additions and 4 deletions

View File

@ -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();