From 6cbbab80bdffea76e3990948273e523c352dd727 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 6 May 2024 02:12:26 +0100 Subject: [PATCH] fmt: clippy and fmt --- src/bin/update_minecraft.rs | 3 +-- src/bin/update_users.rs | 2 +- src/commands/add_minecraft.rs | 6 +++--- src/commands/add_server.rs | 4 ++-- src/commands/link_email.rs | 4 ++-- src/lib.rs | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/bin/update_minecraft.rs b/src/bin/update_minecraft.rs index b63d8dd..3105167 100644 --- a/src/bin/update_minecraft.rs +++ b/src/bin/update_minecraft.rs @@ -1,5 +1,4 @@ -use skynet_discord_bot::set_roles::get_server_member_bulk; -use skynet_discord_bot::{db_init, get_config, get_server_config_bulk, update_server, whitelist_update, whitelist_wipe}; +use skynet_discord_bot::{db_init, get_config, get_server_config_bulk, update_server, whitelist_wipe}; #[tokio::main] async fn main() { diff --git a/src/bin/update_users.rs b/src/bin/update_users.rs index 34a0bc0..d46c0e5 100644 --- a/src/bin/update_users.rs +++ b/src/bin/update_users.rs @@ -59,6 +59,6 @@ async fn bulk_check(ctx: Arc) { let db = db_lock.read().await; for server_config in get_server_config_bulk(&db).await { - set_roles::update_server(&ctx, &server_config, &[], &vec![]).await; + set_roles::update_server(&ctx, &server_config, &[], &[]).await; } } diff --git a/src/commands/add_minecraft.rs b/src/commands/add_minecraft.rs index d0115b5..b22dfaa 100644 --- a/src/commands/add_minecraft.rs +++ b/src/commands/add_minecraft.rs @@ -48,7 +48,7 @@ pub(crate) mod user { let username = if let CommandDataOptionValue::String(username) = command .data .options - .get(0) + .first() .expect("Expected username option") .resolved .as_ref() @@ -147,7 +147,7 @@ pub(crate) mod server { let server_minecraft = if let CommandDataOptionValue::String(id) = command .data .options - .get(0) + .first() .expect("Expected server_id option") .resolved .as_ref() @@ -169,7 +169,7 @@ pub(crate) mod server { return "No existing server config, have you used ``/add``?".to_string(); } Some(mut x) => { - x.server_minecraft = server_minecraft.clone(); + x.server_minecraft.clone_from(&server_minecraft); x } }; diff --git a/src/commands/add_server.rs b/src/commands/add_server.rs index 49fcae3..cd66500 100644 --- a/src/commands/add_server.rs +++ b/src/commands/add_server.rs @@ -19,7 +19,7 @@ pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> Stri let api_key = if let CommandDataOptionValue::String(key) = command .data .options - .get(0) + .first() .expect("Expected user option") .resolved .as_ref() @@ -164,7 +164,7 @@ async fn add_server(db: &Pool, ctx: &Context, server: &Servers) -> Resul if past_remove { roles_remove.push(past_role) } - update_server(ctx, server, &roles_remove, &vec![]).await; + update_server(ctx, server, &roles_remove, &[]).await; } insert diff --git a/src/commands/link_email.rs b/src/commands/link_email.rs index f4441df..5a0fd26 100644 --- a/src/commands/link_email.rs +++ b/src/commands/link_email.rs @@ -44,7 +44,7 @@ pub mod link { let option = command .data .options - .get(0) + .first() .expect("Expected email option") .resolved .as_ref() @@ -258,7 +258,7 @@ pub mod verify { let option = command .data .options - .get(0) + .first() .expect("Expected code option") .resolved .as_ref() diff --git a/src/lib.rs b/src/lib.rs index c08f453..7ff2fd8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -345,7 +345,7 @@ pub fn random_string(len: usize) -> String { pub mod set_roles { use super::*; - pub async fn update_server(ctx: &Context, server: &Servers, remove_roles: &[Option], members_changed: &Vec) { + pub async fn update_server(ctx: &Context, server: &Servers, remove_roles: &[Option], members_changed: &[UserId]) { let db_lock = { let data_read = ctx.data.read().await; data_read.get::().expect("Expected Database in TypeMap.").clone()