Struct serenity::model::guild::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

Indicator of whether the member can hear in voice channels.

The unique Id of the guild that the member is a part of.

Timestamp representing the date when the member joined.

Indicator of whether the member can speak in voice channels.

The member's nickname, if present.

Can't be longer than 32 characters.

Vector of Ids of Roles given to the member.

Attached User struct.

Methods

impl Member
[src]

Adds a Role to the member, editing its roles in-place if the request was successful.

Note: Requires the Manage Roles permission.

Adds one or multiple Roles to the member, editing its roles in-place if the request was successful.

Note: Requires the Manage Roles permission.

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.

Determines the member's colour.

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)

Calculates the member's display name.

The nickname takes priority over the member's username if it exists.

Returns the DiscordTag of a Member, taking possible nickname into account.

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.

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.

Kick the member from the guild.

Note: Requires the Kick Members permission.

Examples

Kick a member from its guild:

This example is not tested
// 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.

Returns the guild-level permissions for the member.

Examples

This example is not tested
// 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.

Removes a Role from the member, editing its roles in-place if the request was successful.

Note: Requires the Manage Roles permission.

Removes one or multiple Roles from the member.

Note: Requires the Manage Roles permission.

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.

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]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Member
[src]

Formats the value using the given formatter. Read more

impl Display for Member
[src]

Mentions the user so that they receive a notification.

Examples

This example is not tested
// assumes a `member` has already been bound
println!("{} is a member!", member);

impl Mentionable for Member
[src]

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]

Gets the Id of a Member.

impl<'a> From<&'a Member> for UserId
[src]

Gets the Id of a Member.

Auto Trait Implementations

impl Send for Member

impl Sync for Member