Fix small bugs

This commit is contained in:
ErrorNoInternet 2023-01-13 17:25:52 +08:00
parent 50acd4dc88
commit bbcdf324b1
Signed by untrusted user who does not match committer: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3
2 changed files with 19 additions and 2 deletions

@ -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();

@ -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::<Vec<String>>()[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();