clove/allInOne
src/commands/switch/mod.rs
// src/commands/switch/mod.rs
use crate::{Bot, proxy};
impl Bot {
pub(super) async fn switch(&self, args: &[String]) -> String {
if args.is_empty() {
return self.command_text("Use `{prefix}switch <member>`, like `{prefix}switch c1`, several like `{prefix}sw c1 c2`, or `{prefix}sw out`.");
}
if args == ["out"] {
return match self.switch_front(&[]).await {
Ok(()) => "Switched out. Nobody is fronting.".into(),
Err(problem) => problem,
};
}
let found = match self.command_members(args).await {
Ok(found) => found,
Err(problem) => return problem,
};
let ids = found
.iter()
.map(|member| member.id.as_str())
.collect::<Vec<_>>();
match self.switch_front(&ids).await {
Ok(()) => {
let speakers = found.iter().collect::<Vec<_>>();
format!("Switched in **{}**.", proxy::webhook_name(&speakers, None))
}
Err(problem) => problem,
}
}
}