pub struct RequestGuildMembersBuilder { /* private fields */ }
Implementations§
Source§impl RequestGuildMembersBuilder
impl RequestGuildMembersBuilder
Sourcepub const fn new(guild_id: Id<GuildMarker>) -> Self
pub const fn new(guild_id: Id<GuildMarker>) -> Self
Create a new builder to configure and construct a
RequestGuildMembers
.
Sourcepub fn nonce(self, nonce: impl Into<String>) -> Self
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.
Sourcepub fn presences(self, presences: bool) -> Self
pub fn presences(self, presences: bool) -> Self
Request that guild members’ presences are included in member chunks.
By default, this uses Discord’s default.
Sourcepub fn query(
self,
query: impl Into<String>,
limit: Option<u64>,
) -> RequestGuildMembers
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);
Sourcepub fn user_id(self, user_id: Id<UserMarker>) -> RequestGuildMembers
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
);
Sourcepub fn user_ids(
self,
user_ids: impl Into<Vec<Id<UserMarker>>>,
) -> Result<RequestGuildMembers, UserIdsError>
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
impl Clone for RequestGuildMembersBuilder
Source§fn clone(&self) -> RequestGuildMembersBuilder
fn clone(&self) -> RequestGuildMembersBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more