Module twitch_api2::helix::moderation::ban_user
source · [−]Available on crate feature
helix
only.Expand description
Bans a user from participating in a broadcaster’s chat room, or puts them in a timeout.
ban-user
Accessing the endpoint
Request: BanUserRequest
To use this endpoint, construct a BanUserRequest
with the BanUserRequest::builder()
method.
use twitch_api2::helix::moderation::ban_user;
let request = ban_user::BanUserRequest::builder()
.broadcaster_id("1234")
.moderator_id("5678")
.build();
Body: BanUserBody
We also need to provide a body to the request containing what we want to change.
let body = ban_user::BanUserBody::new("9876", "no reason".to_string(), 120);
Response: BanUser
Send the request to receive the response with HelixClient::req_post()
.
use twitch_api2::helix::{self, moderation::ban_user};
let request = ban_user::BanUserRequest::builder()
.broadcaster_id("1234")
.moderator_id("5678")
.build();
let body = ban_user::BanUserBody::new("9876", "no reason".to_string(), 120);
let response: ban_user::BanUser = client.req_post(request, body, &token).await?.data;
You can also get the http::Request
with request.create_request(&token, &client_id)
and parse the http::Response
with BanUserRequest::parse_response(None, &request.get_uri(), response)