[−][src]Struct serenity::model::guild::Member
Information about a member of a guild.
Fields
deaf: bool
Indicator of whether the member can hear in voice channels.
guild_id: GuildId
The unique Id of the guild that the member is a part of.
joined_at: Option<DateTime<FixedOffset>>
Timestamp representing the date when the member joined.
mute: bool
Indicator of whether the member can speak in voice channels.
nick: Option<String>
The member's nickname, if present.
Can't be longer than 32 characters.
roles: Vec<RoleId>
Vector of Ids of Role
s given to the member.
user: Arc<RwLock<User>>
Attached User struct.
Methods
impl Member
[src]
impl Member
pub fn add_role<R: Into<RoleId>>(&mut self, role_id: R) -> Result<()>
[src]
pub fn add_role<R: Into<RoleId>>(&mut self, role_id: R) -> Result<()>
Adds a Role
to the member, editing its roles in-place if the request
was successful.
Note: Requires the Manage Roles permission.
pub fn add_roles(&mut self, role_ids: &[RoleId]) -> Result<()>
[src]
pub fn add_roles(&mut self, role_ids: &[RoleId]) -> Result<()>
Adds one or multiple Role
s to the member, editing
its roles in-place if the request was successful.
Note: Requires the Manage Roles permission.
pub fn ban<BO: BanOptions>(&self, ban_options: &BO) -> Result<()>
[src]
pub fn ban<BO: BanOptions>(&self, ban_options: &BO) -> Result<()>
Ban the member from its guild, deleting the last X number of days' worth of messages.
Note: Requires the Ban Members permission.
Errors
Returns a ModelError::GuildNotFound
if the guild could not be
found.
pub fn colour(&self) -> Option<Colour>
[src]
pub fn colour(&self) -> Option<Colour>
Determines the member's colour.
pub fn default_channel(&self) -> Option<Arc<RwLock<GuildChannel>>>
[src]
pub fn default_channel(&self) -> Option<Arc<RwLock<GuildChannel>>>
Returns the "default channel" of the guild for the member.
(This returns the first channel that can be read by the member, if there isn't
one returns None
)
pub fn display_name(&self) -> Cow<String>
[src]
pub fn display_name(&self) -> Cow<String>
Calculates the member's display name.
The nickname takes priority over the member's username if it exists.
pub fn distinct(&self) -> String
[src]
pub fn distinct(&self) -> String
Returns the DiscordTag of a Member, taking possible nickname into account.
pub fn edit<F: FnOnce(EditMember) -> EditMember>(&self, f: F) -> Result<()>
[src]
pub fn edit<F: FnOnce(EditMember) -> EditMember>(&self, f: F) -> Result<()>
Edits the member with the given data. See Guild::edit_member
for
more information.
See EditMember
for the permission(s) required for separate builder
methods, as well as usage of this.
pub fn highest_role_info(&self) -> Option<(RoleId, i64)>
[src]
pub fn highest_role_info(&self) -> Option<(RoleId, i64)>
Retrieves the ID and position of the member's highest role in the hierarchy, if they have one.
This may return None
if:
- the user has roles, but they are not present in the cache for cache inconsistency reasons
- you already have a write lock to the member's guild
The "highest role in hierarchy" is defined as the role with the highest position. If two or more roles have the same highest position, then the role with the lowest ID is the highest.
pub fn kick(&self) -> Result<()>
[src]
pub fn kick(&self) -> Result<()>
Kick the member from the guild.
Note: Requires the Kick Members permission.
Examples
Kick a member from its guild:
// assuming a `member` has already been bound match member.kick() { Ok(()) => println!("Successfully kicked member"), Err(Error::Model(ModelError::GuildNotFound)) => { println!("Couldn't determine guild of member"); }, Err(Error::Model(ModelError::InvalidPermissions(missing_perms))) => { println!("Didn't have permissions; missing: {:?}", missing_perms); }, _ => {}, }
Errors
Returns a ModelError::GuildNotFound
if the Id of the member's guild
could not be determined.
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user does not have permission to perform the kick.
pub fn permissions(&self) -> Result<Permissions>
[src]
pub fn permissions(&self) -> Result<Permissions>
Returns the guild-level permissions for the member.
Examples
// assuming there's a `member` variable gotten from anything. println!("The permission bits for the member are: {}", member.permissions().expect("permissions").bits);
Errors
Returns a ModelError::GuildNotFound
if the guild the member's in could not be
found in the cache.
And/or returns ModelError::ItemMissing
if the "default channel" of the guild is not
found.
pub fn remove_role<R: Into<RoleId>>(&mut self, role_id: R) -> Result<()>
[src]
pub fn remove_role<R: Into<RoleId>>(&mut self, role_id: R) -> Result<()>
Removes a Role
from the member, editing its roles in-place if the
request was successful.
Note: Requires the Manage Roles permission.
pub fn remove_roles(&mut self, role_ids: &[RoleId]) -> Result<()>
[src]
pub fn remove_roles(&mut self, role_ids: &[RoleId]) -> Result<()>
Removes one or multiple Role
s from the member.
Note: Requires the Manage Roles permission.
pub fn roles(&self) -> Option<Vec<Role>>
[src]
pub fn roles(&self) -> Option<Vec<Role>>
Retrieves the full role data for the user's roles.
This is shorthand for manually searching through the CACHE.
If role data can not be found for the member, then None
is returned.
pub fn unban(&self) -> Result<()>
[src]
pub fn unban(&self) -> Result<()>
Unbans the User
from the guild.
Note: Requires the Ban Members permission.
Errors
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user does not have permission to perform bans.
pub fn user_id(&self) -> UserId
[src]
pub fn user_id(&self) -> UserId
Retrieves the member's user ID.
This is a shortcut for accessing the user
structfield, retrieving a
reader guard, and then copying its ID.
Deadlocking
This function can deadlock while retrieving a read guard to the user object if your application infinitely holds a write lock elsewhere.
Trait Implementations
impl Mentionable for Member
[src]
impl Mentionable for Member
fn mention(&self) -> String
[src]
fn mention(&self) -> String
Creates a mentionable string, that will be able to notify and/or create a link to the item. Read more
impl From<Member> for UserId
[src]
impl From<Member> for UserId
impl<'a> From<&'a Member> for UserId
[src]
impl<'a> From<&'a Member> for UserId
impl Clone for Member
[src]
impl Clone for Member
fn clone(&self) -> Member
[src]
fn clone(&self) -> Member
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Member
[src]
impl Debug for Member
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Display for Member
[src]
impl Display for Member
fn fmt(&self, f: &mut Formatter) -> FmtResult
[src]
fn fmt(&self, f: &mut Formatter) -> FmtResult
Mentions the user so that they receive a notification.
Examples
// assumes a `member` has already been bound println!("{} is a member!", member);
impl Serialize for Member
[src]
impl Serialize for Member
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for Member
[src]
impl<'de> Deserialize<'de> for Member
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
impl<T> ToString for T where
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
impl<T> Erased for T
impl<T> Erased for T
impl<T> Typeable for T where
T: Any,
impl<T> Typeable for T where
T: Any,
impl<T> DebugAny for T where
T: Any + Debug,
[src]
impl<T> DebugAny for T where
T: Any + Debug,
impl<T> CloneAny for T where
T: Clone + Any,
[src]
impl<T> CloneAny for T where
T: Clone + Any,
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
[src]
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
[src]
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
[src]
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync,
[src]
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync,
impl<T> UnsafeAny for T where
T: Any,
impl<T> UnsafeAny for T where
T: Any,