From a1c829d9d9ccf18f70431e0e64028da5e9bd6332 Mon Sep 17 00:00:00 2001 From: DataHearth Date: Fri, 23 Jun 2023 14:57:00 +0200 Subject: [PATCH] use find_one for auth search --- src/commands.rs | 2 +- src/database.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 8edbf89..4330ed3 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -157,7 +157,7 @@ pub async fn add_auth_user( #[description = "Discord user ID"] id: String, ) -> Result<(), Error> { if !std::env::var("ADMIN_USERS") - .expect("missing ADMIN_USERS") + .unwrap_or(String::new()) .contains(&ctx.author().id.to_string()) { ctx.say("You don't have permission to add a new user") diff --git a/src/database.rs b/src/database.rs index 8ab5806..2c482cf 100644 --- a/src/database.rs +++ b/src/database.rs @@ -90,8 +90,7 @@ pub fn is_auth_user(discord_id: String) -> Result { .get() .unwrap() .collection::("authorized_users") - .find(doc! { "$eq": [{"discord_id": discord_id}] }) + .find_one(doc! { "discord_id": discord_id }) .map_err(|err| Error::new(ErrorKind::InvalidInput, err))? - .next() .is_some()) }