Skip to content

Struct Message

zaun_client::Message · Struct

pub struct Message { … }

A message in a channel.

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

Its buttons, selects and layout (bots only).

pub const fn flags(&self) -> u32

Its flags (flags::*).

pub const fn is_loading(&self) -> bool

Whether a deferred bot reply is still “thinking…”.

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

The interaction this bot reply answers.

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

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

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

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.

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.

pub fn mentions_me(&self) -> bool

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

pub const fn silent(&self) -> bool

Sent with SUPPRESS_NOTIFICATIONS: its mentions notify nobody.

pub const fn id(&self) -> MessageId

Its id.

pub fn content(&self) -> &str

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

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

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

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

The channel it is in.

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

The community it belongs to.

pub fn author(&self) -> Member

Who wrote it.

pub fn is_mine(&self) -> bool

Whether this client wrote it.

pub const fn sequence(&self) -> u64

Its position in the channel.

pub const fn timestamp(&self) -> u64

When the host accepted it, ms since the epoch.

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

The message it answers.

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

Its files; Attachment::download fetches one.

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

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

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

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

As Channel::send.

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.

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.

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

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

The host refused or did not answer.

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

Adds emoji as this member.

The host refused or did not answer.

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

Takes this member’s emoji off.

The host refused or did not answer.

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

Full rustdoc page