pub async fn server_from_name(name: &str) -> Result<Server, Error>
Expand description

Gets a Server struct from the specified name asynchronously. Returns all the useful server information.

Arguments

  • name - Name of the server.

Example

async fn wife() -> Result<(), minehut::Error> {
    // Get server named "Wife"
    let server = minehut::servers::server_from_name("Wife").await;
     
    // Server might not exist, so we do a check
    match server {
        Ok(s) => println!("{}", s.player_count),
        Err(_) => println!("Could not find server named Wife")
    }
    Ok(())
}

Errors

Returns None if the server name passed as a parameter does not link to any servers.