pub struct GetBans<'a> { /* private fields */ }
Expand description
Retrieve the bans for a guild.
Examples
Retrieve the first 25 bans of a guild after a particular user ID:
use std::env;
use twilight_http::Client;
use twilight_model::id::Id;
let client = Client::new(env::var("DISCORD_TOKEN")?);
let guild_id = Id::new(1);
let user_id = Id::new(2);
let response = client
.bans(guild_id)
.after(user_id)
.limit(25)?
.exec()
.await?;
let bans = response.models().await?;
for ban in bans {
println!("{} was banned for: {:?}", ban.user.name, ban.reason);
}
Implementations
sourceimpl<'a> GetBans<'a>
impl<'a> GetBans<'a>
sourcepub const fn after(self, user_id: Id<UserMarker>) -> Self
pub const fn after(self, user_id: Id<UserMarker>) -> Self
sourcepub const fn before(self, user_id: Id<UserMarker>) -> Self
pub const fn before(self, user_id: Id<UserMarker>) -> Self
sourcepub const fn limit(self, limit: u16) -> Result<Self, ValidationError>
pub const fn limit(self, limit: u16) -> Result<Self, ValidationError>
Set the maximum number of bans to retrieve.
Defaults to Discord’s default.
Refer to [Discord Docs/Get Guild Bans] for more information.
Errors
Returns an error of type GetGuildBans
if the limit is invalid.
sourcepub fn exec(self) -> ResponseFuture<ListBody<Ban>>ⓘNotable traits for ResponseFuture<T>impl<T: Unpin> Future for ResponseFuture<T> type Output = Result<Response<T>, Error>;
pub fn exec(self) -> ResponseFuture<ListBody<Ban>>ⓘNotable traits for ResponseFuture<T>impl<T: Unpin> Future for ResponseFuture<T> type Output = Result<Response<T>, Error>;
Execute the request, returning a future resolving to a Response
.
Trait Implementations
sourceimpl TryIntoRequest for GetBans<'_>
impl TryIntoRequest for GetBans<'_>
Auto Trait Implementations
impl<'a> !RefUnwindSafe for GetBans<'a>
impl<'a> Send for GetBans<'a>
impl<'a> Sync for GetBans<'a>
impl<'a> Unpin for GetBans<'a>
impl<'a> !UnwindSafe for GetBans<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more