html terminal
Diffstat (limited to 'src/bot/bans.rs')
-rw-r--r--src/bot/bans.rs50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/bot/bans.rs b/src/bot/bans.rs
index 89266c6..aa11440 100644
--- a/src/bot/bans.rs
+++ b/src/bot/bans.rs
@@ -9,7 +9,7 @@ use crate::{return_next, send_ctx};
required_permissions = "ADMINISTRATOR",
default_member_permissions = "ADMINISTRATOR"
)]
-/// ban a player by uuid and ip
+/// ban a ingame player by uuid and ip
pub async fn add(
ctx: Context<'_>,
#[description = "player to ban"]
@@ -29,6 +29,54 @@ pub async fn add(
#[poise::command(
slash_command,
category = "Control",
+ required_permissions = "ADMINISTRATOR",
+ default_member_permissions = "ADMINISTRATOR"
+)]
+/// kick somebody off the server
+pub async fn kick(
+ ctx: Context<'_>,
+ #[description = "player to ban"]
+ #[autocomplete = "player::autocomplete"]
+ player: String,
+) -> Result<()> {
+ let _ = ctx.defer().await;
+ let player = Players::find(&ctx.data().stdin, player)
+ .await
+ .unwrap()
+ .unwrap();
+ send_ctx!(ctx, "kick {}", player.uuid)?; // FIXME
+ return_next!(ctx)
+}
+
+#[poise::command(
+ slash_command,
+ category = "Control",
+ rename = "ban",
+ required_permissions = "ADMINISTRATOR",
+ default_member_permissions = "ADMINISTRATOR"
+)]
+/// ban a player by uuid and/or ip
+pub async fn add_raw(
+ ctx: Context<'_>,
+ #[description = "uuid of player to ban"] uuid: Option<String>,
+ #[description = "ip address of player to ban"] ip: Option<String>,
+) -> Result<()> {
+ let _ = ctx.defer().await;
+ if uuid.is_none() && ip.is_none() {
+ anyhow::bail!("what are you banning? yourself?")
+ }
+ if let Some(uuid) = uuid {
+ send_ctx!(ctx, "ban id {}", uuid)?;
+ }
+ if let Some(ip) = ip {
+ send_ctx!(ctx, "ban ip {}", ip)?;
+ }
+ return_next!(ctx)
+}
+
+#[poise::command(
+ slash_command,
+ category = "Control",
rename = "unban",
default_member_permissions = "ADMINISTRATOR",
required_permissions = "ADMINISTRATOR"