Struct serenity::model::ChannelId
[−]
[src]
pub struct ChannelId(pub u64);
An identifier for a Channel
Methods
impl ChannelId
[src]
fn broadcast_typing(&self) -> 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();
fn create_permission(&self, target: &PermissionOverwrite) -> Result<()>
[src]
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.
fn create_reaction<M, R>(&self, message_id: M, reaction_type: R) -> Result<()> where
M: Into<MessageId>,
R: Into<ReactionType>,
[src]
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.
fn delete(&self) -> Result<Channel>
[src]
Deletes this channel, returning the channel on a successful deletion.
fn delete_message<M: Into<MessageId>>(&self, message_id: M) -> Result<()>
[src]
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.
fn delete_messages<T: AsRef<MessageId>, It: IntoIterator<Item = T>>(
&self,
message_ids: It
) -> Result<()>
[src]
&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: This uses bulk delete endpoint which is not available for user accounts.
Note: Messages that are older than 2 weeks can't be deleted using this method.
fn delete_permission(
&self,
permission_type: PermissionOverwriteType
) -> Result<()>
[src]
&self,
permission_type: PermissionOverwriteType
) -> Result<()>
Deletes all permission overrides in the channel from a member or role.
Note: Requires the Manage Channel permission.
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]
&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.
fn edit<F: FnOnce(EditChannel) -> EditChannel>(
&self,
f: F
) -> Result<GuildChannel>
[src]
&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));
fn edit_message<F, M>(&self, message_id: M, f: F) -> Result<Message> where
F: FnOnce(CreateMessage) -> CreateMessage,
M: Into<MessageId>,
[src]
F: FnOnce(CreateMessage) -> CreateMessage,
M: Into<MessageId>,
Edits a Message
in the channel given its Id.
Message editing preserves all unchanged message data.
Refer to the documentation for CreateMessage
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.
fn find(&self) -> Option<Channel>
[src]
Search the cache for the channel with the Id.
fn get(&self) -> Result<Channel>
[src]
Search the cache for the channel. If it can't be found, the channel is requested over REST.
fn invites(&self) -> Result<Vec<RichInvite>>
[src]
Gets all of the channel's invites.
Requires the Manage Channels permission.
fn message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message>
[src]
Gets a message from the channel.
Requires the Read Message History permission.
fn messages<F>(&self, f: F) -> Result<Vec<Message>> where
F: FnOnce(GetMessages) -> GetMessages,
[src]
F: FnOnce(GetMessages) -> GetMessages,
Gets messages from the channel.
Refer to Channel::messages
for more information.
Requires the Read Message History permission.
fn name(&self) -> Option<String>
[src]
Returns the name of whatever channel this id holds.
fn pin<M: Into<MessageId>>(&self, message_id: M) -> Result<()>
[src]
Pins a Message
to the channel.
fn pins(&self) -> Result<Vec<Message>>
[src]
Gets the list of Message
s which are pinned to the channel.
fn reaction_users<M, R, U>(
&self,
message_id: M,
reaction_type: R,
limit: Option<u8>,
after: Option<U>
) -> Result<Vec<User>> where
M: Into<MessageId>,
R: Into<ReactionType>,
U: Into<UserId>,
[src]
&self,
message_id: M,
reaction_type: R,
limit: Option<u8>,
after: Option<U>
) -> Result<Vec<User>> where
M: Into<MessageId>,
R: Into<ReactionType>,
U: Into<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.
fn say<D: Display>(&self, content: D) -> Result<Message>
[src]
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.
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]
&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.
An embed can not be sent when sending a file. If you set one, it will be automatically removed.
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::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::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.
fn send_message<F>(&self, f: F) -> Result<Message> where
F: FnOnce(CreateMessage) -> CreateMessage,
[src]
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.
fn unpin<M: Into<MessageId>>(&self, message_id: M) -> Result<()>
[src]
Unpins a Message
in the channel given by its Id.
Requires the Manage Messages permission.
fn webhooks(&self) -> Result<Vec<Webhook>>
[src]
Retrieves the channel's webhooks.
Note: Requires the Manage Webhooks permission.
impl ChannelId
[src]
fn created_at(&self) -> NaiveDateTime
[src]
Retrieves the time that the Id was created at.
Trait Implementations
impl From<Channel> for ChannelId
[src]
impl<'a> From<&'a Channel> for ChannelId
[src]
impl From<PrivateChannel> for ChannelId
[src]
fn from(private_channel: PrivateChannel) -> ChannelId
[src]
Gets the Id of a private 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<GuildChannel> for ChannelId
[src]
fn from(public_channel: GuildChannel) -> ChannelId
[src]
Gets the Id of a guild channel.
impl<'a> From<&'a GuildChannel> for ChannelId
[src]
fn from(public_channel: &GuildChannel) -> ChannelId
[src]
Gets the Id of a guild channel.
impl Mentionable for ChannelId
[src]
fn mention(&self) -> String
[src]
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]
type Err = ()
The associated error which can be returned from parsing.
fn from_str(s: &str) -> StdResult<Self, ()>
[src]
Parses a string s
to return a value of this type. Read more
impl Copy for ChannelId
[src]
impl Clone for ChannelId
[src]
fn clone(&self) -> ChannelId
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for ChannelId
[src]
impl Debug for ChannelId
[src]
impl Eq for ChannelId
[src]
impl Hash for ChannelId
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
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]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialOrd for ChannelId
[src]
fn partial_cmp(&self, __arg_0: &ChannelId) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &ChannelId) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &ChannelId) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &ChannelId) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &ChannelId) -> bool
[src]
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]
fn cmp(&self, __arg_0: &ChannelId) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl AsRef<ChannelId> for ChannelId
[src]
impl From<u64> for ChannelId
[src]
impl PartialEq for ChannelId
[src]
fn eq(&self, other: &Self) -> bool
[src]
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]
This method tests for !=
.
impl PartialEq<u64> for ChannelId
[src]
fn eq(&self, u: &u64) -> bool
[src]
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]
This method tests for !=
.
impl Display for ChannelId
[src]
fn fmt(&self, f: &mut Formatter) -> FmtResult
[src]
Formats the value using the given formatter. Read more
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>
Deserialize this value from the given Serde deserializer. Read more