Fix small bugs
This commit is contained in:
parent
50acd4dc88
commit
bbcdf324b1
15
src/bot.rs
15
src/bot.rs
@ -94,13 +94,26 @@ pub async fn process_command(
|
|||||||
segments.remove(0);
|
segments.remove(0);
|
||||||
let return_value = match command {
|
let return_value = match command {
|
||||||
Command::Help => {
|
Command::Help => {
|
||||||
|
let mut page = 1;
|
||||||
|
if segments.len() > 0 {
|
||||||
|
page = segments[0].parse().unwrap_or(1)
|
||||||
|
}
|
||||||
|
|
||||||
let mut commands = Vec::new();
|
let mut commands = Vec::new();
|
||||||
for command in Command::iter() {
|
for command in Command::iter() {
|
||||||
if command != Command::Unknown {
|
if command != Command::Unknown {
|
||||||
commands.push(format!("{:?}", command));
|
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 => {
|
Command::BotStatus => {
|
||||||
let bot_status = state.bot_status.lock().unwrap().to_owned();
|
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,
|
Some(raw_entity) => raw_entity,
|
||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
};
|
};
|
||||||
|
let entity_type = &format!("{:?}", raw_entity.metadata)
|
||||||
|
.split("(")
|
||||||
|
.map(|item| item.to_owned())
|
||||||
|
.collect::<Vec<String>>()[0];
|
||||||
let entity = Entity {
|
let entity = Entity {
|
||||||
id: raw_entity.id,
|
id: raw_entity.id,
|
||||||
uuid: raw_entity.uuid.as_hyphenated().to_string(),
|
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();
|
let entity_position = raw_entity.pos();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user