diff --git a/src/config.rs b/src/config.rs index 9320830f9d933801b383f04b4782afd10c7071fd..a854a7230fcab99ace0047da31f50f35e296e2d1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -36,12 +36,6 @@ pub struct UccbotConfig { pub bind_address: String, } -#[derive(Debug, Deserialize)] -pub struct UccbotSecrets { - pub ldap_pass: String, - pub discord_token: String, -} - pub fn ldap_bind_address() -> String { "ldaps://samson.ucc.asn.au:636".to_string() } @@ -59,6 +53,12 @@ impl UccbotConfig { } } +#[derive(Debug, Deserialize)] +pub struct UccbotSecrets { + pub ldap_pass: String, + pub discord_token: String, +} + pub type ReactRoleMap = IndexMap<String, id::RoleId>; #[derive(Debug, Deserialize, Clone)] diff --git a/src/ldap.rs b/src/ldap.rs index 1346ffc24bbaec0cff6dd7ede550cbf4cc1006ae..ee0deeeb25097d7624cf93045c642dae284c188e 100644 --- a/src/ldap.rs +++ b/src/ldap.rs @@ -30,7 +30,7 @@ pub fn ldap_search(username: &str) -> Option<LDAPUser> { .success() .expect("LDAP search error"); if rs.is_empty() { - return None; + return None } let result = SearchEntry::construct(rs[0].clone()).attrs; Some(LDAPUser { diff --git a/src/main.rs b/src/main.rs index 2486c3e798119ae609a16c4845963ca1316a43ba..e4ded92b0fe817fcbbc0f24822150738d21cdbfc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -130,7 +130,7 @@ impl EventHandler for Handler { Ok(message) => match get_message_type(&message) { MessageType::RoleReactMessage if add_reaction.user_id.0 != CONFIG.bot_id => { add_role_by_reaction(&ctx, message, add_reaction); - return; + return } _ if message.author.id.0 != CONFIG.bot_id || add_reaction.user_id == CONFIG.bot_id => @@ -146,7 +146,7 @@ impl EventHandler for Handler { "The logreact message {} just tried to use is too old", react_user.name ); - return; + return } info!( "The react {} just added is {:?}. In full: {:?}", @@ -172,7 +172,7 @@ impl EventHandler for Handler { Ok(message) => match get_message_type(&message) { MessageType::RoleReactMessage if removed_reaction.user_id != CONFIG.bot_id => { remove_role_by_reaction(&ctx, message, removed_reaction); - return; + return } _ if message.author.id.0 != CONFIG.bot_id || removed_reaction.user_id == CONFIG.bot_id => diff --git a/src/reaction_roles.rs b/src/reaction_roles.rs index f0f1b38b009b00eedde06b9fd25098e57fd7215a..fbc188d215de9e6b5ecaac0f972189923df17911 100644 --- a/src/reaction_roles.rs +++ b/src/reaction_roles.rs @@ -97,7 +97,7 @@ pub fn sync_all_role_reactions(ctx: &Context) { for react in &message.reactions { let react_as_string = get_string_from_react(&react.reaction_type); if mapping.contains_key(&react_as_string) { - continue; + continue } info!( " message #{}: Removing non-role react '{}'", diff --git a/src/token_management.rs b/src/token_management.rs index ff11f94b0c6889137862ac3cbd7f8d651073b4e2..f6d21f6caef515118fb40c45623721148272ce99 100644 --- a/src/token_management.rs +++ b/src/token_management.rs @@ -75,7 +75,7 @@ pub fn parse_token(discord_user: &User, encrypted_token: &str) -> Result<String, let token_username = token_components[2]; if token_discord_user != discord_user.id.0.to_string() { warn!("... attempt failed : DiscordID mismatch"); - return Err(TokenError::DiscordIdMismatch); + return Err(TokenError::DiscordIdMismatch) } let time_delta_seconds = Utc::now().timestamp() - token_timestamp.timestamp(); if time_delta_seconds > TOKEN_LIFETIME { @@ -83,7 +83,7 @@ pub fn parse_token(discord_user: &User, encrypted_token: &str) -> Result<String, "... attempt failed : token expired ({} seconds old)", time_delta_seconds ); - return Err(TokenError::TokenExpired); + return Err(TokenError::TokenExpired) } info!( "... verification successful (token {} seconds old)", diff --git a/src/user_management.rs b/src/user_management.rs index 5e3c1f2782b26171538b1f126cf0497a8cab5f51..2b09045831c214052170065204ac2970ea000dc2 100644 --- a/src/user_management.rs +++ b/src/user_management.rs @@ -78,7 +78,7 @@ impl Commands { &ctx.http, format!("Usage: {}register <username>", CONFIG.command_prefix) ); - return; + return } if RESERVED_NAMES.contains(&account_name) || database::username_exists(account_name) { send_message!( @@ -88,7 +88,7 @@ impl Commands { .choose(&mut rand::thread_rng()) .expect("We couldn't get any sass") ); - return; + return } if !ldap_exists(account_name) { send_message!( @@ -99,7 +99,7 @@ impl Commands { account_name ) ); - return; + return } send_message!( msg.channel_id, @@ -200,7 +200,7 @@ impl Commands { &ctx.http, "Sorry, I couldn't find that profile (you need to !register for a profile)" ); - return; + return } let member = possible_member.unwrap(); let result = msg.channel_id.send_message(&ctx.http, |m| { @@ -272,7 +272,7 @@ impl Commands { m }) .expect("Failed to send usage help embed"); - return; + return } let info_content: Vec<_> = info.splitn(2, ' ').collect(); let mut property = String::from(info_content[0]); @@ -316,7 +316,7 @@ impl Commands { m }) .expect("Failed to send usage embed"); - return; + return } let mut value = info_content[1].to_string(); @@ -333,7 +333,7 @@ impl Commands { &ctx.http, "That ain't a URL where I come from..." ); - return; + return } } } diff --git a/src/voting.rs b/src/voting.rs index 6d679612eed4150e7542545066464c614c6fc5d4..5f2e05f5a3ba52add0eeabf62cfc738f85b88872 100644 --- a/src/voting.rs +++ b/src/voting.rs @@ -15,7 +15,7 @@ impl Commands { let motion = content; if !motion.is_empty() { create_motion(&ctx, &msg, motion); - return; + return } send_message!( msg.channel_id, @@ -34,7 +34,7 @@ impl Commands { let topic = content; if !topic.is_empty() { create_poll(&ctx, &msg, topic); - return; + return } send_message!( msg.channel_id, @@ -193,7 +193,7 @@ fn get_cached_motion(ctx: &Context, msg: &Message) -> MotionInfo { fn set_cached_motion(id: serenity::model::id::MessageId, motion_info: MotionInfo) { if let Some(motion) = MOTIONS_CACHE.lock().unwrap().get_mut(&id) { *motion = motion_info; - return; + return } warn!("{}", "Couldn't find motion in cache to set"); } @@ -208,7 +208,7 @@ macro_rules! tiebreaker { } else { 0.0 } - }; + } } fn update_motion( @@ -225,10 +225,8 @@ fn update_motion( let abstain_votes = motion_info.votes.get(&CONFIG.abstain_vote).unwrap().len() as isize - 1; let for_strength = for_votes as f32 + tiebreaker!(ctx, &CONFIG.for_vote, motion_info); - let against_strength = - against_votes as f32 + tiebreaker!(ctx, &CONFIG.against_vote, motion_info); - let abstain_strength = - abstain_votes as f32 + tiebreaker!(ctx, &CONFIG.abstain_vote, motion_info); + let against_strength = against_votes as f32 + tiebreaker!(ctx, &CONFIG.against_vote, motion_info); + let abstain_strength = abstain_votes as f32 + tiebreaker!(ctx, &CONFIG.abstain_vote, motion_info); let old_embed = msg.embeds[0].clone(); let topic = old_embed.clone().title.unwrap();