#[non_exhaustive]pub struct PrivateChannel {
pub id: ChannelId,
pub last_message_id: Option<MessageId>,
pub last_pin_timestamp: Option<Timestamp>,
pub kind: ChannelType,
pub recipient: User,
}
Expand description
A Direct Message text channel with another user.
Fields (Non-exhaustive)
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.id: ChannelId
The unique Id of the private channel.
Can be used to calculate the first message’s creation date.
last_message_id: Option<MessageId>
The Id of the last message sent.
last_pin_timestamp: Option<Timestamp>
Timestamp of the last time a Message
was pinned.
kind: ChannelType
Indicator of the type of channel this is.
This should always be ChannelType::Private
.
recipient: User
The recipient to the private channel.
Implementations
sourceimpl PrivateChannel
impl PrivateChannel
sourcepub async fn broadcast_typing(&self, http: impl AsRef<Http>) -> Result<()>
Available on crate feature model
only.
pub async fn broadcast_typing(&self, http: impl AsRef<Http>) -> Result<()>
model
only.Broadcasts that the current user is typing to the recipient.
See ChannelId::broadcast_typing for more details.
sourcepub async fn create_reaction(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
reaction_type: impl Into<ReactionType>
) -> Result<()>
Available on crate feature model
only.
pub async fn create_reaction(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
reaction_type: impl Into<ReactionType>
) -> Result<()>
model
only.React to a Message
with a custom Emoji
or unicode character.
Message::react
may be a more suited method of reacting in most
cases.
Errors
Returns Error::Http
if the reaction cannot be added,
or if a message with that Id does not exist.
sourcepub async fn delete(&self, http: impl AsRef<Http>) -> Result<Channel>
Available on crate feature model
only.
pub async fn delete(&self, http: impl AsRef<Http>) -> Result<Channel>
model
only.Deletes the channel. This does not delete the contents of the channel, and is equivalent to closing a private channel on the client, which can be re-opened.
sourcepub async fn delete_messages<T, It>(
&self,
http: impl AsRef<Http>,
message_ids: It
) -> Result<()> where
T: AsRef<MessageId>,
It: IntoIterator<Item = T>,
Available on crate feature model
only.
pub async fn delete_messages<T, It>(
&self,
http: impl AsRef<Http>,
message_ids: It
) -> Result<()> where
T: AsRef<MessageId>,
It: IntoIterator<Item = T>,
model
only.Deletes all messages by Ids from the given vector in the channel.
The minimum amount of messages is 2 and the maximum amount is 100.
Requires the Manage Messages permission.
Note: Messages that are older than 2 weeks can’t be deleted using this method.
Errors
Returns ModelError::BulkDeleteAmount
if an attempt was made to
delete either 0 or more than 100 messages.
sourcepub async fn delete_permission(
&self,
http: impl AsRef<Http>,
permission_type: PermissionOverwriteType
) -> Result<()>
Available on crate feature model
only.
pub async fn delete_permission(
&self,
http: impl AsRef<Http>,
permission_type: PermissionOverwriteType
) -> Result<()>
model
only.Deletes all permission overrides in the channel from a member or role.
Note: Requires the Manage Channel permission.
sourcepub async fn delete_reaction(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
user_id: Option<UserId>,
reaction_type: impl Into<ReactionType>
) -> Result<()>
Available on crate feature model
only.
pub async fn delete_reaction(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
user_id: Option<UserId>,
reaction_type: impl Into<ReactionType>
) -> Result<()>
model
only.Deletes the given Reaction
from the channel.
Note: In private channels, the current user may only delete it’s own reactions.
Errors
Returns Error::Http
if the reaction is not from
the current user.
sourcepub async fn edit_message<'a, F>(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
f: F
) -> Result<Message> where
F: for<'b> FnOnce(&'b mut EditMessage<'a>) -> &'b mut EditMessage<'a>,
Available on crate feature model
only.
pub async fn edit_message<'a, F>(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
f: F
) -> Result<Message> where
F: for<'b> FnOnce(&'b mut EditMessage<'a>) -> &'b mut EditMessage<'a>,
model
only.Edits a Message
in the channel given its Id.
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.
Errors
Returns a ModelError::MessageTooLong
if the content of the message
is over the the limit
, containing the number of unicode code points
over the limit.
Returns Error::Http
if the current user is not the owner of the message.
sourcepub fn is_nsfw(&self) -> bool
Available on crate feature model
only.
pub fn is_nsfw(&self) -> bool
model
only.Determines if the channel is NSFW.
Note: This method is for consistency. This will always return
false
, due to DMs not being considered NSFW.
sourcepub async fn message(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<Message>
Available on crate feature model
only.
pub async fn message(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<Message>
model
only.Gets a message from the channel.
Errors
Returns Error::Http
if a message with that Id does not
exist in this channel.
sourcepub async fn messages<F>(
&self,
http: impl AsRef<Http>,
builder: F
) -> Result<Vec<Message>> where
F: FnOnce(&mut GetMessages) -> &mut GetMessages,
Available on crate feature model
only.
pub async fn messages<F>(
&self,
http: impl AsRef<Http>,
builder: F
) -> Result<Vec<Message>> where
F: FnOnce(&mut GetMessages) -> &mut GetMessages,
model
only.Gets messages from the channel.
Refer to GetMessages
for more information on how to use builder
.
Errors
Returns Error::Http
if an invalid value is set in the builder.
sourcepub fn name(&self) -> String
Available on crate feature model
only.
pub fn name(&self) -> String
model
only.Returns “DM with $username#discriminator”.
sourcepub async fn reaction_users<M, R, U>(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
reaction_type: impl Into<ReactionType>,
limit: Option<u8>,
after: impl Into<Option<UserId>>
) -> Result<Vec<User>>
Available on crate feature model
only.
pub async fn reaction_users<M, R, U>(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
reaction_type: impl Into<ReactionType>,
limit: Option<u8>,
after: impl Into<Option<UserId>>
) -> Result<Vec<User>>
model
only.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.
Errors
Returns Error::Http
if a message with the given Id does not exist
in the channel.
sourcepub async fn pin(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
Available on crate feature model
only.
pub async fn pin(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
model
only.Pins a Message
to the channel.
Errors
Returns Error::Http
if the number of pinned messages
would exceed the 50 message limit.
sourcepub async fn pins(&self, http: impl AsRef<Http>) -> Result<Vec<Message>>
Available on crate feature model
only.
pub async fn pins(&self, http: impl AsRef<Http>) -> Result<Vec<Message>>
model
only.Retrieves the list of messages that have been pinned in the private channel.
sourcepub async fn say(
&self,
http: impl AsRef<Http>,
content: impl Display
) -> Result<Message>
Available on crate feature model
only.
pub async fn say(
&self,
http: impl AsRef<Http>,
content: impl Display
) -> Result<Message>
model
only.Sends a message with just the given message content in the channel.
Errors
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.
sourcepub async fn send_files<'a, F, T, It>(
&self,
http: impl AsRef<Http>,
files: It,
f: F
) -> Result<Message> where
for<'b> F: FnOnce(&'b mut CreateMessage<'a>) -> &'b mut CreateMessage<'a>,
T: Into<AttachmentType<'a>>,
It: IntoIterator<Item = T>,
Available on crate feature model
only.
pub async fn send_files<'a, F, T, It>(
&self,
http: impl AsRef<Http>,
files: It,
f: F
) -> Result<Message> where
for<'b> F: FnOnce(&'b mut CreateMessage<'a>) -> &'b mut CreateMessage<'a>,
T: Into<AttachmentType<'a>>,
It: IntoIterator<Item = T>,
model
only.Sends (a) file(s) along with optional message contents.
Refer to ChannelId::send_files
for examples and more information.
The [Attach Files] and Send Messages permissions are required.
Note: Message contents must be under 2000 unicode code points.
Errors
If the content of the message is over the above limit, then a
ModelError::MessageTooLong
will be returned, containing the number
of unicode code points over the limit.
sourcepub async fn send_message<'a, F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<Message> where
for<'b> F: FnOnce(&'b mut CreateMessage<'a>) -> &'b mut CreateMessage<'a>,
Available on crate feature model
only.
pub async fn send_message<'a, F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<Message> where
for<'b> F: FnOnce(&'b mut CreateMessage<'a>) -> &'b mut CreateMessage<'a>,
model
only.Sends a message to the channel with the given content.
Refer to the documentation for CreateMessage
for more information
regarding message restrictions and requirements.
Errors
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.
sourcepub fn start_typing(self, http: &Arc<Http>) -> Result<Typing>
Available on crate feature model
only.
pub fn start_typing(self, http: &Arc<Http>) -> Result<Typing>
model
only.Starts typing in the channel for an indefinite period of time.
Returns Typing
that is used to trigger the typing. Typing::stop
must be called
on the returned struct to stop typing. Note that on some clients, typing may persist
for a few seconds after Typing::stop
is called.
Typing is also stopped when the struct is dropped.
If a message is sent while typing is triggered, the user will stop typing for a brief period
of time and then resume again until either Typing::stop
is called or the struct is dropped.
This should rarely be used for bots, although it is a good indicator that a long-running command is still being processed.
Examples
// Initiate typing (assuming http is `Arc<Http>` and `channel` is bound)
let typing = channel.start_typing(&http)?;
// Run some long-running process
long_process();
// Stop typing
typing.stop();
Errors
May return Error::Http
if the current user cannot send a direct message
to this user.
sourcepub async fn unpin(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
Available on crate feature model
only.
pub async fn unpin(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
model
only.Unpins a Message
in the channel given by its Id.
Errors
Returns Error::Http
if the current user lacks permission,
if the message was deleted, or if the channel already has the limit of
50 pinned messages.
Trait Implementations
sourceimpl Clone for PrivateChannel
impl Clone for PrivateChannel
sourcefn clone(&self) -> PrivateChannel
fn clone(&self) -> PrivateChannel
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for PrivateChannel
impl Debug for PrivateChannel
sourceimpl<'de> Deserialize<'de> for PrivateChannel
impl<'de> Deserialize<'de> for PrivateChannel
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for PrivateChannel
impl Display for PrivateChannel
sourceimpl<'a> From<&'a PrivateChannel> for ChannelId
impl<'a> From<&'a PrivateChannel> for ChannelId
sourcefn from(private_channel: &PrivateChannel) -> ChannelId
fn from(private_channel: &PrivateChannel) -> ChannelId
Gets the Id of a private channel.
sourceimpl From<PrivateChannel> for ChannelId
impl From<PrivateChannel> for ChannelId
sourcefn from(private_channel: PrivateChannel) -> ChannelId
fn from(private_channel: PrivateChannel) -> ChannelId
Gets the Id of a private channel.
sourceimpl Mentionable for PrivateChannel
impl Mentionable for PrivateChannel
sourceimpl Serialize for PrivateChannel
impl Serialize for PrivateChannel
Auto Trait Implementations
impl RefUnwindSafe for PrivateChannel
impl Send for PrivateChannel
impl Sync for PrivateChannel
impl Unpin for PrivateChannel
impl UnwindSafe for PrivateChannel
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more