Skip to content

zaun_client::Member · Struct

pub struct Member { … }

A member of a community.

pub fn dm(&self) -> Result<Channel>

The DM with this member, opened if needed (a bot DMs a member; a member DMs a bot).

FORBIDDEN{reason:"dms_closed"}, RATE_LIMITED{category:"dms"}, NOT_FOUND, or no answer.

pub fn send<impl Into<MessageOptions>>(&self, options: impl Into<MessageOptions>) -> Result<Message>

Sends this member a direct message: opens the DM, then posts in it.

What dm and Channel::send refuse.

pub fn presence(&self) -> Presence

What this member is doing and whether they are online (offline when unknown).

pub fn status_text(&self) -> Option<String>

Their custom status text, if they set one.

pub fn status_emoji(&self) -> Option<String>

Their custom status emoji, if they set one.

pub fn bot_id(&self) -> Option<BotId>

The bot this member is, if it is one.

pub fn is_bot(&self) -> bool

Whether this member is a bot.

pub fn can_use(&self, command: &ApplicationCommand, channel: &Channel) -> bool

Whether this member may use command in channel (a local view; the host decides).

pub fn mention(&self) -> String

The text that shows a mention of this member, <@id>.

pub const fn id(&self) -> MemberId

Its id.

pub const fn community(&self) -> &Community

The community it belongs to.

pub fn data(&self) -> Option<MemberData>

The cache’s copy, or None before the cache heard of this member (Community::fetch_members).

pub fn display_name(&self) -> String

Their name in this community.

pub fn is_me(&self) -> bool

Whether this member is this client.

pub fn roles(&self) -> Vec<Role>

Their roles.

pub fn timed_out_until(&self) -> Option<u64>

When a timeout ends, ms since the epoch; None when not timed out.

pub fn permissions(&self, channel: Option<&Channel>) -> Permissions

What this member may do in the community, or in channel, as the cache sees it; the host still decides.

pub fn can(&self, permission: Permissions, channel: Option<&Channel>) -> bool

Whether this member has permission (in channel), as the cache sees it.

pub fn add_role(&self, role: &Role) -> Result<()>

Gives this member role.

The host refused (no MANAGE_ROLES, or a role above this member’s) or did not answer.

pub fn remove_role(&self, role: &Role) -> Result<()>

Takes role from this member.

As add_role.

pub fn set_roles(&self, add: &[&Role], remove: &[&Role]) -> Result<()>

Adds and removes roles in one command.

As add_role.

pub fn kick(&self, reason: Option<&str>) -> Result<()>

Removes this member; they may join again with a new invitation.

The host refused (no KICK_MEMBERS, or a member above this one) or did not answer.

pub fn ban(&self, reason: Option<&str>) -> Result<()>

Removes this member and keeps them out.

The host refused (no BAN_MEMBERS) or did not answer.

pub fn timeout(&self, duration: Option<Duration>, reason: Option<&str>) -> Result<()>

Times this member out for duration, or lifts it with None.

The host refused (no TIMEOUT_MEMBERS) or did not answer.

pub fn fingerprint(&self) -> Option<String>

The fingerprint of this member’s key (this client’s own, or the one pinned on first sight), to compare out of band.

Clone, Debug, Display, PartialEq

Full rustdoc page