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...`);
|
const modifyingPropertyResponse = await this.loading(message.channel, `Modifying \`${property}\` of \`${account.username}\`'s account...`);
|
||||||
try {
|
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(' ')]);
|
.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 -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({
|
await account.updateOne({
|
||||||
username: value,
|
username: value,
|
||||||
homepath: `/home/${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(' ')]);
|
.run(message, [value, ...`Your username has been successfully changed. Remember to use \`ssh ${value}@cloud.libraryofcode.org\` when logging in.`.split(' ')]);
|
||||||
} catch (error) {
|
} 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(' ')]);
|
.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.');
|
this.error(message.channel, 'Failed to modify username.');
|
||||||
return this.client.util.handleError(error);
|
return this.client.util.handleError(error);
|
||||||
|
} finally {
|
||||||
|
await this.client.util.exec(`unlock ${account.username}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
modifyingPropertyResponse.delete();
|
modifyingPropertyResponse.delete();
|
||||||
|
|
Loading…
Reference in New Issue