From 958a6718ebf8910cacb7876cbdddf7c11ecad489 Mon Sep 17 00:00:00 2001 From: Raptorox <70806316+Raptorox@users.noreply.github.com> Date: Sat, 1 Aug 2026 13:40:59 +0200 Subject: [PATCH] add ban --- src/command/ban.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/command/ban.rs 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