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
Guild(GuildChannel)
Tuple Fields
0: GuildChannel
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 GuildChannel
s
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.
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):
- Lookup by ID.
- Lookup by mention.
- Lookup by name.
type Err = ChannelParseError
type Err = ChannelParseError
The associated error which can be returned from parsing.
Parses a string s
as a command parameter of this type.
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:
PrivateChannel
s: the recipient’s name;GuildChannel
s: a string mentioning the channel that users who can see the channel can click on.
Auto Trait Implementations
impl RefUnwindSafe for Channel
impl UnwindSafe for Channel
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
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