From f3ef03a418279b789e6546c4e116ab8d38754adf Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Tue, 17 Sep 2024 22:11:34 +0100 Subject: [PATCH] fmt: fmt and clippy --- src/commands/add_server.rs | 86 +++++++++++++++++++------------------- src/lib.rs | 7 +--- src/main.rs | 10 ++--- 3 files changed, 49 insertions(+), 54 deletions(-) diff --git a/src/commands/add_server.rs b/src/commands/add_server.rs index 0d5d03b..9a50608 100644 --- a/src/commands/add_server.rs +++ b/src/commands/add_server.rs @@ -51,30 +51,28 @@ pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> Stri } }; - let bot_channel_id = if let CommandDataOptionValue::Channel(channel) = command - .data - .options - .get(3) - .expect("Expected channel option") - .resolved - .as_ref() - .expect("Expected channel object") + .data + .options + .get(3) + .expect("Expected channel option") + .resolved + .as_ref() + .expect("Expected channel object") { channel.id.to_owned() } else { return "Please provide a valid channel for ``Bot Channel``".to_string(); }; - let server_name = if let CommandDataOptionValue::String(name) = command - .data - .options - .get(4) - .expect("Expected Server Name option") - .resolved - .as_ref() - .expect("Expected Server Name object") + .data + .options + .get(4) + .expect("Expected Server Name option") + .resolved + .as_ref() + .expect("Expected Server Name object") { name } else { @@ -82,13 +80,13 @@ pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> Stri }; let wolves_link = if let CommandDataOptionValue::String(wolves) = command - .data - .options - .get(5) - .expect("Expected Wolves Link option") - .resolved - .as_ref() - .expect("Expected Server Name object") + .data + .options + .get(5) + .expect("Expected Wolves Link option") + .resolved + .as_ref() + .expect("Expected Server Name object") { wolves } else { @@ -149,27 +147,27 @@ pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicatio .kind(CommandOptionType::Role) .required(false) }) - .create_option(|option| { - option - .name("bot_channel") - .description("Safe space for folks to use the bot commands.") - .kind(CommandOptionType::Channel) - .required(true) - }) - .create_option(|option| { - option - .name("server_name") - .description("Name of the Discord Server.") - .kind(CommandOptionType::String) - .required(true) - }) - .create_option(|option| { - option - .name("wolves_link") - .description("Link to the Club/Society on UL Wolves.") - .kind(CommandOptionType::String) - .required(true) - }) + .create_option(|option| { + option + .name("bot_channel") + .description("Safe space for folks to use the bot commands.") + .kind(CommandOptionType::Channel) + .required(true) + }) + .create_option(|option| { + option + .name("server_name") + .description("Name of the Discord Server.") + .kind(CommandOptionType::String) + .required(true) + }) + .create_option(|option| { + option + .name("wolves_link") + .description("Link to the Club/Society on UL Wolves.") + .kind(CommandOptionType::String) + .required(true) + }) } async fn add_server(db: &Pool, ctx: &Context, server: &Servers) -> Result, Error> { diff --git a/src/lib.rs b/src/lib.rs index 466ab41..abfc829 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use serenity::{ model::{ guild, - id::{GuildId, RoleId, ChannelId}, + id::{ChannelId, GuildId, RoleId}, }, prelude::TypeMapKey, }; @@ -255,7 +255,7 @@ impl<'r> FromRow<'r, SqliteRow> for Servers { Ok(x) => { let tmp: i64 = x; RoleId::from(tmp as u64) - } + } _ => RoleId::from(0u64), }; @@ -409,13 +409,11 @@ pub mod set_roles { } } - if !member.roles.contains(role_current) { roles_set[1] += 1; roles.push(role_current.to_owned()); } - if let Err(e) = member.add_roles(ctx, &roles).await { println!("{:?}", e); } @@ -428,7 +426,6 @@ pub mod set_roles { } } - if member.roles.contains(role_current) { roles_set[2] += 1; // if theya re not a current member and have the role then remove it diff --git a/src/main.rs b/src/main.rs index 064b780..316f31e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,11 +55,11 @@ impl EventHandler for Handler { Welcome {} to the {} server! Sign up on [UL Wolves]({}) and go to https://discord.com/channels/{}/{} and use ``/link_wolves`` to get full access. "#, - new_member.display_name(), - &config.server_name, - &config.wolves_link, - &config.server, - &config.bot_channel_id + new_member.display_name(), + &config.server_name, + &config.wolves_link, + &config.server, + &config.bot_channel_id ); // let msg = format!( // "Welcome {} to the {} server! \n\