Struct serenity::model::Member
[−]
[src]
pub struct Member { pub deaf: bool, pub guild_id: GuildId, pub joined_at: Option<DateTime<FixedOffset>>, pub mute: bool, pub nick: Option<String>, pub roles: Vec<RoleId>, pub user: Arc<RwLock<User>>, }
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]
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.
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.
fn ban(&self, delete_message_days: u8) -> 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.
fn colour(&self) -> Option<Colour>
Determines the member's colour.
fn display_name(&self) -> Cow<String>
Calculates the member's display name.
The nickname takes priority over the member's username if it exists.
fn distinct(&self) -> String
Returns the DiscordTag of a Member, taking possible nickname into account.
fn edit<F: FnOnce(EditMember) -> EditMember>(&self, f: F) -> Result<()>
Edits the member with the given data. See Context::edit_member
for
more information.
See EditMember
for the permission(s) required for separate builder
methods, as well as usage of this.
fn find_guild(&self) -> Result<GuildId>
: Use the guild_id
structfield instead.
Returns the value of guild_id
.
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.
fn permissions(&self) -> Result<Permissions>
Returns the 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.
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.
fn remove_roles(&mut self, role_ids: &[RoleId]) -> Result<()>
Removes one or multiple Role
s from the member.
Note: Requires the Manage Roles permission.
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.
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.
Trait Implementations
impl Clone for Member
[src]
fn clone(&self) -> Member
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for Member
[src]
impl Display for Member
[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);