# Struct Message

> A message in a channel.

`zaun_client::Message` · Struct

```rust
pub struct Message { … }
```

A message in a channel.

## Methods

### `components`

```rust
pub fn components(&self) -> &[Component]
```

Its buttons, selects and layout (bots only).

### `flags`

```rust
pub const fn flags(&self) -> u32
```

Its flags (`flags::*`).

### `is_loading`

```rust
pub const fn is_loading(&self) -> bool
```

Whether a deferred bot reply is still "thinking…".

### `interaction`

```rust
pub const fn interaction(&self) -> Option<&InteractionMetadata>
```

The interaction this bot reply answers.

### `click`

```rust
pub fn click(&self, custom_id: &str, values: Vec<String>) -> Result<InteractionId>
```

Clicks a button, or chooses `values` in a select, of this message.

# Errors
The host refused (no such enabled component, values out of bounds).

### `mentions`

```rust
pub const fn mentions(&self) -> &Mentions
```

Who it mentions, as the host honoured them: `everyone`, `members`, `roles`. For a
message this client just posted, the ones it asked for.

### `mentions_member`

```rust
pub fn mentions_member(&self, member: &Member) -> bool
```

Whether it mentions `member`: by id, by one of the member's roles (as the cache has
them), or by `@everyone`.

### `mentions_me`

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

Whether it mentions this client's member (a client notifies its member then, unless
the message is `silent`).

### `silent`

```rust
pub const fn silent(&self) -> bool
```

Sent with `SUPPRESS_NOTIFICATIONS`: its mentions notify nobody.

### `id`

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

Its id.

### `content`

```rust
pub fn content(&self) -> &str
```

Its text (empty when it has embeds or attachments instead).

### `embeds`

```rust
pub fn embeds(&self) -> &[Embed]
```

Its rich embeds. A picture names one of `attachments`
(`attachment` finds it); nothing is fetched from elsewhere.

### `channel`

```rust
pub const fn channel(&self) -> &Channel
```

The channel it is in.

### `community`

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

The community it belongs to.

### `author`

```rust
pub fn author(&self) -> Member
```

Who wrote it.

### `is_mine`

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

Whether this client wrote it.

### `sequence`

```rust
pub const fn sequence(&self) -> u64
```

Its position in the channel.

### `timestamp`

```rust
pub const fn timestamp(&self) -> u64
```

When the host accepted it, ms since the epoch.

### `reply_to`

```rust
pub const fn reply_to(&self) -> Option<MessageId>
```

The message it answers.

### `attachments`

```rust
pub fn attachments(&self) -> Vec<Attachment>
```

Its files; `Attachment::download` fetches one.

### `attachment`

```rust
pub fn attachment(&self, id: AttachmentId) -> Option<Attachment>
```

One of its attachments, by id: an embed's picture, say.

### `reply`

```rust
pub fn reply<impl Into<MessageOptions>>(&self, options: impl Into<MessageOptions>) -> Result<Self>
```

Answers this message in its channel: text, or `MessageOptions`.

# Errors
As `Channel::send`.

### `edit`

```rust
pub fn edit<impl Into<EditMessage>>(&mut self, options: impl Into<EditMessage>) -> Result<()>
```

Edits this message (one of this member's): new text (`message.edit("…")`), or an
`EditMessage` that also replaces or removes the embeds or the mentions. Text not
given stays, and so do the mentions unless the edit names some (then they replace
them all). Pictures of new embeds must be attachments the message already has.

# Errors
A picture still to upload or a broken embed (`Error::Protocol`), embeds to a host
that does not keep them (`Error::Unsupported`), or the host refused or did not
answer.

### `delete`

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

Deletes this message (one's own, or any with `MANAGE_MESSAGES`).

# Errors
The host refused or did not answer.

### `react`

```rust
pub fn react(&self, emoji: &str) -> Result<()>
```

Adds `emoji` as this member.

# Errors
The host refused or did not answer.

### `unreact`

```rust
pub fn unreact(&self, emoji: &str) -> Result<()>
```

Takes this member's `emoji` off.

# Errors
The host refused or did not answer.

## Trait implementations

`Clone`, `Debug`, `Display`, `From<&Message>`, `PartialEq`

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