feat: add /mod teleport

This commit is contained in:
Evan Carroll 2026-01-20 22:40:29 -06:00
parent 45a7e44b3a
commit 3da420fe59
3 changed files with 113 additions and 13 deletions

View file

@ -983,6 +983,89 @@ async fn handle_socket(
}
}
}
"teleport" => {
if args.len() < 2 {
let _ = direct_tx.send(ServerMessage::ModCommandResult {
success: false,
message: "Usage: /mod teleport [nick] [slug]".to_string(),
}).await;
continue;
}
let target_nick = &args[0];
let target_slug = &args[1];
// Look up the target scene by slug
let target_scene = match scenes::get_scene_by_slug(&pool, realm_id, target_slug).await {
Ok(Some(s)) => s,
Ok(None) => {
let _ = direct_tx.send(ServerMessage::ModCommandResult {
success: false,
message: format!("Scene '{}' not found", target_slug),
}).await;
continue;
}
Err(_) => {
let _ = direct_tx.send(ServerMessage::ModCommandResult {
success: false,
message: "Failed to look up scene".to_string(),
}).await;
continue;
}
};
// Find target user by display name
if let Some((target_user_id, target_conn)) = ws_state
.find_user_by_display_name(realm_id, target_nick)
{
if target_user_id == user_id {
let _ = direct_tx.send(ServerMessage::ModCommandResult {
success: false,
message: "You cannot teleport yourself".to_string(),
}).await;
continue;
}
// Send Summoned message to target user with the specified scene
let teleport_msg = ServerMessage::Summoned {
scene_id: target_scene.id,
scene_slug: target_scene.slug.clone(),
summoned_by: mod_member.display_name.clone(),
};
if target_conn.direct_tx.send(teleport_msg).await.is_ok() {
// Log the action
let metadata = serde_json::json!({
"scene_id": target_scene.id,
"scene_slug": target_scene.slug,
"target_display_name": target_nick,
});
let _ = moderation::log_moderation_action(
&pool,
realm_id,
user_id,
ActionType::Teleport,
Some(target_user_id),
&format!("Teleported {} to scene {}", target_nick, target_scene.name),
metadata,
).await;
let _ = direct_tx.send(ServerMessage::ModCommandResult {
success: true,
message: format!("Teleported {} to {}", target_nick, target_scene.name),
}).await;
} else {
let _ = direct_tx.send(ServerMessage::ModCommandResult {
success: false,
message: format!("Failed to send teleport to {}", target_nick),
}).await;
}
} else {
let _ = direct_tx.send(ServerMessage::ModCommandResult {
success: false,
message: format!("User '{}' is not online in this realm", target_nick),
}).await;
}
}
_ => {
let _ = direct_tx.send(ServerMessage::ModCommandResult {
success: false,