pub struct RequestGuildMembersBuilder { /* private fields */ }

Implementations§

source§

impl RequestGuildMembersBuilder

source

pub const fn new(guild_id: Id<GuildMarker>) -> Self

Create a new builder to configure and construct a RequestGuildMembers.

source

pub fn nonce(self, nonce: impl Into<String>) -> Self

Set the nonce to identify the member chunk response.

By default, this uses Discord’s default.

source

pub fn presences(self, presences: bool) -> Self

Request that guild members’ presences are included in member chunks.

By default, this uses Discord’s default.

source

pub fn query( self, query: impl Into<String>, limit: Option<u64> ) -> RequestGuildMembers

Consume the builder, creating a request for users whose usernames start with the provided string and optionally limiting the number of members to retrieve.

If you specify no limit, then Discord’s default will be used, which will be an unbounded number of members. Specifying 0 is also equivalent.

To request the entire member list, pass in an empty string and no limit. You must also have the GUILD_MEMBERS intent enabled.

§Examples

Request all of the guild members that start with the letter “a” and their presences:

use twilight_model::{gateway::payload::outgoing::RequestGuildMembers, id::Id};

let request = RequestGuildMembers::builder(Id::new(1))
    .presences(true)
    .query("a", None);

assert_eq!(Id::new(1), request.d.guild_id);
assert_eq!(Some(0), request.d.limit);
assert_eq!(Some("a"), request.d.query.as_deref());
assert_eq!(Some(true), request.d.presences);
source

pub fn user_id(self, user_id: Id<UserMarker>) -> RequestGuildMembers

Consume the builder, creating a request that requests the provided member in the specified guild(s).

§Examples

Request a member within a guild and specify a nonce of “test”:

use twilight_model::{
    gateway::payload::outgoing::request_guild_members::{
        RequestGuildMemberId, RequestGuildMembers,
    },
    id::Id,
};

let request = RequestGuildMembers::builder(Id::new(1))
    .nonce("test")
    .user_id(Id::new(2));

assert_eq!(
    Some(RequestGuildMemberId::One(Id::new(2))),
    request.d.user_ids
);
source

pub fn user_ids( self, user_ids: impl Into<Vec<Id<UserMarker>>> ) -> Result<RequestGuildMembers, UserIdsError>

Consume the builder, creating a request that requests the provided user(s) in the specified guild(s).

Only up to 100 user IDs can be requested at once.

§Examples

Request two members within one guild and specify a nonce of “test”:

use twilight_model::{
    gateway::payload::outgoing::request_guild_members::{
        RequestGuildMemberId,
        RequestGuildMembers,
    },
    id::Id,
};

let request = RequestGuildMembers::builder(Id::new(1))
    .nonce("test")
    .user_ids(vec![Id::new(2), Id::new(2)])?;

assert!(matches!(request.d.user_ids, Some(RequestGuildMemberId::Multiple(ids)) if ids.len() == 2));
§Errors

Returns a UserIdsErrorType::TooMany error type if more than 100 user IDs were provided.

Trait Implementations§

source§

impl Clone for RequestGuildMembersBuilder

source§

fn clone(&self) -> RequestGuildMembersBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RequestGuildMembersBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for RequestGuildMembersBuilder

source§

fn eq(&self, other: &RequestGuildMembersBuilder) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for RequestGuildMembersBuilder

source§

impl StructuralPartialEq for RequestGuildMembersBuilder

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.