[−][src]Struct serenity::model::channel::PrivateChannel
A Direct Message text channel with another user.
Fields
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<DateTime<Utc>>
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
impl PrivateChannel
[src]
pub async fn broadcast_typing<'_>(
&'_ self,
http: impl AsRef<Http>
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>
) -> Result<()>
Broadcasts that the current user is typing to the recipient.
pub async fn create_reaction<'_>(
&'_ self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
reaction_type: impl Into<ReactionType>
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
reaction_type: impl Into<ReactionType>
) -> Result<()>
React to a Message
with a custom Emoji
or unicode character.
Message::react
may be a more suited method of reacting in most
cases.
Requires the Add Reactions permission, if the current user is the first user to perform a react with a certain emoji.
pub async fn delete<'_>(&'_ self, http: impl AsRef<Http>) -> Result<Channel>
[src]
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.
pub async fn delete_messages<T: AsRef<MessageId>, It: IntoIterator<Item = T>, '_>(
&'_ self,
http: impl AsRef<Http>,
message_ids: It
) -> Result<()> where
T: AsRef<MessageId>,
It: IntoIterator<Item = T>,
[src]
&'_ self,
http: impl AsRef<Http>,
message_ids: It
) -> Result<()> where
T: AsRef<MessageId>,
It: IntoIterator<Item = T>,
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.
pub async fn delete_permission<'_>(
&'_ self,
http: impl AsRef<Http>,
permission_type: PermissionOverwriteType
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>,
permission_type: PermissionOverwriteType
) -> Result<()>
Deletes all permission overrides in the channel from a member or role.
Note: Requires the Manage Channel permission.
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<()>
[src]
&'_ self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
user_id: Option<UserId>,
reaction_type: impl Into<ReactionType>
) -> Result<()>
Deletes the given Reaction
from the channel.
Note: Requires the Manage Messages permission, if the current user did not perform the reaction.
pub async fn edit_message<F, '_>(
&'_ self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
f: F
) -> Result<Message> where
F: FnOnce(&mut EditMessage) -> &mut EditMessage,
[src]
&'_ self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
f: F
) -> Result<Message> where
F: FnOnce(&mut EditMessage) -> &mut EditMessage,
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.
pub fn is_nsfw(&self) -> bool
[src]
Determines if the channel is NSFW.
Note: This method is for consistency. This will always return
false
, due to DMs not being considered NSFW.
pub async fn message<'_>(
&'_ self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<Message>
[src]
&'_ self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<Message>
Gets a message from the channel.
Requires the Read Message History permission.
pub async fn messages<F, '_>(
&'_ self,
http: impl AsRef<Http>,
builder: F
) -> Result<Vec<Message>> where
F: FnOnce(&mut GetMessages) -> &mut GetMessages,
[src]
&'_ self,
http: impl AsRef<Http>,
builder: F
) -> Result<Vec<Message>> where
F: FnOnce(&mut GetMessages) -> &mut GetMessages,
Gets messages from the channel.
Refer to GetMessages
for more information on how to use builder
.
Requires the Read Message History permission.
pub fn name(&self) -> String
[src]
Returns "DM with $username#discriminator".
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>>
[src]
&'_ 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>>
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 pin<'_>(
&'_ self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
Pins a Message
to the channel.
pub async fn pins<'_>(&'_ self, http: impl AsRef<Http>) -> Result<Vec<Message>>
[src]
Retrieves the list of messages that have been pinned in the private channel.
pub async fn say<'_>(
&'_ self,
http: impl AsRef<Http>,
content: impl Display
) -> Result<Message>
[src]
&'_ self,
http: impl AsRef<Http>,
content: impl Display
) -> Result<Message>
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.
pub async fn send_files<'a, F, T, It, '_>(
&'_ self,
http: impl AsRef<Http>,
files: It,
f: F
) -> Result<Message> where
F: FnOnce(&'b mut CreateMessage<'a>) -> &'b mut CreateMessage<'a>,
T: Into<AttachmentType<'a>>,
It: IntoIterator<Item = T>,
[src]
&'_ self,
http: impl AsRef<Http>,
files: It,
f: F
) -> Result<Message> where
F: FnOnce(&'b mut CreateMessage<'a>) -> &'b mut CreateMessage<'a>,
T: Into<AttachmentType<'a>>,
It: IntoIterator<Item = T>,
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.
pub async fn send_message<'a, F, '_>(
&'_ self,
http: impl AsRef<Http>,
f: F
) -> Result<Message> where
F: FnOnce(&'b mut CreateMessage<'a>) -> &'b mut CreateMessage<'a>,
[src]
&'_ self,
http: impl AsRef<Http>,
f: F
) -> Result<Message> where
F: FnOnce(&'b mut CreateMessage<'a>) -> &'b mut CreateMessage<'a>,
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.
pub fn start_typing(self, http: &Arc<Http>) -> Result<Typing>
[src]
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 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 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();
pub async fn unpin<'_>(
&'_ self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
Unpins a Message
in the channel given by its Id.
Requires the Manage Messages permission.
Trait Implementations
impl Clone for PrivateChannel
[src]
fn clone(&self) -> PrivateChannel
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for PrivateChannel
[src]
impl<'de> Deserialize<'de> for PrivateChannel
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for PrivateChannel
[src]
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult
[src]
Formats the private channel, displaying the recipient's username.
impl<'a> From<&'a PrivateChannel> for ChannelId
[src]
fn from(private_channel: &PrivateChannel) -> ChannelId
[src]
Gets the Id of a private channel.
impl From<PrivateChannel> for ChannelId
[src]
fn from(private_channel: PrivateChannel) -> ChannelId
[src]
Gets the Id of a private channel.
impl Mentionable for PrivateChannel
[src]
impl Serialize for PrivateChannel
[src]
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
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]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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]
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,