[−][src]Struct serenity::model::id::ChannelId
An identifier for a Channel
Implementations
impl ChannelId
[src]
pub async fn broadcast_typing(self, http: impl AsRef<Http>) -> Result<()>
[src]
Broadcasts that the current user is typing to a channel for the next 5 seconds.
After 5 seconds, another request must be made to continue broadcasting that the current user is typing.
This should rarely be used for bots, and should likely only be used for signifying that a long-running command is still being executed.
Note: Requires the Send Messages permission.
Examples
use serenity::model::id::ChannelId; let _successful = ChannelId(7).broadcast_typing(&http).await;
pub async fn create_invite<F, '_>(
&'_ self,
http: impl AsRef<Http>,
f: F
) -> Result<RichInvite> where
F: FnOnce(&mut CreateInvite) -> &mut CreateInvite,
[src]
&'_ self,
http: impl AsRef<Http>,
f: F
) -> Result<RichInvite> where
F: FnOnce(&mut CreateInvite) -> &mut CreateInvite,
Creates an invite leading to the given channel.
pub async fn create_permission<'_>(
self,
http: impl AsRef<Http>,
target: &'_ PermissionOverwrite
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
target: &'_ PermissionOverwrite
) -> Result<()>
Creates a permission overwrite for either a
single Member
or Role
within the channel.
Refer to the documentation for GuildChannel::create_permission
for
more information.
Requires the Manage Channels permission.
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 this channel, returning the channel on a successful deletion.
pub async fn delete_message(
self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
Deletes a Message
given its Id.
Refer to Message::delete
for more information.
Requires the Manage Messages permission, if the current user is not the author of the message.
pub async fn delete_messages<T, It>(
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 given 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 delete_reaction_emoji(
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<()>
Deletes all Reaction
s of the given emoji to a message within the channel.
Note: Requires the Manage Messages permission.
pub async fn edit<F>(self, http: impl AsRef<Http>, f: F) -> Result<GuildChannel> where
F: FnOnce(&mut EditChannel) -> &mut EditChannel,
[src]
F: FnOnce(&mut EditChannel) -> &mut EditChannel,
Edits the settings of a Channel
, optionally setting new values.
Refer to EditChannel
's documentation for its methods.
Requires the Manage Channel permission.
Examples
Change a voice channel's name and bitrate:
// assuming a `channel_id` has been bound channel_id.edit(&http, |c| c.name("test").bitrate(64000)).await;
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 async fn to_channel_cached(
self,
cache: impl AsRef<Cache>
) -> Option<Channel>
[src]
self,
cache: impl AsRef<Cache>
) -> Option<Channel>
Attempts to find a Channel
by its Id in the cache.
pub async fn to_channel(self, cache_http: impl CacheHttp) -> Result<Channel>
[src]
First attempts to find a Channel
by its Id in the cache,
upon failure requests it via the REST API.
Note: If the cache
-feature is enabled permissions will be checked and upon
owning the required permissions the HTTP-request will be issued.
pub async fn invites(self, http: impl AsRef<Http>) -> Result<Vec<RichInvite>>
[src]
Gets all of the channel's invites.
Requires the Manage Channels permission.
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 messages_iter<H: AsRef<Http>>(
self,
http: H
) -> impl Stream<Item = Result<Message>>
[src]
self,
http: H
) -> impl Stream<Item = Result<Message>>
Streams over all the messages in a channel.
This is accomplished and equivalent to repeated calls to messages
.
A buffer of at most 100 messages is used to reduce the number of calls.
necessary.
The stream returns the oldest message first, followed by newer messages.
Examples
use serenity::model::channel::MessagesIter; use serenity::futures::StreamExt; let mut messages = channel_id.messages_iter(&ctx).boxed(); while let Some(message_result) = messages.next().await { match message_result { Ok(message) => println!( "{} said \"{}\".", message.author.name, message.content, ), Err(error) => eprintln!("Uh oh! Error: {}", error), } }
pub async fn name(self, cache: impl AsRef<Cache>) -> Option<String>
[src]
Returns the name of whatever channel this id holds.
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]
Gets the list of Message
s which are pinned to the channel.
pub async fn reaction_users(
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 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 along with optional message contents. The filename must be specified.
Message contents may be passed by using the CreateMessage::content
method.
The Attach Files and Send Messages permissions are required.
Note: Message contents must be under 2000 unicode code points.
Examples
Send files with the paths /path/to/file.jpg
and /path/to/file2.jpg
:
use serenity::model::id::ChannelId; let channel_id = ChannelId(7); let paths = vec!["/path/to/file.jpg", "path/to/file2.jpg"]; let _ = channel_id.send_files(&http, paths, |m| { m.content("a file") }) .await;
Send files using File
:
use serenity::model::id::ChannelId; use tokio::fs::File; let channel_id = ChannelId(7); let f1 = File::open("my_file.jpg").await?; let f2 = File::open("my_file2.jpg").await?; let files = vec![(&f1, "my_file.jpg"), (&f2, "my_file2.jpg")]; let _ = channel_id.send_files(&http, files, |m| { m.content("a file") }) .await;
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.
Returns an
HttpError::UnsuccessfulRequest(ErrorResponse)
if the file is too large to send.
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.
Refer to the documentation for CreateMessage
for more information
regarding message restrictions and requirements.
Requires the Send Messages permission.
Note: Message contents must be under 2000 unicode code points.
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>`) let typing = ChannelId(7).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.
pub async fn webhooks(self, http: impl AsRef<Http>) -> Result<Vec<Webhook>>
[src]
Retrieves the channel's webhooks.
Note: Requires the Manage Webhooks permission.
pub fn await_reply<'a>(
&self,
shard_messenger: &'a impl AsRef<ShardMessenger>
) -> CollectReply<'a>ⓘNotable traits for CollectReply<'a>
impl<'a> Future for CollectReply<'a> type Output = Option<Arc<Message>>;
[src]
&self,
shard_messenger: &'a impl AsRef<ShardMessenger>
) -> CollectReply<'a>ⓘ
Notable traits for CollectReply<'a>
impl<'a> Future for CollectReply<'a> type Output = Option<Arc<Message>>;
Returns a future that will await one message sent in this channel.
pub fn await_replies<'a>(
&self,
shard_messenger: &'a impl AsRef<ShardMessenger>
) -> MessageCollectorBuilder<'a>ⓘNotable traits for MessageCollectorBuilder<'a>
impl<'a> Future for MessageCollectorBuilder<'a> type Output = MessageCollector;
[src]
&self,
shard_messenger: &'a impl AsRef<ShardMessenger>
) -> MessageCollectorBuilder<'a>ⓘ
Notable traits for MessageCollectorBuilder<'a>
impl<'a> Future for MessageCollectorBuilder<'a> type Output = MessageCollector;
Returns a stream builder which can be awaited to obtain a stream of messages in this channel.
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 in this guild.
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 sent in this channel.
impl ChannelId
[src]
pub fn created_at(&self) -> DateTime<Utc>
[src]
Retrieves the time that the Id was created at.
pub fn as_u64(&self) -> &u64
[src]
Immutably borrow inner Id.
pub fn as_mut_u64(&mut self) -> &mut u64
[src]
Mutably borrow inner Id.
Trait Implementations
impl AsRef<ChannelId> for ChannelId
[src]
impl Clone for ChannelId
[src]
impl Copy for ChannelId
[src]
impl Debug for ChannelId
[src]
impl Default for ChannelId
[src]
impl<'de> Deserialize<'de> for ChannelId
[src]
pub fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
[src]
deserializer: D
) -> StdResult<Self, D::Error>
impl Display for ChannelId
[src]
impl Eq for ChannelId
[src]
impl<'a> From<&'a Channel> for ChannelId
[src]
impl<'a> From<&'a ChannelId> for ChannelId
[src]
impl<'a> From<&'a GuildChannel> for ChannelId
[src]
pub fn from(public_channel: &GuildChannel) -> ChannelId
[src]
Gets the Id of a guild channel.
impl<'a> From<&'a PrivateChannel> for ChannelId
[src]
pub fn from(private_channel: &PrivateChannel) -> ChannelId
[src]
Gets the Id of a private channel.
impl From<Channel> for ChannelId
[src]
impl From<ChannelId> for u64
[src]
impl From<ChannelId> for i64
[src]
impl From<GuildChannel> for ChannelId
[src]
pub fn from(public_channel: GuildChannel) -> ChannelId
[src]
Gets the Id of a guild channel.
impl From<PrivateChannel> for ChannelId
[src]
pub fn from(private_channel: PrivateChannel) -> ChannelId
[src]
Gets the Id of a private channel.
impl From<u64> for ChannelId
[src]
impl FromStr for ChannelId
[src]
type Err = ChannelIdParseError
The associated error which can be returned from parsing.
pub fn from_str(s: &str) -> StdResult<Self, Self::Err>
[src]
impl Hash for ChannelId
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Mentionable for ChannelId
[src]
impl Ord for ChannelId
[src]
pub fn cmp(&self, other: &ChannelId) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<ChannelId> for ChannelId
[src]
impl PartialEq<u64> for ChannelId
[src]
impl PartialOrd<ChannelId> for ChannelId
[src]
pub fn partial_cmp(&self, other: &ChannelId) -> Option<Ordering>
[src]
pub fn lt(&self, other: &ChannelId) -> bool
[src]
pub fn le(&self, other: &ChannelId) -> bool
[src]
pub fn gt(&self, other: &ChannelId) -> bool
[src]
pub fn ge(&self, other: &ChannelId) -> bool
[src]
impl Serialize for ChannelId
[src]
pub fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for ChannelId
[src]
impl StructuralPartialEq for ChannelId
[src]
Auto Trait Implementations
impl RefUnwindSafe for ChannelId
[src]
impl Send for ChannelId
[src]
impl Sync for ChannelId
[src]
impl Unpin for ChannelId
[src]
impl UnwindSafe for ChannelId
[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<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<F> FromStrAndCache for F where
F: FromStr,
[src]
F: FromStr,
type Err = <F as FromStr>::Err
pub fn from_str<'life0, 'async_trait, CRL>(
CRL,
&'life0 str
) -> Pin<Box<dyn Future<Output = Result<F, <F as FromStrAndCache>::Err>> + 'async_trait + Send, Global>> where
'life0: 'async_trait,
F: 'async_trait,
CRL: AsRef<Cache> + Send + Sync + 'async_trait,
[src]
CRL,
&'life0 str
) -> Pin<Box<dyn Future<Output = Result<F, <F as FromStrAndCache>::Err>> + 'async_trait + Send, Global>> where
'life0: 'async_trait,
F: 'async_trait,
CRL: AsRef<Cache> + Send + Sync + 'async_trait,
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> 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]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,