#[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)
Private(PrivateChannel)
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 GuildChannel
s
Implementations
sourceimpl Channel
impl Channel
sourcepub fn guild(self) -> Option<GuildChannel>
pub fn guild(self) -> Option<GuildChannel>
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!");
},
}
sourcepub fn private(self) -> Option<PrivateChannel>
pub fn private(self) -> Option<PrivateChannel>
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!");
},
}
sourcepub fn category(self) -> Option<ChannelCategory>
pub fn category(self) -> Option<ChannelCategory>
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!");
},
}
sourcepub async fn delete(&self, cache_http: impl CacheHttp) -> Result<()>
Available on crate feature http
only.
pub async fn delete(&self, cache_http: impl CacheHttp) -> Result<()>
http
only.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.
sourcepub fn is_nsfw(&self) -> bool
Available on crate feature model
only.
pub fn is_nsfw(&self) -> bool
model
only.Determines if the channel is NSFW.
sourcepub fn id(&self) -> ChannelId
pub fn id(&self) -> ChannelId
Retrieves the Id of the inner GuildChannel
, or
PrivateChannel
.
sourcepub fn position(&self) -> Option<i64>
pub fn position(&self) -> Option<i64>
Retrieves the position of the inner GuildChannel
or
ChannelCategory
.
If other channel types are used it will return None.
Trait Implementations
sourceimpl ArgumentConvert for Channel
impl ArgumentConvert for Channel
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
utils
and client
only.The associated error which can be returned from parsing.
sourcefn convert<'life0, 'life1, 'async_trait>(
ctx: &'life0 Context,
guild_id: Option<GuildId>,
_channel_id: Option<ChannelId>,
s: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn convert<'life0, 'life1, 'async_trait>(
ctx: &'life0 Context,
guild_id: Option<GuildId>,
_channel_id: Option<ChannelId>,
s: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
utils
and client
only.Parses a string s
as a command parameter of this type.
sourceimpl<'de> Deserialize<'de> for Channel
impl<'de> Deserialize<'de> for Channel
sourcefn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for Channel
impl Display for Channel
sourcefn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
sourceimpl FromStrAndCache for Channel
Available on crate features cache
and model
and utils
only.
impl FromStrAndCache for Channel
cache
and model
and utils
only.sourceimpl Mentionable for Channel
impl Mentionable for Channel
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more