diff --git a/src/command/ban.rs b/src/command/ban.rs new file mode 100644 index 0000000..cb18e91 --- /dev/null +++ b/src/command/ban.rs @@ -0,0 +1,26 @@ +#[derive(Default)] +pub struct BanCommand { + target: Option, + reason: Option +} + +impl BanCommand { + pub fn target(mut self, target: super::Selector) -> Self { + self.target = Some(target); + self + } + + pub fn reason(mut self, reason: impl Into) -> Self { + self.reason = Some(reason.into()); + self + } + + pub fn build(self) -> super::Command { + let target = self.target.unwrap_or(super::Selector::Player("nonexistent".to_string())); + let mut s = format!("ban {target}"); + if let Some(reason) = self.reason { + s.push_str(&format!(" {reason}")); + }; + super::Command(s) + } +} \ No newline at end of file