add ip opt for ban

This commit is contained in:
Raptorox 2026-08-01 13:42:58 +02:00
parent 958a6718eb
commit 9ff3aad199
No known key found for this signature in database
GPG key ID: 8B3556FC3ED1F6D8

View file

@ -1,7 +1,8 @@
#[derive(Default)]
pub struct BanCommand {
target: Option<super::Selector>,
reason: Option<String>
reason: Option<String>,
ip: Option<bool>
}
impl BanCommand {
@ -15,9 +16,15 @@ impl BanCommand {
self
}
pub fn ip(mut self) -> Self {
self.ip = Some(true);
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}");
let ip = self.ip.unwrap_or(false);
let mut s = if ip { format!("ban-ip {target}") } else { format!("ban {target}") };
if let Some(reason) = self.reason {
s.push_str(&format!(" {reason}"));
};