Struct serenity::model::ChannelId
[−]
[src]
pub struct ChannelId(pub u64);
An identifier for a Channel
Methods
impl ChannelId
[src]
fn ack<M: Into<MessageId>>(&self, message_id: M) -> Result<()>
Marks a Channel
as being read up to a certain Message
.
Refer to the documentation for rest::ack_message
for more
information.
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();
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.
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.
fn delete(&self) -> Result<Channel>
Deletes this channel, returning the channel on a successful deletion.
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.
fn delete_messages(&self, message_ids: &[MessageId]) -> 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<()>
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>
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>
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:
context.edit_channel(channel_id, |c| c .name("test") .bitrate(64000));
Errors
Returns a ClientError::NoChannelId
if the current context is not
related to a channel.
fn edit_message<F, M>(&self, message_id: M, text: &str, f: F) -> Result<Message> where F: FnOnce(CreateEmbed) -> CreateEmbed, M: Into<MessageId>
Edits a Message
in the channel given its Id.
Pass an empty string (""
) to text
if you are editing a message with
an embed or file but no content. Otherwise, text
must be given.
Note: Requires that the current user be the author of the message.
Errors
Returns a ClientError::NoChannelId
if the current context is not
related to a channel.
fn find(&self) -> Option<Channel>
Search the cache for the channel with the Id.
fn get(&self) -> Result<Channel>
Search the cache for the channel. If it can't be found, the channel is requested over REST.
fn get_invites(&self) -> Result<Vec<RichInvite>>
Gets all of the channel's invites.
Requires the Manage Channels permission.
fn get_message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message>
Gets a message from the channel.
Requires the Read Message History permission.
fn get_messages<F>(&self, f: F) -> Result<Vec<Message>> where F: FnOnce(GetMessages) -> GetMessages
Gets messages from the channel.
Refer to Channel::get_messages
for more information.
Requires the Read Message History permission.
fn get_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>
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::get_reaction_users
for more information.
Note: Requires the Read Message History permission.
fn get_webhooks(&self) -> Result<Vec<Webhook>>
Retrieves the channel's webhooks.
Note: Requires the Manage Webhooks permission.
fn pin<M: Into<MessageId>>(&self, message_id: M) -> Result<()>
Pins a Message
to the channel.
fn pins(&self) -> Result<Vec<Message>>
Gets the list of Message
s which are pinned to the channel.
fn search<F: FnOnce(Search) -> Search>(&self, f: F) -> Result<SearchResult>
Searches the channel's messages by providing query parameters via the search builder.
Refer to the documentation for the Search
builder for restrictions
and defaults parameters, as well as potentially advanced usage.
Note: Bot users can not search.
Examples
Refer to the Search
builder's documentation for examples,
specifically the section on [searching a channel][search channel].
fn send_file<F, R>(&self, file: R, filename: &str, f: F) -> Result<Message> where F: FnOnce(CreateMessage) -> CreateMessage, R: Read
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.
Requires 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
ClientError::MessageTooLong
will be returned, containing the number
of unicode code points over the limit.
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 is required.
Note: Message contents must be under 2000 unicode code points.
Errors
Returns a ClientError::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<()>
Unpins a Message
in the channel given by its Id.
Requires the Manage Messages permission.
impl ChannelId
[src]
fn created_at(&self) -> Timespec
Retrieves the time that the Id was created at.
Trait Implementations
impl From<Channel> for ChannelId
[src]
impl From<PrivateChannel> for ChannelId
[src]
fn from(private_channel: PrivateChannel) -> ChannelId
Gets the Id of a private channel.
impl From<GuildChannel> for ChannelId
[src]
fn from(public_channel: GuildChannel) -> ChannelId
Gets the Id of a guild channel.
impl Display for ChannelId
[src]
impl Mentionable for ChannelId
[src]
impl FromStr for ChannelId
[src]
type Err = ()
The associated error which can be returned from parsing.
fn from_str(s: &str) -> StdResult<Self, ()>
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
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for ChannelId
[src]
impl Eq for ChannelId
[src]
impl Hash for ChannelId
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl PartialOrd for ChannelId
[src]
fn partial_cmp(&self, __arg_0: &ChannelId) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &ChannelId) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &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, __arg_0: &ChannelId) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &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]
fn cmp(&self, __arg_0: &ChannelId) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl From<u64> for ChannelId
[src]
impl PartialEq for ChannelId
[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
This method tests for !=
.