[][src]Struct twilight_model::gateway::payload::request_guild_members::RequestGuildMembersBuilder

pub struct RequestGuildMembersBuilder { /* fields omitted */ }

Implementations

impl RequestGuildMembersBuilder[src]

pub fn new(guild_id: GuildId) -> Self[src]

Create a new builder to configure and construct a RequestGuildMembers.

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

Set the nonce to identify the member chunk response.

By default, this uses Discord's default.

pub fn presences(mut self: Self, presences: bool) -> Self[src]

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

By default, this uses Discord's default.

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

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 a None query. 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::RequestGuildMembers, id::GuildId};

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

assert_eq!(GuildId(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);

pub fn user_id(self, user_id: UserId) -> RequestGuildMembers[src]

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::request_guild_members::{RequestGuildMemberId, RequestGuildMembers},
    id::{GuildId, UserId},
};

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

assert_eq!(Some(RequestGuildMemberId::One(UserId(2))), request.d.user_ids);

pub fn user_ids(
    self,
    user_ids: impl Into<Vec<UserId>>
) -> Result<RequestGuildMembers, UserIdsError>
[src]

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::request_guild_members::{RequestGuildMemberId, RequestGuildMembers},
    id::{GuildId, UserId},
};

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

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

Errors

Returns UserIdsError::TooMany if more than 100 user IDs were provided.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.