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

#[non_exhaustive]pub enum Channel {
    Guild(GuildChannel),
    Private(PrivateChannel),
    Category(ChannelCategory),
}

A container for any channel.

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.

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.

Category(ChannelCategory)

A category of GuildChannels

Implementations

impl Channel[src]

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

Converts from Channel to Option<GuildChannel>.

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

Examples

Basic usage:

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

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

Converts from Channel to Option<PrivateChannel>.

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

Examples

Basic usage:

match channel.private() {
    Some(private) => {
        println!("It's a private channel with {}!", &private.recipient);
    },
    None => { println!("It's not a private channel!"); },
}

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

Converts from Channel to Option<ChannelCategory>.

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

Examples

Basic usage:

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

pub async 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.

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 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]

pub 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:

  • PrivateChannels: the recipient's name;
  • GuildChannels: a string mentioning the channel that users who can see the channel can click on.

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

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

Gets the Id of a Channel.

impl From<Channel> for ChannelId[src]

pub 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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

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

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

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<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]