Skip to main content

get_player_bans

Function get_player_bans 

Source
pub fn get_player_bans(
    steamids: &str,
    api_key: &str,
) -> Result<Vec<User>, Error>
Expand description

Calls the GetPlayerBans API

§Returns

Returns an anyhow::Result containing a Vector of structs::bans::User and anyhow::Error

§Arguments

  • steamids - A string that contains either a single Steam ID or a comma separated string of Steam IDs
  • api_key - A string slice containing the API Key to use with the API.

§Errors

§Examples

Single Steam ID

let api_key = &std::env::var("API_KEY")?;
let steamid: &str = "76561198421169032";

let user = steam_api::get_player_bans(&steamid, &api_key)?;

println!("{}", user[0].SteamId);
println!("{}", user[0].VACBanned);

assert_eq!(user[0].SteamId, "76561198421169032");
assert!(!user[0].VACBanned);

Multiple Steam IDs

let api_key = &std::env::var("API_KEY")?;
let steamids: &str = "76561198421169032,76561198421169032";

let user = steam_api::get_player_bans(&steamids, &api_key)?;

for i in user {
    println!("Steam ID\t{}", i.SteamId);
    println!("VAC Banned\t{}", i.VACBanned);
}