diff --git a/src/bot.rs b/src/bot.rs index 6588e35..bfddc62 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -94,13 +94,26 @@ pub async fn process_command( segments.remove(0); let return_value = match command { Command::Help => { + let mut page = 1; + if segments.len() > 0 { + page = segments[0].parse().unwrap_or(1) + } + let mut commands = Vec::new(); for command in Command::iter() { if command != Command::Unknown { commands.push(format!("{:?}", command)); } } - return "Commands: ".to_owned() + &commands.join(", "); + + let start_index = (page - 1) * 10; + let end_index = page * 10; + if end_index >= commands.len() { + return format!("There are only {} pages!", commands.len() / 10); + } else { + let paged_commands = &commands[start_index..end_index]; + return format!("Commands (page {}): {}", page, paged_commands.join(", ")); + } } Command::BotStatus => { let bot_status = state.bot_status.lock().unwrap().to_owned(); diff --git a/src/main.rs b/src/main.rs index e0d42c7..d9707de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -325,10 +325,14 @@ async fn handle(mut client: Client, event: Event, mut state: State) -> anyhow::R Some(raw_entity) => raw_entity, None => return Ok(()), }; + let entity_type = &format!("{:?}", raw_entity.metadata) + .split("(") + .map(|item| item.to_owned()) + .collect::>()[0]; let entity = Entity { id: raw_entity.id, uuid: raw_entity.uuid.as_hyphenated().to_string(), - entity_type: format!("{:?}", raw_entity.metadata), + entity_type: entity_type.to_lowercase(), }; let entity_position = raw_entity.pos();