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.

Guild(GuildChannel)

Tuple Fields

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

Private(PrivateChannel)

Tuple Fields

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

Category(ChannelCategory)

Tuple Fields

A category of GuildChannels

Implementations

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_channel) => {
        println!("It's a guild channel named {}!", guild_channel.name);
    },
    None => {
        println!("It's not in a guild!");
    },
}

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!");
    },
}

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!");
    },
}

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.

Determines if the channel is NSFW.

Retrieves the Id of the inner GuildChannel, or PrivateChannel.

Retrieves the position of the inner GuildChannel or ChannelCategory.

If other channel types are used it will return None.

Trait Implementations

Look up a Channel by a string case-insensitively.

Lookup are done via local guild. If in DMs, the global cache is used instead.

The cache feature needs to be enabled.

The lookup strategy is as follows (in order):

  1. Lookup by ID.
  2. Lookup by mention.
  3. Lookup by name.

The associated error which can be returned from parsing.

Parses a string s as a command parameter of this type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

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.

Performs the conversion.

Gets the Id of a Channel.

Gets the Id of a Channel.

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

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

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

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

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

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

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more