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

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

A container for any channel.

Variants (Non-exhaustive)

This enum is marked as 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.
Expand description

A text, voice, or stage channel within a Guild.

Expand description

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

Category(ChannelCategory)
Expand description

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.

Errors

If the cache is enabled, returns ModelError::InvalidPermissions, if the current user lacks permission.

Otherwise will return Error::Http if the current user does not have permission.

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]

fn clone(&self) -> Channel[src]

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl Debug for Channel[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

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

fn deserialize<D: Deserializer<'de>>(
    deserializer: D
) -> StdResult<Self, D::Error>
[src]

Deserialize this value from the given Serde deserializer. 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:

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

impl From<&'_ Channel> for Mention[src]

fn from(value: &Channel) -> Self[src]

Performs the conversion.

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

fn from_str<'life0, 'async_trait, C>(
    cache: C,
    s: &'life0 str
) -> Pin<Box<dyn Future<Output = StdResult<Self, Self::Err>> + Send + 'async_trait>> where
    C: AsRef<Cache> + Send + Sync,
    C: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

impl Mentionable for Channel[src]

fn mention(&self) -> Mention[src]

Creates a Mention that will be able to notify or create a link to the item. Read more

impl Serialize for Channel[src]

fn serialize<S>(&self, serializer: S) -> StdResult<S::Ok, S::Error> where
    S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

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

pub fn vzip(self) -> V

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