[][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>>),
    // some variants omitted
}

A container for any channel.

Variants

Group(Arc<RwLock<Group>>)

A group. A group comprises of only one channel.

A text or voice channel within a Guild.

A private channel to another User. No other users may access the channel. For multi-user "private channels", use a group.

A category of GuildChannels

Implementations

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 delete(&self, cache_http: impl CacheHttp) -> Result<()>[src]

Deletes the inner channel.

Note: If the cache-feature is enabled permissions will be checked and upon owning the required permissions the HTTP-request will be issued.

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

pub fn is_nsfw(&self) -> bool[src]

Determines if the channel is NSFW.

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.

Trait Implementations

impl Clone for Channel[src]

impl Debug for Channel[src]

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

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<'a> From<&'a Channel> for ChannelId[src]

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

Gets the Id of a Channel.

impl From<Channel> for ChannelId[src]

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

Gets the Id of a Channel.

impl FromStrAndCache for Channel[src]

type Err = ChannelParseError

impl Mentionable for Channel[src]

impl Serialize for Channel[src]

Auto Trait Implementations

impl !RefUnwindSafe for Channel

impl Send for Channel

impl Sync for Channel

impl Unpin for Channel

impl !UnwindSafe for Channel

Blanket Implementations

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

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

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

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

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

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

impl<T> From<T> for T[src]

impl<F> FromStrAndCache for F where
    F: FromStr
[src]

type Err = <F as FromStr>::Err

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

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

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

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> 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> UnsafeAny for T where
    T: Any

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,