fix(usermod): misc
parent
669d9d0fef
commit
578aa0db8c
|
@ -44,7 +44,7 @@ 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('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}\`.`.split(' ')]);
|
||||
if (!account.locked) {
|
||||
await account.updateOne({ locked: true });
|
||||
await this.client.util.exec(`lock ${account.username}`);
|
||||
|
@ -57,7 +57,13 @@ export default class Usermod extends Command {
|
|||
username: value,
|
||||
homepath: `/home/${value}`,
|
||||
});
|
||||
await this.client.db.Moderation.updateMany({ username: account.username }, { username: value });
|
||||
await this.client.db.Moderation.updateMany(
|
||||
{
|
||||
username: account.username,
|
||||
date: { $gt: account.createdAt },
|
||||
},
|
||||
{ username: value },
|
||||
);
|
||||
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) {
|
||||
|
@ -66,9 +72,11 @@ export default class Usermod extends Command {
|
|||
await this.client.util.handleError(error);
|
||||
return this.error(message.channel, 'Failed to modify username. Please check <#595788220764127272> for more information.');
|
||||
} finally {
|
||||
if (!account.locked) {
|
||||
await this.client.util.exec(`unlock ${account.username}`);
|
||||
await account.updateOne({ locked: false });
|
||||
}
|
||||
}
|
||||
|
||||
modifyingPropertyResponse.delete();
|
||||
this.success(message.channel, 'Successfully modified username.');
|
||||
|
|
Loading…
Reference in New Issue