add ip opt for ban
This commit is contained in:
parent
958a6718eb
commit
9ff3aad199
1 changed files with 9 additions and 2 deletions
|
|
@ -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}"));
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue