Support guild lookup by prefix

This commit is contained in:
Sakuhl 2018-01-02 00:24:48 +01:00
parent 2a2697b13f
commit 2b441f42c5
2 changed files with 8 additions and 2 deletions

2
Cargo.lock generated
View File

@ -1066,7 +1066,7 @@ dependencies = [
[[package]]
name = "wynncraft"
version = "0.1.0"
source = "git+https://gitlab.com/Sakuhl/wynncraft#b73034104c1bc02ec3bde74c6a1042943a61bab1"
source = "git+https://gitlab.com/Sakuhl/wynncraft#2a9a7d55e9b4d311b121f2ca330cc0fb9de7c723"
dependencies = [
"reqwest 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -44,8 +44,14 @@ impl EventHandler for Handler {
fn wc_guild(msg: Message) {
let guild = &msg.content[9..];
let guild = wynncraft::guild(guild).unwrap();
let guild = if guild.len() <= 3 {
let guild = wynncraft::guild_by_prefix(guild).unwrap().unwrap();
wynncraft::guild(&guild.name).unwrap()
} else {
wynncraft::guild(guild).unwrap()
};
let resp = reqwest::get("https://api.wynncraft.com/public_api.php?action=territoryList").unwrap();
assert!(resp.status().is_success());