Skip to main content

Member

Struct Member 

Source
#[non_exhaustive]
pub struct Member {
Show 14 fields pub user: User, pub nick: Option<CompactString>, pub avatar: Option<ImageHash>, pub banner: Option<ImageHash>, pub roles: Vec<RoleId>, pub joined_at: Option<Timestamp>, pub premium_since: Option<Timestamp>, pub deaf: bool, pub mute: bool, pub flags: MemberFlags, pub pending: bool, pub communication_disabled_until: Option<Timestamp>, pub avatar_decoration_data: Option<Box<AvatarDecorationData>>, pub collectibles: Option<Box<Collectibles>>,
}
Expand description

A guild member: a user’s membership in one guild, with guild-specific data such as nickname and roles.

This is the complete shape (it includes the user), as returned by GET /guilds/{guild.id}/members/{user.id} and member gateway events. Messages carry a PartialMember instead (D-051).

discord.js counterpart: GuildMember.

§Examples

use djs_model::guild::Member;

let member: Member = serde_json::from_str(r#"{
    "user": {"id": "80351110224678912", "username": "nelly", "discriminator": "0",
             "global_name": "Nelly", "avatar": null},
    "nick": "NOT API SUPPORT", "roles": [], "joined_at": "2015-04-26T06:26:56.936000+00:00",
    "deaf": false, "mute": false, "flags": 0
}"#)?;
assert_eq!(member.display_name(), "NOT API SUPPORT");

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§user: User

The user this membership belongs to.

§nick: Option<CompactString>

The member’s nickname in this guild.

§avatar: Option<ImageHash>

The member’s guild avatar hash, overriding the user’s avatar in this guild.

§banner: Option<ImageHash>

The member’s guild banner hash.

§roles: Vec<RoleId>

The IDs of the member’s roles (the @everyone role is implied and not listed).

§joined_at: Option<Timestamp>

When the user joined the guild. None for guest members.

§premium_since: Option<Timestamp>

When the user started boosting the guild.

§deaf: bool

Whether the member is deafened in voice channels.

§mute: bool

Whether the member is muted in voice channels.

§flags: MemberFlags

The member’s flags.

§pending: bool

Whether the member has not yet passed the guild’s membership screening. Such members cannot use most of the guild until they do.

§communication_disabled_until: Option<Timestamp>

When the member’s timeout ends. A time in the past means the member is no longer timed out.

§avatar_decoration_data: Option<Box<AvatarDecorationData>>

The member’s guild-specific avatar decoration.

§collectibles: Option<Box<Collectibles>>

The member’s guild-specific collectibles.

Implementations§

Source§

impl Member

Source

pub fn display_name(&self) -> &str

Returns the name shown for the member in this guild: the nickname, else the user’s display name, else the username.

discord.js counterpart: GuildMember#displayName.

Source

pub fn is_timed_out(&self, now: Timestamp) -> bool

Returns whether the member is timed out at now.

discord.js counterpart: GuildMember#isCommunicationDisabled.

Trait Implementations§

Source§

impl Clone for Member

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Member

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Member

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Member

Source§

impl PartialEq for Member

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Member

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Member

Auto Trait Implementations§

§

impl Forget for Member

§

impl Freeze for Member

§

impl Move for Member

§

impl RefUnwindSafe for Member

§

impl Send for Member

§

impl Sync for Member

§

impl Unpin for Member

§

impl UnsafeUnpin for Member

§

impl UnwindSafe for Member

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.