Struct serenity::model::id::ChannelId [−][src]
pub struct ChannelId(pub u64);
An identifier for a Channel
Methods
impl ChannelId
[src]
impl ChannelId
pub fn broadcast_typing(&self) -> Result<()>
[src]
pub fn broadcast_typing(&self) -> Result<()>
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, target: &PermissionOverwrite) -> Result<()>
[src]
pub fn create_permission(&self, 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,
message_id: M,
reaction_type: R
) -> Result<()> where
M: Into<MessageId>,
R: Into<ReactionType>,
[src]
pub fn create_reaction<M, R>(
&self,
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) -> Result<Channel>
[src]
pub fn delete(&self) -> Result<Channel>
Deletes this channel, returning the channel on a successful deletion.
pub fn delete_message<M: Into<MessageId>>(&self, message_id: M) -> Result<()>
[src]
pub fn delete_message<M: Into<MessageId>>(&self, 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,
message_ids: It
) -> Result<()>
[src]
pub fn delete_messages<T: AsRef<MessageId>, It: IntoIterator<Item = T>>(
&self,
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,
permission_type: PermissionOverwriteType
) -> Result<()>
[src]
pub fn delete_permission(
&self,
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,
message_id: M,
user_id: Option<UserId>,
reaction_type: R
) -> Result<()> where
M: Into<MessageId>,
R: Into<ReactionType>,
[src]
pub fn delete_reaction<M, R>(
&self,
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(EditChannel) -> EditChannel>(
&self,
f: F
) -> Result<GuildChannel>
[src]
pub fn edit<F: FnOnce(EditChannel) -> EditChannel>(
&self,
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(|c| c.name("test").bitrate(64000));
pub fn edit_message<F, M>(&self, message_id: M, f: F) -> Result<Message> where
F: FnOnce(EditMessage) -> EditMessage,
M: Into<MessageId>,
[src]
pub fn edit_message<F, M>(&self, message_id: M, f: F) -> Result<Message> where
F: FnOnce(EditMessage) -> 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 find(&self) -> Option<Channel>
[src]
pub fn find(&self) -> Option<Channel>
Search the cache for the channel with the Id.
pub fn get(&self) -> Result<Channel>
[src]
pub fn get(&self) -> Result<Channel>
Search the cache for the channel. If it can't be found, the channel is requested over REST.
pub fn invites(&self) -> Result<Vec<RichInvite>>
[src]
pub fn invites(&self) -> Result<Vec<RichInvite>>
Gets all of the channel's invites.
Requires the [Manage Channels] permission. [Manage Channels]: permissions/constant.MANAGE_CHANNELS.html
pub fn message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message>
[src]
pub fn message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message>
Gets a message from the channel.
Requires the Read Message History permission.
pub fn messages<F>(&self, f: F) -> Result<Vec<Message>> where
F: FnOnce(GetMessages) -> GetMessages,
[src]
pub fn messages<F>(&self, f: F) -> Result<Vec<Message>> where
F: FnOnce(GetMessages) -> GetMessages,
Gets messages from the channel.
Refer to Channel::messages
for more information.
Requires the Read Message History permission.
pub fn name(&self) -> Option<String>
[src]
pub fn name(&self) -> Option<String>
Returns the name of whatever channel this id holds.
pub fn pin<M: Into<MessageId>>(&self, message_id: M) -> Result<()>
[src]
pub fn pin<M: Into<MessageId>>(&self, message_id: M) -> Result<()>
Pins a Message
to the channel.
pub fn pins(&self) -> Result<Vec<Message>>
[src]
pub fn pins(&self) -> Result<Vec<Message>>
Gets the list of Message
s which are pinned to the channel.
pub fn reaction_users<M, R, U>(
&self,
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]
pub fn reaction_users<M, R, U>(
&self,
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<D: Display>(&self, content: D) -> Result<Message>
[src]
pub fn say<D: Display>(&self, content: D) -> 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: IntoIterator<Item = T>>(
&self,
files: It,
f: F
) -> Result<Message> where
F: FnOnce(CreateMessage) -> CreateMessage,
T: Into<AttachmentType<'a>>,
[src]
pub fn send_files<'a, F, T, It: IntoIterator<Item = T>>(
&self,
files: It,
f: F
) -> Result<Message> where
F: FnOnce(CreateMessage) -> CreateMessage,
T: Into<AttachmentType<'a>>,
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(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(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<F>(&self, f: F) -> Result<Message> where
F: FnOnce(CreateMessage) -> CreateMessage,
[src]
pub fn send_message<F>(&self, f: F) -> Result<Message> where
F: FnOnce(CreateMessage) -> CreateMessage,
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, message_id: M) -> Result<()>
[src]
pub fn unpin<M: Into<MessageId>>(&self, message_id: M) -> Result<()>
Unpins a Message
in the channel given by its Id.
Requires the Manage Messages permission.
pub fn webhooks(&self) -> Result<Vec<Webhook>>
[src]
pub fn webhooks(&self) -> Result<Vec<Webhook>>
Retrieves the channel's webhooks.
Note: Requires the Manage Webhooks permission.
impl ChannelId
[src]
impl ChannelId
pub fn created_at(&self) -> NaiveDateTime
[src]
pub fn created_at(&self) -> NaiveDateTime
Retrieves the time that the Id was created at.
Trait Implementations
impl From<Channel> for ChannelId
[src]
impl From<Channel> for ChannelId
impl<'a> From<&'a Channel> for ChannelId
[src]
impl<'a> From<&'a Channel> for ChannelId
impl From<PrivateChannel> for ChannelId
[src]
impl From<PrivateChannel> for ChannelId
fn from(private_channel: PrivateChannel) -> ChannelId
[src]
fn from(private_channel: PrivateChannel) -> ChannelId
Gets the Id of a private channel.
impl<'a> From<&'a PrivateChannel> for ChannelId
[src]
impl<'a> From<&'a PrivateChannel> for ChannelId
fn from(private_channel: &PrivateChannel) -> ChannelId
[src]
fn from(private_channel: &PrivateChannel) -> ChannelId
Gets the Id of a private channel.
impl From<GuildChannel> for ChannelId
[src]
impl From<GuildChannel> for ChannelId
fn from(public_channel: GuildChannel) -> ChannelId
[src]
fn from(public_channel: GuildChannel) -> ChannelId
Gets the Id of a guild channel.
impl<'a> From<&'a GuildChannel> for ChannelId
[src]
impl<'a> From<&'a GuildChannel> for ChannelId
fn from(public_channel: &GuildChannel) -> ChannelId
[src]
fn from(public_channel: &GuildChannel) -> ChannelId
Gets the Id of a guild channel.
impl Copy for ChannelId
[src]
impl Copy for ChannelId
impl Clone for ChannelId
[src]
impl Clone for ChannelId
fn clone(&self) -> ChannelId
[src]
fn clone(&self) -> ChannelId
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Default for ChannelId
[src]
impl Default for ChannelId
impl Debug for ChannelId
[src]
impl Debug for ChannelId
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Eq for ChannelId
[src]
impl Eq for ChannelId
impl Hash for ChannelId
[src]
impl Hash for ChannelId
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialOrd for ChannelId
[src]
impl PartialOrd for ChannelId
fn partial_cmp(&self, other: &ChannelId) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &ChannelId) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &ChannelId) -> bool
[src]
fn lt(&self, other: &ChannelId) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &ChannelId) -> bool
[src]
fn le(&self, other: &ChannelId) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &ChannelId) -> bool
[src]
fn gt(&self, other: &ChannelId) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &ChannelId) -> bool
[src]
fn ge(&self, other: &ChannelId) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for ChannelId
[src]
impl Ord for ChannelId
fn cmp(&self, other: &ChannelId) -> Ordering
[src]
fn cmp(&self, other: &ChannelId) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl AsRef<ChannelId> for ChannelId
[src]
impl AsRef<ChannelId> for ChannelId
impl<'a> From<&'a ChannelId> for ChannelId
[src]
impl<'a> From<&'a ChannelId> for ChannelId
impl From<u64> for ChannelId
[src]
impl From<u64> for ChannelId
impl PartialEq for ChannelId
[src]
impl PartialEq for ChannelId
fn eq(&self, other: &Self) -> bool
[src]
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl PartialEq<u64> for ChannelId
[src]
impl PartialEq<u64> for ChannelId
fn eq(&self, u: &u64) -> bool
[src]
fn eq(&self, u: &u64) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Display for ChannelId
[src]
impl Display for ChannelId
fn fmt(&self, f: &mut Formatter) -> FmtResult
[src]
fn fmt(&self, f: &mut Formatter) -> FmtResult
Formats the value using the given formatter. Read more
impl<'de> Deserialize<'de> for ChannelId
[src]
impl<'de> Deserialize<'de> for ChannelId
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
[src]
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Mentionable for ChannelId
[src]
impl Mentionable for ChannelId
fn mention(&self) -> String
[src]
fn mention(&self) -> String
Creates a mentionable string, that will be able to notify and/or create a link to the item. Read more
impl FromStr for ChannelId
[src]
impl FromStr for ChannelId