[][src]Enum serenity::model::channel::Channel

pub enum Channel {
    Group(Arc<RwLock<Group>>),
    Guild(Arc<RwLock<GuildChannel>>),
    Private(Arc<RwLock<PrivateChannel>>),
    Category(Arc<RwLock<ChannelCategory>>),
}

A container for any channel.

Variants

Group(Arc<RwLock<Group>>)

A group. A group comprises of only one channel.

Guild(Arc<RwLock<GuildChannel>>)

A text or voice channel within a Guild.

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.

Category(Arc<RwLock<ChannelCategory>>)

A category of GuildChannels

Methods

impl Channel[src]

pub fn group(self) -> Option<Arc<RwLock<Group>>>[src]

Converts from Channel to Option<Arc<RwLock<Group>>>.

Converts self into an Option<Arc<RwLock<Group>>>, consuming self, and discarding a GuildChannel, PrivateChannel, or ChannelCategory, if any.

Examples

Basic usage:

match channel.group() {
    Some(group_lock) => {
        if let Some(ref name) = group_lock.read().name {
            println!("It's a group named {}!", name);
        } else {
             println!("It's an unnamed group!");
        }
    },
    None => { println!("It's not a group!"); },
}
fn main() {}

pub fn guild(self) -> Option<Arc<RwLock<GuildChannel>>>[src]

Converts from Channel to Option<Arc<RwLock<GuildChannel>>>.

Converts self into an Option<Arc<RwLock<GuildChannel>>>, consuming self, and discarding a Group, PrivateChannel, or ChannelCategory, if any.

Examples

Basic usage:

match channel.guild() {
    Some(guild_lock) => {
        println!("It's a guild named {}!", guild_lock.read().name);
    },
    None => { println!("It's not a guild!"); },
}
fn main() {}

pub fn private(self) -> Option<Arc<RwLock<PrivateChannel>>>[src]

Converts from Channel to Option<Arc<RwLock<PrivateChannel>>>.

Converts self into an Option<Arc<RwLock<PrivateChannel>>>, consuming self, and discarding a Group, GuildChannel, or ChannelCategory, if any.

Examples

Basic usage:

match channel.private() {
    Some(private_lock) => {
        let private = private_lock.read();
        let recipient_lock = &private.recipient;
        let recipient = recipient_lock.read();
        println!("It's a private channel with {}!", recipient.name);
    },
    None => { println!("It's not a private channel!"); },
}
fn main() {}

pub fn category(self) -> Option<Arc<RwLock<ChannelCategory>>>[src]

Converts from Channel to Option<Arc<RwLock<ChannelCategory>>>.

Converts self into an Option<Arc<RwLock<ChannelCategory>>>, consuming self, and discarding a Group, GuildChannel, or PrivateChannel, if any.

Examples

Basic usage:

match channel.category() {
    Some(category_lock) => {
        println!("It's a category named {}!", category_lock.read().name);
    },
    None => { println!("It's not a category!"); },
}
fn main() {}

pub fn create_reaction<M, R>(
    &self,
    message_id: M,
    reaction_type: R
) -> Result<()> where
    M: Into<MessageId>,
    R: Into<ReactionType>, 
[src]

Deprecated since 0.4.2:

Use the inner channel's method

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<()>[src]

Deletes the inner channel.

Note: There is no real function as deleting a Group. The closest functionality is leaving it.

pub fn delete_message<M: Into<MessageId>>(&self, message_id: M) -> Result<()>[src]

Deprecated since 0.4.2:

Use the inner channel's method

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_reaction<M, R>(
    &self,
    message_id: M,
    user_id: Option<UserId>,
    reaction_type: R
) -> Result<()> where
    M: Into<MessageId>,
    R: Into<ReactionType>, 
[src]

Deprecated since 0.4.2:

Use the inner channel's method

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_message<F, M>(&self, message_id: M, f: F) -> Result<Message> where
    F: FnOnce(EditMessage) -> EditMessage,
    M: Into<MessageId>, 
[src]

Deprecated since 0.4.2:

Use the inner channel's method

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 is_nsfw(&self) -> bool[src]

Determines if the channel is NSFW.

pub fn message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message>[src]

Deprecated since 0.4.2:

Use the inner channel's method

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]

Deprecated since 0.4.2:

Use the inner channel's method

Gets messages from the channel.

Requires the Read Message History permission.

Examples

This example is not tested
use serenity::model::MessageId;

let id = MessageId(81392407232380928);

// Maximum is 100.
let _messages = channel.messages(|g| g.after(id).limit(100));

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]

Deprecated since 0.4.2:

Use the inner channel's method

Gets the list of Users 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.

pub fn id(&self) -> ChannelId[src]

Retrieves the Id of the inner Group, GuildChannel, or PrivateChannel.

pub fn position(&self) -> Option<i64>[src]

Retrieves the position of the inner GuildChannel or ChannelCategory.

If other channel types are used it will return None.

pub fn say(&self, content: &str) -> Result<Message>[src]

Deprecated since 0.4.2:

Use the inner channel's method

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]

Deprecated since 0.4.2:

Use the inner channel's method

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.

pub fn send_message<F>(&self, f: F) -> Result<Message> where
    F: FnOnce(CreateMessage) -> CreateMessage
[src]

Deprecated since 0.4.2:

Use the inner channel's method

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.

pub fn unpin<M: Into<MessageId>>(&self, message_id: M) -> Result<()>[src]

Deprecated since 0.4.2:

Use the inner channel's method

Unpins a Message in the channel given by its Id.

Requires the Manage Messages permission.

Trait Implementations

impl Mentionable for Channel[src]

impl From<Channel> for ChannelId[src]

fn from(channel: Channel) -> ChannelId[src]

Gets the Id of a Channel.

impl<'a> From<&'a Channel> for ChannelId[src]

fn from(channel: &Channel) -> ChannelId[src]

Gets the Id of a Channel.

impl Clone for Channel[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Display for Channel[src]

fn fmt(&self, f: &mut Formatter) -> FmtResult[src]

Formats the channel into a "mentioned" string.

This will return a different format for each type of channel:

impl Debug for Channel[src]

impl FromStr for Channel[src]

type Err = ChannelParseError

The associated error which can be returned from parsing.

impl Serialize for Channel[src]

impl<'de> Deserialize<'de> for Channel[src]

Auto Trait Implementations

impl Send for Channel

impl Sync for Channel

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Erased for T

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.

impl<T> DebugAny for T where
    T: Any + Debug
[src]

impl<T> CloneAny for T where
    T: Clone + Any
[src]

impl<T> UnsafeAny for T where
    T: Any