Skip to content
Snippets Groups Projects
Unverified Commit f37c96d3 authored by tec's avatar tec
Browse files

Cope with users without avatars + minor log message reformatting

parent fabad29e
No related merge requests found
Pipeline #210 failed with stages
in 3 seconds
...@@ -78,7 +78,7 @@ impl Commands { ...@@ -78,7 +78,7 @@ impl Commands {
&ctx.http, &ctx.http,
format!("Usage: {}register <username>", CONFIG.command_prefix) format!("Usage: {}register <username>", CONFIG.command_prefix)
); );
return return;
} }
if RESERVED_NAMES.contains(&account_name) || database::username_exists(account_name) { if RESERVED_NAMES.contains(&account_name) || database::username_exists(account_name) {
send_message!( send_message!(
...@@ -88,7 +88,7 @@ impl Commands { ...@@ -88,7 +88,7 @@ impl Commands {
.choose(&mut rand::thread_rng()) .choose(&mut rand::thread_rng())
.expect("We couldn't get any sass") .expect("We couldn't get any sass")
); );
return return;
} }
if !ldap_exists(account_name) { if !ldap_exists(account_name) {
send_message!( send_message!(
...@@ -99,7 +99,7 @@ impl Commands { ...@@ -99,7 +99,7 @@ impl Commands {
account_name account_name
) )
); );
return return;
} }
send_message!( send_message!(
msg.channel_id, msg.channel_id,
...@@ -188,12 +188,12 @@ impl Commands { ...@@ -188,12 +188,12 @@ impl Commands {
} { } {
Ok(member) => Some(member), Ok(member) => Some(member),
Err(why) => { Err(why) => {
warn!("Could not find member {:?}", why); warn!("Could not find member {}, {:?}", &name, why);
if name.len() != 3 { if name.len() != 3 {
None None
} else { } else {
info!( info!(
"Searching for a profile for the TLA {}", "Searching for a profile for the TLA '{}'",
&name.to_uppercase() &name.to_uppercase()
); );
match database::get_member_info_from_tla(&name.to_uppercase()) { match database::get_member_info_from_tla(&name.to_uppercase()) {
...@@ -209,10 +209,10 @@ impl Commands { ...@@ -209,10 +209,10 @@ impl Commands {
&ctx.http, &ctx.http,
"Sorry, I couldn't find that profile (you need to !register for a profile)" "Sorry, I couldn't find that profile (you need to !register for a profile)"
); );
return return;
} }
let member = possible_member.unwrap(); let member = possible_member.unwrap();
info!("Found matching profile. UCC username: {}", &member.username); info!("Found matching profile, UCC username: {}", &member.username);
let result = msg.channel_id.send_message(&ctx.http, |m| { let result = msg.channel_id.send_message(&ctx.http, |m| {
m.embed(|embed| { m.embed(|embed| {
embed.colour(serenity::utils::Colour::LIGHTER_GREY); embed.colour(serenity::utils::Colour::LIGHTER_GREY);
...@@ -224,7 +224,7 @@ impl Commands { ...@@ -224,7 +224,7 @@ impl Commands {
f.text(&user.name); f.text(&user.name);
f.icon_url( f.icon_url(
user.static_avatar_url() user.static_avatar_url()
.expect("Expected user to have avatar"), .unwrap_or(String::from("https://www.ucc.asn.au/logos/ucc-logo.png")),
); );
f f
}); });
...@@ -282,7 +282,7 @@ impl Commands { ...@@ -282,7 +282,7 @@ impl Commands {
m m
}) })
.expect("Failed to send usage help embed"); .expect("Failed to send usage help embed");
return return;
} }
let info_content: Vec<_> = info.splitn(2, ' ').collect(); let info_content: Vec<_> = info.splitn(2, ' ').collect();
let mut property = String::from(info_content[0]); let mut property = String::from(info_content[0]);
...@@ -326,7 +326,7 @@ impl Commands { ...@@ -326,7 +326,7 @@ impl Commands {
m m
}) })
.expect("Failed to send usage embed"); .expect("Failed to send usage embed");
return return;
} }
let mut value = info_content[1].to_string(); let mut value = info_content[1].to_string();
...@@ -343,7 +343,7 @@ impl Commands { ...@@ -343,7 +343,7 @@ impl Commands {
&ctx.http, &ctx.http,
"That ain't a URL where I come from..." "That ain't a URL where I come from..."
); );
return return;
} }
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment