Fix large guild display
This commit is contained in:
parent
a7290926db
commit
8880d5290b
30
src/main.rs
30
src/main.rs
@ -47,7 +47,6 @@ impl EventHandler for Handler {
|
||||
fn wc_guild(msg: Message) {
|
||||
let guild = &msg.content[9..];
|
||||
|
||||
|
||||
let guild = if guild.len() <= 3 {
|
||||
let guild = wynncraft::guild_by_prefix(guild).unwrap().unwrap();
|
||||
wynncraft::guild(&guild.name).unwrap()
|
||||
@ -61,16 +60,18 @@ fn wc_guild(msg: Message) {
|
||||
let territories: Value = serde_json::from_reader(resp).unwrap();
|
||||
|
||||
let mut message = String::new();
|
||||
let mut territories_count = 0;
|
||||
for value in territories.get("territories").unwrap().as_object().unwrap().values() {
|
||||
if value.get("guild").unwrap().as_str().unwrap() == guild.name {
|
||||
message.push_str(&format!("
|
||||
**Territory**: {}",
|
||||
value.get("territory").unwrap().as_str().unwrap()
|
||||
))
|
||||
));
|
||||
territories_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
msg.channel_id.say(
|
||||
if let Err(_) = msg.channel_id.say(
|
||||
format!(
|
||||
"**Guild**: {}
|
||||
**prefix**: {}
|
||||
@ -83,12 +84,33 @@ fn wc_guild(msg: Message) {
|
||||
guild.level,
|
||||
guild.members.len()
|
||||
) + &message
|
||||
).unwrap();
|
||||
) {
|
||||
msg.channel_id.say(
|
||||
format!(
|
||||
"**Guild**: {}
|
||||
**prefix**: {}
|
||||
**Created**: {}
|
||||
**Level**: {}
|
||||
**Members**: {}
|
||||
**Territories**: {}",
|
||||
guild.name,
|
||||
guild.prefix,
|
||||
guild.created_friendly,
|
||||
guild.level,
|
||||
guild.members.len(),
|
||||
territories_count
|
||||
)
|
||||
).unwrap();
|
||||
};
|
||||
}
|
||||
|
||||
fn wc_topguilds(msg: Message) {
|
||||
let limit: usize = msg.content[13..].parse().unwrap();
|
||||
|
||||
wc_topguilds_limit(msg, limit);
|
||||
}
|
||||
|
||||
fn wc_topguilds_limit(msg: Message, limit: usize) {
|
||||
let leaderboard = wynncraft::guild_leaderboard().unwrap();
|
||||
|
||||
let mut text = "```".to_owned();
|
||||
|
Loading…
Reference in New Issue
Block a user