Enum serenity::model::Channel
[−]
[src]
pub enum Channel { Group(Arc<RwLock<Group>>), Guild(Arc<RwLock<GuildChannel>>), Private(Arc<RwLock<PrivateChannel>>), }
A container for any channel.
Variants
Group(Arc<RwLock<Group>>)
A group. A group comprises of only one channel.
Guild(Arc<RwLock<GuildChannel>>)
Private(Arc<RwLock<PrivateChannel>>)
A private channel to another User
. No other users may access the
channel. For multi-user "private channels", use a group.
Methods
impl Channel
[src]
fn create_reaction<M, R>(&self, message_id: M, reaction_type: R) -> Result<()> where
M: Into<MessageId>,
R: Into<ReactionType>,
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<()>
Deletes the inner channel.
Note: There is no real function as deleting a Group
. The
closest functionality is leaving it.
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<()>
: Use the inner channel's delete_messages
method instead.
Deletes all messages by Ids from the given vector in the channel.
The minimum amount of messages is 2 and the maximum amount is 100.
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<()>
&self,
permission_type: PermissionOverwriteType
) -> Result<()>
: Use the inner channel's delete_permission
method instead.
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>,
&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_message<F, M>(&self, message_id: M, f: F) -> Result<Message> where
F: FnOnce(CreateMessage) -> CreateMessage,
M: Into<MessageId>,
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 is_nsfw(&self) -> bool
Determines if the channel is NSFW.
Refer to utils::is_nsfw
for more details.
fn message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message>
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,
F: FnOnce(GetMessages) -> GetMessages,
Gets messages from the channel.
Requires the Read Message History permission.
Examples
use serenity::model::MessageId; let id = MessageId(81392407232380928); // Maximum is 100. let _messages = channel.get_messages(|g| g.after(id).limit(100));
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>,
&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
.
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.
fn id(&self) -> ChannelId
Retrieves the Id of the inner Group
, GuildChannel
, or
PrivateChannel
.
fn say(&self, content: &str) -> 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.
fn send_file<F, R>(&self, file: R, filename: &str, f: F) -> Result<Message> where
F: FnOnce(CreateMessage) -> CreateMessage,
R: Read,
F: FnOnce(CreateMessage) -> CreateMessage,
R: Read,
: Please use send_files
instead.
Sends a file along with optional message contents. The filename must be specified.
Refer to ChannelId::send_file
for examples and more information.
The Attach Files and Send Messages permissions are required.
Note: Message contents must be under 2000 unicode code points.
Errors
Returns an
HttpError::InvalidRequest(PayloadTooLarge)
if the file is too large to send.
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.
fn send_files<'a, F, T>(&self, files: Vec<T>, f: F) -> Result<Message> where
F: FnOnce(CreateMessage) -> CreateMessage,
T: Into<AttachmentType<'a>>,
F: FnOnce(CreateMessage) -> CreateMessage,
T: Into<AttachmentType<'a>>,
Sends (a) file(s) along with optional message contents.
Refer to ChannelId::send_files
for examples and more information.
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,
F: FnOnce(CreateMessage) -> CreateMessage,
Sends a message to the channel.
Refer to the documentation for CreateMessage
for more information
regarding message restrictions and requirements.
The Send Messages permission is required.
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<()>
Unpins a Message
in the channel given by its Id.
Requires the Manage Messages permission.
fn get_message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message>
: Use message
instead.
Alias of message
.
fn get_messages<F>(&self, f: F) -> Result<Vec<Message>> where
F: FnOnce(GetMessages) -> GetMessages,
F: FnOnce(GetMessages) -> GetMessages,
: Use messages
instead.
Alias of messages
.
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>,
&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>,
: Use reaction_users
instead.
Alias of reaction_users
.
Trait Implementations
impl Clone for Channel
[src]
fn clone(&self) -> Channel
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 Channel
[src]
impl<'de> Deserialize<'de> for Channel
[src]
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
deserializer: D
) -> StdResult<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Display for Channel
[src]
fn fmt(&self, f: &mut Formatter) -> FmtResult
Formats the channel into a "mentioned" string.
This will return a different format for each type of channel:
Group
s: the generated name retrievable viaGroup::name
;PrivateChannel
s: the recipient's name;GuildChannel
s: a string mentioning the channel that users who can see the channel can click on.
impl Mentionable for Channel
[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