diff --git a/src/commands/management.rs b/src/commands/management.rs index 975949a..d161105 100644 --- a/src/commands/management.rs +++ b/src/commands/management.rs @@ -34,7 +34,7 @@ impl Command for RegisterCommand { } async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult { - if let Some(_) = ctx.db.get_user(ctx.username).await? { + if ctx.account.is_registered() { return Err(ExecutionError(BotError::AccountAlreadyExists)); } @@ -46,6 +46,7 @@ impl Command for RegisterCommand { }; ctx.db.upsert_user(&user).await?; + Execution::success(format!( "User account {} registered for bot commands.", ctx.username diff --git a/src/models.rs b/src/models.rs index 2da71dc..c185424 100644 --- a/src/models.rs +++ b/src/models.rs @@ -42,6 +42,11 @@ pub enum Account { } impl Account { + /// Whether or not this account is a registered user account. + pub fn is_registered(&self) -> bool { + matches!(self, Self::Registered(_)) + } + /// Gets the account status. For registered users, this is their /// actual account status (fully registered or awaiting /// activation). For transient users, this is