[−][src]Struct serenity::model::id::ChannelId
An identifier for a Channel
Methods
impl ChannelId
[src]
pub 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::ChannelId; let _successful = ChannelId(7).broadcast_typing();
pub 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 fn create_reaction<M, R>(
self,
http: impl AsRef<Http>,
message_id: M,
reaction_type: R
) -> Result<()> where
M: Into<MessageId>,
R: Into<ReactionType>,
[src]
self,
http: impl AsRef<Http>,
message_id: M,
reaction_type: R
) -> Result<()> where
M: Into<MessageId>,
R: Into<ReactionType>,
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 fn delete(self, http: impl AsRef<Http>) -> Result<Channel>
[src]
Deletes this channel, returning the channel on a successful deletion.
pub fn delete_message<M: Into<MessageId>>(
self,
http: impl AsRef<Http>,
message_id: M
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
message_id: M
) -> 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 fn delete_messages<T: AsRef<MessageId>, It: IntoIterator<Item = T>>(
self,
http: impl AsRef<Http>,
message_ids: It
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
message_ids: It
) -> Result<()>
Deletes all messages by Ids from the given vector in the given channel.
Refer to the documentation for Channel::delete_messages
for more
information.
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 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 fn delete_reaction<M, R>(
self,
http: impl AsRef<Http>,
message_id: M,
user_id: Option<UserId>,
reaction_type: R
) -> Result<()> where
M: Into<MessageId>,
R: Into<ReactionType>,
[src]
self,
http: impl AsRef<Http>,
message_id: M,
user_id: Option<UserId>,
reaction_type: R
) -> Result<()> where
M: Into<MessageId>,
R: Into<ReactionType>,
Deletes the given Reaction
from the channel.
Note: Requires the Manage Messages permission, if the current user did not perform the reaction.
pub fn edit<F: FnOnce(&mut EditChannel) -> &mut EditChannel>(
self,
http: impl AsRef<Http>,
f: F
) -> Result<GuildChannel>
[src]
self,
http: impl AsRef<Http>,
f: F
) -> Result<GuildChannel>
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(&context, |c| c.name("test").bitrate(64000));
pub fn edit_message<F, M>(
self,
http: impl AsRef<Http>,
message_id: M,
f: F
) -> Result<Message> where
F: FnOnce(&mut EditMessage) -> &mut EditMessage,
M: Into<MessageId>,
[src]
self,
http: impl AsRef<Http>,
message_id: M,
f: F
) -> Result<Message> where
F: FnOnce(&mut EditMessage) -> &mut EditMessage,
M: Into<MessageId>,
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 to_channel_cached(
self,
cache: impl AsRef<CacheRwLock>
) -> Option<Channel>
[src]
self,
cache: impl AsRef<CacheRwLock>
) -> Option<Channel>
Attempts to find a Channel
by its Id in the cache.
pub 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 fn invites(self, http: impl AsRef<Http>) -> Result<Vec<RichInvite>>
[src]
Gets all of the channel's invites.
Requires the Manage Channels permission.
pub fn message<M: Into<MessageId>>(
self,
http: impl AsRef<Http>,
message_id: M
) -> Result<Message>
[src]
self,
http: impl AsRef<Http>,
message_id: M
) -> Result<Message>
Gets a message from the channel.
Requires the Read Message History permission.
pub 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, cache: impl AsRef<CacheRwLock>) -> Option<String>
[src]
Returns the name of whatever channel this id holds.
pub fn pin<M: Into<MessageId>>(
self,
http: impl AsRef<Http>,
message_id: M
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
message_id: M
) -> Result<()>
Pins a Message
to the channel.
pub fn pins(self, http: impl AsRef<Http>) -> Result<Vec<Message>>
[src]
Gets the list of Message
s which are pinned to the channel.
pub fn reaction_users<M, R, U>(
self,
http: impl AsRef<Http>,
message_id: M,
reaction_type: R,
limit: Option<u8>,
after: U
) -> Result<Vec<User>> where
M: Into<MessageId>,
R: Into<ReactionType>,
U: Into<Option<UserId>>,
[src]
self,
http: impl AsRef<Http>,
message_id: M,
reaction_type: R,
limit: Option<u8>,
after: U
) -> Result<Vec<User>> where
M: Into<MessageId>,
R: Into<ReactionType>,
U: Into<Option<UserId>>,
Gets the list of User
s who have reacted to a Message
with a
certain Emoji
.
Refer to Channel::reaction_users
for more information.
Note: Requires the Read Message History permission.
pub 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 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") });
Send files using File
:
use serenity::model::id::ChannelId; use std::fs::File; let channel_id = ChannelId(7); let f1 = File::open("my_file.jpg").unwrap(); let f2 = File::open("my_file2.jpg").unwrap(); let files = vec![(&f1, "my_file.jpg"), (&f2, "my_file2.jpg")]; let _ = channel_id.send_files(&http, files, |m| { m.content("a file") });
Errors
If the content of the message is over the above limit, then a
ClientError::MessageTooLong
will be returned, containing the number
of unicode code points over the limit.
Returns an
HttpError::InvalidRequest(PayloadTooLarge)
if the file is too large to send.
pub 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 unpin<M: Into<MessageId>>(
self,
http: impl AsRef<Http>,
message_id: M
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
message_id: M
) -> Result<()>
Unpins a Message
in the channel given by its Id.
Requires the Manage Messages permission.
pub fn webhooks(self, http: impl AsRef<Http>) -> Result<Vec<Webhook>>
[src]
Retrieves the channel's webhooks.
Note: Requires the Manage Webhooks permission.
impl ChannelId
[src]
pub fn created_at(&self) -> DateTime<FixedOffset>
[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]
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]
fn from(public_channel: &GuildChannel) -> ChannelId
[src]
Gets the Id of a guild channel.
impl<'a> From<&'a PrivateChannel> for ChannelId
[src]
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]
fn from(public_channel: GuildChannel) -> ChannelId
[src]
Gets the Id of a guild channel.
impl From<PrivateChannel> for ChannelId
[src]
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.
fn from_str(s: &str) -> StdResult<Self, Self::Err>
[src]
impl Hash for ChannelId
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
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]
fn cmp(&self, other: &ChannelId) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<ChannelId> for ChannelId
[src]
impl PartialEq<u64> for ChannelId
[src]
impl PartialOrd<ChannelId> for ChannelId
[src]
fn partial_cmp(&self, other: &ChannelId) -> Option<Ordering>
[src]
fn lt(&self, other: &ChannelId) -> bool
[src]
fn le(&self, other: &ChannelId) -> bool
[src]
fn gt(&self, other: &ChannelId) -> bool
[src]
fn ge(&self, other: &ChannelId) -> bool
[src]
impl Serialize for ChannelId
[src]
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
impl Send for ChannelId
impl Sync for ChannelId
impl Unpin for ChannelId
impl UnwindSafe for ChannelId
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CloneAny for T where
T: Clone + Any,
[src]
T: Clone + Any,
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
[src]
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
[src]
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
[src]
T: Sync,
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Send + Sync> where
T: Send + Sync,
[src]
T: Send + Sync,
impl<T> DebugAny for T where
T: Any + Debug,
[src]
T: Any + Debug,
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,
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
fn from_str(
impl AsRef<CacheRwLock>,
&str
) -> Result<F, <F as FromStrAndCache>::Err>
[src]
impl AsRef<CacheRwLock>,
&str
) -> Result<F, <F as FromStrAndCache>::Err>
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.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<'a, T> TryFrom<&'a str> for T where
T: FromStr,
T: FromStr,
type Err = <T as FromStr>::Err
fn try_from(string: &'a str) -> Result<T, <T as TryFrom<&'a str>>::Err>
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.
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,
impl<T> UnsafeAny for T where
T: Any,
T: Any,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,