From 982814d99cd1c4e7d80d4182e4b88eab28f0cd39 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Sat, 31 Aug 2024 19:21:58 +0100 Subject: [PATCH] fmt: fmt and clippy --- src/commands/committee.rs | 52 +++++++++++++++++++++------------------ src/commands/mod.rs | 2 +- src/lib.rs | 1 - 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/commands/committee.rs b/src/commands/committee.rs index 0702a0e..3de0ec9 100644 --- a/src/commands/committee.rs +++ b/src/commands/committee.rs @@ -16,11 +16,10 @@ use serenity::{ use skynet_discord_bot::{random_string, Config, DataBase}; use sqlx::{Pool, Sqlite}; - pub mod link { + use super::*; use serenity::model::id::GuildId; use skynet_discord_bot::Committee; - use super::*; pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> String { let committee_server = GuildId(1220150752656363520); @@ -35,15 +34,14 @@ pub mod link { } } - let option = command - .data - .options - .first() - .expect("Expected email option") - .resolved - .as_ref() - .expect("Expected email object"); + .data + .options + .first() + .expect("Expected email option") + .resolved + .as_ref() + .expect("Expected email object"); let email = if let CommandDataOptionValue::String(email) = option { email.trim() @@ -56,7 +54,6 @@ pub mod link { return "Please use a @ulwolves.ie address you have access to.".to_string(); } - let db_lock = { let data_read = ctx.data.read().await; data_read.get::().expect("Expected Databse in TypeMap.").clone() @@ -77,7 +74,6 @@ pub mod link { return "Linking already in process, please check email.".to_string(); } - // generate a auth key let auth = random_string(20); match send_mail(&config, email, &auth, &command.user.name) { @@ -99,7 +95,13 @@ pub mod link { command .name("link_committee") .description("Verify you are a committee member") - .create_option(|option| option.name("email").description("UL Wolves Committee Email").kind(CommandOptionType::String).required(true)) + .create_option(|option| { + option + .name("email") + .description("UL Wolves Committee Email") + .kind(CommandOptionType::String) + .required(true) + }) } pub async fn get_server_member_discord(db: &Pool, user: &UserId) -> Option { @@ -206,11 +208,11 @@ pub mod link { } pub mod verify { - use serenity::model::id::{GuildId, RoleId}; use super::*; - use crate::commands::committee::link::{get_verify_from_db}; + use crate::commands::committee::link::get_verify_from_db; + use serenity::model::id::{GuildId, RoleId}; use serenity::model::user::User; - use skynet_discord_bot::{Committee}; + use skynet_discord_bot::Committee; use sqlx::Error; pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> String { @@ -272,13 +274,16 @@ pub mod verify { } pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand { - command.name("verify_committee").description("Verify Wolves Committee Email").create_option(|option| { - option - .name("code") - .description("Code from verification email") - .kind(CommandOptionType::String) - .required(true) - }) + command + .name("verify_committee") + .description("Verify Wolves Committee Email") + .create_option(|option| { + option + .name("code") + .description("Code from verification email") + .kind(CommandOptionType::String) + .required(true) + }) } async fn set_discord(db: &Pool, discord: &UserId) -> Result, Error> { @@ -303,5 +308,4 @@ pub mod verify { } } } - } diff --git a/src/commands/mod.rs b/src/commands/mod.rs index c95bf66..3acfe81 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,4 +1,4 @@ pub mod add_server; +pub mod committee; pub mod link_email; pub mod minecraft; -pub mod committee; diff --git a/src/lib.rs b/src/lib.rs index 20fcb46..cc8f7f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -218,7 +218,6 @@ impl<'r> FromRow<'r, SqliteRow> for WolvesVerify { } } - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Committee { pub email: String,