fix: usermod command logistics
parent
7fd95aa586
commit
bef1f3e59f
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue