bot: Move multi-failure response join() call into the format!().

This commit is contained in:
projectmoon 2021-02-07 21:42:32 +00:00
parent 304c91c69d
commit b0707dff05
1 changed files with 3 additions and 4 deletions

View File

@ -83,18 +83,17 @@ async fn handle_multiple_results(
let message = if errors.len() == 0 { let message = if errors.len() == 0 {
format!("{}: Executed {} commands", respond_to, results.len()) format!("{}: Executed {} commands", respond_to, results.len())
} else { } else {
let failures: String = errors let failures: Vec<String> = errors
.iter() .iter()
.map(|&(cmd, err)| format!("<strong>{}:</strong> {}", cmd, err)) .map(|&(cmd, err)| format!("<strong>{}:</strong> {}", cmd, err))
.collect::<Vec<_>>() .collect();
.join("\n");
format!( format!(
"{}: Executed {} commands ({} failed)\n\nFailures:\n{}", "{}: Executed {} commands ({} failed)\n\nFailures:\n{}",
respond_to, respond_to,
results.len(), results.len(),
errors.len(), errors.len(),
failures failures.join("\n")
) )
.replace("\n", "<br/>") .replace("\n", "<br/>")
}; };