Skip to main content

Message

Struct Message 

Source
pub struct Message { /* private fields */ }
Expand description

A message in a channel.

Implementations§

Source§

impl Message

Source

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

Its buttons, selects and layout (bots only).

Source

pub const fn flags(&self) -> u32

Its flags (flags::*).

Source

pub const fn is_loading(&self) -> bool

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

Source

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

The interaction this bot reply answers.

Source

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).

Source§

impl Message

Source

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.

Source

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.

Source

pub fn mentions_me(&self) -> bool

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

Source

pub const fn silent(&self) -> bool

Sent with SUPPRESS_NOTIFICATIONS: its mentions notify nobody.

Source§

impl Message

Source

pub const fn id(&self) -> MessageId

Its id.

Source

pub fn content(&self) -> &str

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

Source

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

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

Source

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

The channel it is in.

Source

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

The community it belongs to.

Source

pub fn author(&self) -> Member

Who wrote it.

Source

pub fn is_mine(&self) -> bool

Whether this client wrote it.

Source

pub const fn sequence(&self) -> u64

Its position in the channel.

Source

pub const fn timestamp(&self) -> u64

When the host accepted it, ms since the epoch.

Source

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

The message it answers.

Source

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

Its files; Attachment::download fetches one.

Source

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

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

Source

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

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

§Errors

As Channel::send.

Source

pub fn edit(&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.

Source

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

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

§Errors

The host refused or did not answer.

Source

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

Adds emoji as this member.

§Errors

The host refused or did not answer.

Source

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

Takes this member’s emoji off.

§Errors

The host refused or did not answer.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Message

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 Message

Source§

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

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

impl Display for Message

Source§

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

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

impl From<&Message> for PartialMessage

Source§

fn from(m: &Message) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Message

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

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
§

impl<T> CryptoSafe for T
where T: Send + Sync + Debug,

§

impl<T> CryptoSafe for T

Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more