[−][src]Struct serenity::model::channel::Message
A representation of a message over a guild's text channel, a group, or a private channel.
Fields (Non-exhaustive)
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.id: MessageId
The unique Id of the message. Can be used to calculate the creation date of the message.
attachments: Vec<Attachment>
An vector of the files attached to a message.
The user that sent the message.
channel_id: ChannelId
The Id of the Channel
that the message was sent to.
content: String
The content of the message.
edited_timestamp: Option<DateTime<Utc>>
The timestamp of the last time the message was updated, if it was.
embeds: Vec<Embed>
Array of embeds sent with the message.
guild_id: Option<GuildId>
The Id of the Guild
that the message was sent in. This value will
only be present if this message was received over the gateway.
kind: MessageType
Indicator of the type of message this is, i.e. whether it is a regular message or a system message.
member: Option<PartialMember>
A partial amount of data about the user's member data, if this message was sent in a guild.
mention_everyone: bool
Indicator of whether the message mentions everyone.
mention_roles: Vec<RoleId>
Array of Role
s' Ids mentioned in the message.
mention_channels: Vec<ChannelMention>
Channels specifically mentioned in this message.
mentions: Vec<User>
Array of users mentioned in the message.
nonce: Value
Non-repeating number used for ensuring message order.
pinned: bool
Indicator of whether the message is pinned.
reactions: Vec<MessageReaction>
Array of reactions performed on the message.
timestamp: DateTime<Utc>
Initial message creation timestamp, calculated from its Id.
tts: bool
Indicator of whether the command is to be played back via text-to-speech.
In the client, this is done via the /tts
slash command.
webhook_id: Option<WebhookId>
The Id of the webhook that sent this message, if one did.
activity: Option<MessageActivity>
Sent with Rich Presence-related chat embeds.
application: Option<MessageApplication>
Sent with Rich Presence-related chat embeds.
message_reference: Option<MessageReference>
Reference data sent with crossposted messages.
flags: Option<MessageFlags>
Bit flags describing extra features of the message.
stickers: Vec<Sticker>
Array of stickers sent with the message.
referenced_message: Option<Box<Message>>
The message that was replied to using this message.
Implementations
impl Message
[src]
pub async fn channel(&self, cache: impl AsRef<Cache>) -> Option<Channel>
[src]
Retrieves the related channel located in the cache.
Returns None
if the channel is not in the cache.
pub async fn is_own(&self, cache: impl AsRef<Cache>) -> bool
[src]
A util function for determining whether this message was sent by someone else, or the bot.
pub async fn delete(&self, cache_http: impl CacheHttp) -> Result<()>
[src]
Deletes the message.
Note: The logged in user must either be the author of the message or have the Manage Messages permission.
Errors
If the cache
feature is enabled, then returns a
ModelError::InvalidPermissions
if the current user does not have
the required permissions.
pub async fn delete_reactions(&self, cache_http: impl CacheHttp) -> Result<()>
[src]
Deletes all of the Reaction
s associated with the message.
Note: Requires the Manage Messages permission.
Errors
If the cache
feature is enabled, then returns a
ModelError::InvalidPermissions
if the current user does not have
the required permissions.
pub async fn delete_reaction_emoji(
&self,
cache_http: impl CacheHttp,
reaction_type: impl Into<ReactionType>
) -> Result<()>
[src]
&self,
cache_http: impl CacheHttp,
reaction_type: impl Into<ReactionType>
) -> Result<()>
Deletes all of the Reaction
s of a given emoji associated with the message.
Note: Requires the Manage Messages permission.
Errors
If the cache
feature is enabled, then returns a
ModelError::InvalidPermissions
if the current user does not have
the required permissions.
pub async fn edit<F>(&mut self, cache_http: impl CacheHttp, f: F) -> Result<()> where
F: FnOnce(&mut EditMessage) -> &mut EditMessage,
[src]
F: FnOnce(&mut EditMessage) -> &mut EditMessage,
Edits this message, replacing the original content with new content.
Message editing preserves all unchanged message data.
Refer to the documentation for EditMessage
for more information
regarding message restrictions and requirements.
Note: Requires that the current user be the author of the message.
Examples
Edit a message with new content:
// assuming a `message` has already been bound message.edit(&context, |m| m.content("new content"));
Errors
If the cache
is enabled, returns a ModelError::InvalidUser
if the
current user is not the author.
Returns a ModelError::MessageTooLong
if the content of the message
is over the limit
, containing the number of unicode code points
over the limit.
pub async fn content_safe(&self, cache: impl AsRef<Cache>) -> String
[src]
Returns message content, but with user and role mentions replaced with names and everyone/here mentions cancelled.
pub async fn reaction_users(
&self,
http: impl AsRef<Http>,
reaction_type: impl Into<ReactionType>,
limit: Option<u8>,
after: impl Into<Option<UserId>>
) -> Result<Vec<User>>
[src]
&self,
http: impl AsRef<Http>,
reaction_type: impl Into<ReactionType>,
limit: Option<u8>,
after: impl Into<Option<UserId>>
) -> Result<Vec<User>>
Gets the list of User
s who have reacted to a Message
with a
certain Emoji
.
The default limit
is 50
- specify otherwise to receive a different
maximum number of users. The maximum that may be retrieve at a time is
100
, if a greater number is provided then it is automatically reduced.
The optional after
attribute is to retrieve the users after a certain
user. This is useful for pagination.
Note: Requires the Read Message History permission.
pub async fn guild(&self, cache: impl AsRef<Cache>) -> Option<Guild>
[src]
Returns the associated Guild
for the message if one is in the cache.
Returns None
if the guild's Id could not be found via guild_id
or
if the Guild itself is not cached.
Requires the cache
feature be enabled.
pub async fn guild_field<Ret, Fun>(
&self,
cache: impl AsRef<Cache>,
field_accessor: Fun
) -> Option<Ret> where
Ret: Clone,
Fun: FnOnce(&Guild) -> Ret,
[src]
&self,
cache: impl AsRef<Cache>,
field_accessor: Fun
) -> Option<Ret> where
Ret: Clone,
Fun: FnOnce(&Guild) -> Ret,
Returns a field to the Guild
for the message if one is in the cache.
The field can be selected via the field_accessor
.
Returns None
if the guild's ID could not be found via guild_id
or
if the Guild itself is not cached.
Requires the cache
feature be enabled.
pub fn is_private(&self) -> bool
[src]
True if message was sent using direct messages.
pub async fn member(&self, cache_http: impl CacheHttp) -> Result<Member>
[src]
Retrieves a clone of the author's Member instance, if this message was sent in a guild.
If the instance cannot be found in the cache, or the cache
feature is
disabled, a HTTP request is performed to retrieve it from Discord's API.
Errors
ModelError::ItemMissing
is returned if guild_id
is None
.
pub fn overflow_length(content: &str) -> Option<usize>
[src]
Checks the length of a string to ensure that it is within Discord's maximum message length limit.
Returns None
if the message is within the limit, otherwise returns
Some
with an inner value of how many unicode code points the message
is over.
pub async fn pin(&self, cache_http: impl CacheHttp) -> Result<()>
[src]
Pins this message to its channel.
Note: Requires the Manage Messages permission.
Errors
If the cache
is enabled, returns a
ModelError::InvalidPermissions
if the current user does not have
the required permissions.
pub async fn react(
&self,
cache_http: impl CacheHttp,
reaction_type: impl Into<ReactionType>
) -> Result<Reaction>
[src]
&self,
cache_http: impl CacheHttp,
reaction_type: impl Into<ReactionType>
) -> Result<Reaction>
React to the message with a custom Emoji
or unicode character.
Note: Requires the Add Reactions permission.
Errors
If the cache
is enabled, returns a
ModelError::InvalidPermissions
if the current user does not have the
required permissions.
pub async fn reply(
&self,
cache_http: impl CacheHttp,
content: impl Display
) -> Result<Message>
[src]
&self,
cache_http: impl CacheHttp,
content: impl Display
) -> Result<Message>
Uses Discord's inline reply to a user without pinging them.
User mentions are generally around 20 or 21 characters long.
Note: Requires the Send Messages permission.
Note: Message contents must be under 2000 unicode code points.
Errors
If the cache
is enabled, returns a
ModelError::InvalidPermissions
if the current user does not have
the required permissions.
Returns a ModelError::MessageTooLong
if the content of the message
is over the above limit, containing the number of unicode code points
over the limit.
pub async fn reply_ping(
&self,
cache_http: impl CacheHttp,
content: impl Display
) -> Result<Message>
[src]
&self,
cache_http: impl CacheHttp,
content: impl Display
) -> Result<Message>
Uses Discord's inline reply to a user with a ping.
Note: Requires the Send Messages permission.
Note: Message contents must be under 2000 unicode code points.
Errors
If the cache
is enabled, returns a
ModelError::InvalidPermissions
if the current user does not have
the required permissions.
Returns a ModelError::MessageTooLong
if the content of the message
is over the above limit, containing the number of unicode code points
over the limit.
pub async fn reply_mention(
&self,
cache_http: impl CacheHttp,
content: impl Display
) -> Result<Message>
[src]
&self,
cache_http: impl CacheHttp,
content: impl Display
) -> Result<Message>
Replies to the user, mentioning them prior to the content in the form
of: @<USER_ID> YOUR_CONTENT
.
User mentions are generally around 20 or 21 characters long.
Note: Requires the Send Messages permission.
Note: Message contents must be under 2000 unicode code points.
Errors
If the cache
is enabled, returns a
ModelError::InvalidPermissions
if the current user does not have
the required permissions.
Returns a ModelError::MessageTooLong
if the content of the message
is over the above limit, containing the number of unicode code points
over the limit.
pub async fn suppress_embeds(
&mut self,
cache_http: impl CacheHttp
) -> Result<()>
[src]
&mut self,
cache_http: impl CacheHttp
) -> Result<()>
Delete all embeds in this message Note: The logged in user must either be the author of the message or have the Manage Messages permission.
Errors
If the cache
feature is enabled, then returns a
ModelError::InvalidPermissions
if the current user does not have
the required permissions.
pub fn mentions_user_id(&self, id: impl Into<UserId>) -> bool
[src]
Checks whether the message mentions passed UserId
.
pub fn mentions_user(&self, user: &User) -> bool
[src]
Checks whether the message mentions passed User
.
pub async fn mentions_me(&self, cache_http: impl CacheHttp) -> Result<bool>
[src]
Checks whether the message mentions the current user.
pub async fn unpin(&self, cache_http: impl CacheHttp) -> Result<()>
[src]
Unpins the message from its channel.
Note: Requires the Manage Messages permission.
Errors
If the cache
is enabled, returns a
ModelError::InvalidPermissions
if the current user does not have
the required permissions.
pub async fn author_nick(&self, cache_http: impl CacheHttp) -> Option<String>
[src]
Tries to return author's nickname in the current channel's guild.
Refer to User::nick_in()
inside and None
outside of a guild.
pub fn link(&self) -> String
[src]
Returns a link referencing this message. When clicked, users will jump to the message. The link will be valid for messages in either private channels or guilds.
pub fn await_reaction<'a>(
&self,
shard_messenger: &'a impl AsRef<ShardMessenger>
) -> CollectReaction<'a>ⓘNotable traits for CollectReaction<'a>
impl<'a> Future for CollectReaction<'a> type Output = Option<Arc<ReactionAction>>;
[src]
&self,
shard_messenger: &'a impl AsRef<ShardMessenger>
) -> CollectReaction<'a>ⓘ
Notable traits for CollectReaction<'a>
impl<'a> Future for CollectReaction<'a> type Output = Option<Arc<ReactionAction>>;
Await a single reaction on this message.
pub fn await_reactions<'a>(
&self,
shard_messenger: &'a impl AsRef<ShardMessenger>
) -> ReactionCollectorBuilder<'a>ⓘNotable traits for ReactionCollectorBuilder<'a>
impl<'a> Future for ReactionCollectorBuilder<'a> type Output = ReactionCollector;
[src]
&self,
shard_messenger: &'a impl AsRef<ShardMessenger>
) -> ReactionCollectorBuilder<'a>ⓘ
Notable traits for ReactionCollectorBuilder<'a>
impl<'a> Future for ReactionCollectorBuilder<'a> type Output = ReactionCollector;
Returns a stream builder which can be awaited to obtain a stream of reactions on this message.
pub async fn category_id(&self, cache: impl AsRef<Cache>) -> Option<ChannelId>
[src]
Retrieves the message channel's category ID if the channel has one.
Trait Implementations
impl AsRef<MessageId> for Message
[src]
impl Clone for Message
[src]
impl Debug for Message
[src]
impl<'de> Deserialize<'de> for Message
[src]
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl From<&'_ Message> for MessageReference
[src]
impl<'a> From<&'a Message> for MessageId
[src]
impl From<Message> for MessageId
[src]
impl Serialize for Message
[src]
Auto Trait Implementations
impl RefUnwindSafe for Message
[src]
impl Send for Message
[src]
impl Sync for Message
[src]
impl Unpin for Message
[src]
impl UnwindSafe for Message
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,