# Struct Member

> A member of a community.

`zaun_client::Member` · Struct

```rust
pub struct Member { … }
```

A member of a community.

## Methods

### `dm`

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

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

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

### `send`

```rust
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.

# Errors
What `dm` and `Channel::send` refuse.

### `presence`

```rust
pub fn presence(&self) -> Presence
```

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

### `status_text`

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

Their custom status text, if they set one.

### `status_emoji`

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

Their custom status emoji, if they set one.

### `bot_id`

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

The bot this member is, if it is one.

### `is_bot`

```rust
pub fn is_bot(&self) -> bool
```

Whether this member is a bot.

### `can_use`

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

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

### `mention`

```rust
pub fn mention(&self) -> String
```

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

### `id`

```rust
pub const fn id(&self) -> MemberId
```

Its id.

### `community`

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

The community it belongs to.

### `data`

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

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

### `display_name`

```rust
pub fn display_name(&self) -> String
```

Their name in this community.

### `is_me`

```rust
pub fn is_me(&self) -> bool
```

Whether this member is this client.

### `roles`

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

Their roles.

### `timed_out_until`

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

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

### `permissions`

```rust
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.

### `can`

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

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

### `add_role`

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

Gives this member `role`.

# Errors
The host refused (no `MANAGE_ROLES`, or a role above this member's) or did not answer.

### `remove_role`

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

Takes `role` from this member.

# Errors
As `add_role`.

### `set_roles`

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

Adds and removes roles in one command.

# Errors
As `add_role`.

### `kick`

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

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

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

### `ban`

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

Removes this member and keeps them out.

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

### `timeout`

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

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

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

### `fingerprint`

```rust
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.

## Trait implementations

`Clone`, `Debug`, `Display`, `PartialEq`

[Full rustdoc page](/docs/api/rust/zaun-client/zaun_client/objects/struct.Member.html)
