Consider perfect matches first

This commit is contained in:
Sakuhl 2018-01-16 11:21:47 +01:00
parent e7d1b9c380
commit 6b035809ea

View File

@ -95,6 +95,11 @@ fn guild_by_prefix(prefix: &str) -> Result<Option<String>, Error> {
let guilds: Value = serde_json::from_str(&resp)?;
for guild in guilds.get("guilds").unwrap().as_array().unwrap() {
if guild.get("prefix").unwrap().as_str().unwrap() == prefix {
return Ok(Some(guild.get("name").unwrap().as_str().unwrap().to_owned()));
}
}
for guild in guilds.get("guilds").unwrap().as_array().unwrap() {
if guild.get("prefix").unwrap().as_str().unwrap().to_lowercase() == prefix.to_lowercase() {
return Ok(Some(guild.get("name").unwrap().as_str().unwrap().to_owned()));