#[non_exhaustive]pub struct GuildChannel {Show 21 fields
pub id: ChannelId,
pub bitrate: Option<u64>,
pub parent_id: Option<ChannelId>,
pub guild_id: GuildId,
pub kind: ChannelType,
pub last_message_id: Option<MessageId>,
pub last_pin_timestamp: Option<Timestamp>,
pub name: String,
pub permission_overwrites: Vec<PermissionOverwrite>,
pub position: i64,
pub topic: Option<String>,
pub user_limit: Option<u64>,
pub nsfw: bool,
pub rate_limit_per_user: Option<u64>,
pub rtc_region: Option<String>,
pub video_quality_mode: Option<VideoQualityMode>,
pub message_count: Option<u8>,
pub member_count: Option<u8>,
pub thread_metadata: Option<ThreadMetadata>,
pub member: Option<ThreadMember>,
pub default_auto_archive_duration: Option<u64>,
}
Expand description
Represents a guild’s text, news, or voice channel. Some methods are available
only for voice channels and some are only available for text channels.
News channels are a subset of text channels and lack slow mode hence
Self::rate_limit_per_user
will be None
.
Fields (Non-exhaustive)
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.id: ChannelId
The unique Id of the channel.
The default channel Id shares the Id of the guild and the default role.
bitrate: Option<u64>
The bitrate of the channel.
Note: This is only available for voice and stage channels.
parent_id: Option<ChannelId>
The Id of the parent category for a channel, or of the parent text channel for a thread.
Note: This is only available for channels in a category and thread channels.
guild_id: GuildId
The Id of the guild the channel is located in.
If this matches with the id
, then this is the default text channel.
The original voice channel has an Id equal to the guild’s Id, incremented by one.
kind: ChannelType
The type of the channel.
last_message_id: Option<MessageId>
The Id of the last message sent in the channel.
Note: This is only available for text channels.
last_pin_timestamp: Option<Timestamp>
The timestamp of the time a pin was most recently made.
Note: This is only available for text channels.
name: String
The name of the channel.
permission_overwrites: Vec<PermissionOverwrite>
position: i64
The position of the channel.
The default text channel will almost always have a position of -1
or
0
.
topic: Option<String>
The topic of the channel.
Note: This is only available for text and stage channels.
user_limit: Option<u64>
The maximum number of members allowed in the channel.
Note: This is only available for voice channels.
nsfw: bool
Used to tell if the channel is not safe for work.
Note however, it’s recommended to use Self::is_nsfw
as it’s gonna be more accurate.
rate_limit_per_user: Option<u64>
A rate limit that applies per user and excludes bots.
Note: This is only available for text channels excluding news channels.
rtc_region: Option<String>
The region override.
Note: This is only available for voice and stage channels. None
for voice and stage channels means automatic region selection.
video_quality_mode: Option<VideoQualityMode>
The video quality mode for a voice channel.
message_count: Option<u8>
An approximate count of messages in the thread.
This is currently saturated at 255 to prevent breaking.
Note: This is only available on thread channels.
member_count: Option<u8>
An approximate count of users in a thread, stops counting at 50.
Note: This is only available on thread channels.
thread_metadata: Option<ThreadMetadata>
The thread metadata.
Note: This is only available on thread channels.
member: Option<ThreadMember>
Thread member object for the current user, if they have joined the thread, only included on certain API endpoints.
default_auto_archive_duration: Option<u64>
Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity.
Note: It can currently only be set to 60, 1440, 4320, 10080.
Implementations
sourceimpl GuildChannel
impl GuildChannel
sourcepub fn is_text_based(&self) -> bool
Available on crate feature model
only.
pub fn is_text_based(&self) -> bool
model
only.Whether or not this channel is text-based, meaning that it is possible to send messages.
sourcepub async fn broadcast_typing(&self, http: impl AsRef<Http>) -> Result<()>
Available on crate feature model
only.
pub async fn broadcast_typing(&self, http: impl AsRef<Http>) -> Result<()>
model
only.Broadcasts to the channel that the current user is typing.
For bots, this is a good indicator for long-running commands.
Note: Requires the Send Messages permission.
Errors
Returns Error::Http
if the current user does
not have the required permissions.
sourcepub async fn create_invite<F>(
&self,
cache_http: impl CacheHttp,
f: F
) -> Result<RichInvite> where
F: FnOnce(&mut CreateInvite) -> &mut CreateInvite,
Available on crate features model
and utils
only.
pub async fn create_invite<F>(
&self,
cache_http: impl CacheHttp,
f: F
) -> Result<RichInvite> where
F: FnOnce(&mut CreateInvite) -> &mut CreateInvite,
model
and utils
only.Creates an invite leading to the given channel.
Note: Requires the Create Instant Invite permission.
Examples
Create an invite that can only be used 5 times:
let invite = channel.create_invite(&context, |i| i.max_uses(5)).await;
Errors
If the cache
is enabled, returns ModelError::InvalidPermissions
if the current user does not have permission to create invites.
Otherwise returns Error::Http
if the current user lacks permission.
sourcepub async fn create_permission(
&self,
http: impl AsRef<Http>,
target: &PermissionOverwrite
) -> Result<()>
Available on crate feature model
only.
pub async fn create_permission(
&self,
http: impl AsRef<Http>,
target: &PermissionOverwrite
) -> Result<()>
model
only.Creates a permission overwrite for either a
single Member
or Role
within a Channel
.
Refer to the documentation for PermissionOverwrite
s for more
information.
Requires the Manage Channels permission.
Examples
Creating a permission overwrite for a member by specifying the
PermissionOverwriteType::Member
variant, allowing it the Send Messages
permission, but denying the Send TTS Messages and Attach Files
permissions:
use serenity::model::channel::{PermissionOverwrite, PermissionOverwriteType};
use serenity::model::{ModelError, Permissions};
let allow = Permissions::SEND_MESSAGES;
let deny = Permissions::SEND_TTS_MESSAGES | Permissions::ATTACH_FILES;
let overwrite = PermissionOverwrite {
allow,
deny,
kind: PermissionOverwriteType::Member(user_id),
};
// assuming the cache has been unlocked
let channel = cache.guild_channel(channel_id).ok_or(ModelError::ItemMissing)?;
channel.create_permission(&http, &overwrite).await?;
Creating a permission overwrite for a role by specifying the
PermissionOverwriteType::Role
variant, allowing it the Manage Webhooks
permission, but denying the Send TTS Messages and Attach Files
permissions:
use serenity::model::channel::{Channel, PermissionOverwrite, PermissionOverwriteType};
use serenity::model::{ModelError, Permissions};
let allow = Permissions::SEND_MESSAGES;
let deny = Permissions::SEND_TTS_MESSAGES | Permissions::ATTACH_FILES;
let overwrite = PermissionOverwrite {
allow,
deny,
kind: PermissionOverwriteType::Member(user_id),
};
let channel = cache.guild_channel(channel_id).ok_or(ModelError::ItemMissing)?;
channel.create_permission(&http, &overwrite).await?;
Errors
Returns Error::Http
if the current user lacks permission.
sourcepub async fn delete(&self, cache_http: impl CacheHttp) -> Result<Channel>
Available on crate feature model
only.
pub async fn delete(&self, cache_http: impl CacheHttp) -> Result<Channel>
model
only.Deletes this channel, returning the channel on a successful deletion.
Note: Requires the Manage Channels permission.
Errors
If the cache
is enabled, returns ModelError::InvalidPermissions
if the current user does not have permission.
Otherwise returns Error::Http
if the current user lacks permission.
sourcepub async fn delete_messages<T, It>(
&self,
http: impl AsRef<Http>,
message_ids: It
) -> Result<()> where
T: AsRef<MessageId>,
It: IntoIterator<Item = T>,
Available on crate feature model
only.
pub async fn delete_messages<T, It>(
&self,
http: impl AsRef<Http>,
message_ids: It
) -> Result<()> where
T: AsRef<MessageId>,
It: IntoIterator<Item = T>,
model
only.Deletes all messages by Ids from the given vector in the channel.
The minimum amount of messages is 2 and the maximum amount is 100.
Requires the Manage Messages permission.
Note: Messages that are older than 2 weeks can’t be deleted using this method.
Errors
Returns ModelError::BulkDeleteAmount
if an attempt was made to
delete either 0 or more than 100 messages.
sourcepub async fn delete_permission(
&self,
http: impl AsRef<Http>,
permission_type: PermissionOverwriteType
) -> Result<()>
Available on crate feature model
only.
pub async fn delete_permission(
&self,
http: impl AsRef<Http>,
permission_type: PermissionOverwriteType
) -> Result<()>
model
only.Deletes all permission overrides in the channel from a member or role.
Note: Requires the Manage Channel permission.
Errors
Returns Error::Http
if the current user lacks permission.
sourcepub async fn delete_reaction(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
user_id: Option<UserId>,
reaction_type: impl Into<ReactionType>
) -> Result<()>
Available on crate feature model
only.
pub async fn delete_reaction(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
user_id: Option<UserId>,
reaction_type: impl Into<ReactionType>
) -> Result<()>
model
only.Deletes the given Reaction
from the channel.
Note: Requires the [Manage Messages] permission, if the current user did not perform the reaction.
Errors
Returns Error::Http
if the current user lacks permission.
[Manage Messages]: Permissions::MANAGE_MESSAGES
sourcepub async fn edit<F>(&mut self, cache_http: impl CacheHttp, f: F) -> Result<()> where
F: FnOnce(&mut EditChannel) -> &mut EditChannel,
Available on crate feature model
only.
pub async fn edit<F>(&mut self, cache_http: impl CacheHttp, f: F) -> Result<()> where
F: FnOnce(&mut EditChannel) -> &mut EditChannel,
model
only.Modifies a channel’s settings, such as its position or name.
Refer to EditChannel
s documentation for a full list of methods.
Examples
Change a voice channels name and bitrate:
channel.edit(&context, |c| c.name("test").bitrate(86400)).await;
Errors
If the cache
is enabled, returns ModelError::InvalidPermissions
if the current user lacks permission to edit the channel.
Otherwise returns Error::Http
if the current user lacks permission.
sourcepub async fn edit_message<'a, F>(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
f: F
) -> Result<Message> where
F: for<'b> FnOnce(&'b mut EditMessage<'a>) -> &'b mut EditMessage<'a>,
Available on crate feature model
only.
pub async fn edit_message<'a, F>(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
f: F
) -> Result<Message> where
F: for<'b> FnOnce(&'b mut EditMessage<'a>) -> &'b mut EditMessage<'a>,
model
only.Edits a Message
in the channel given its Id.
Message editing preserves all unchanged message data.
Refer to the documentation for EditMessage
for more information
regarding message restrictions and requirements.
Note: Requires that the current user be the author of the message.
Errors
Returns a ModelError::MessageTooLong
if the content of the message
is over the the limit
, containing the number of unicode code points
over the limit.
sourcepub async fn edit_thread<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<GuildChannel> where
F: FnOnce(&mut EditThread) -> &mut EditThread,
Available on crate feature model
only.
pub async fn edit_thread<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<GuildChannel> where
F: FnOnce(&mut EditThread) -> &mut EditThread,
model
only.sourcepub async fn edit_voice_state<F>(
&self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
f: F
) -> Result<()> where
F: FnOnce(&mut EditVoiceState) -> &mut EditVoiceState,
Available on crate feature model
only.
pub async fn edit_voice_state<F>(
&self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
f: F
) -> Result<()> where
F: FnOnce(&mut EditVoiceState) -> &mut EditVoiceState,
model
only.Edits a voice state in a stage channel. Pass None
for user_id
to
edit the current user’s voice state.
Requires the Mute Members permission to suppress another user or unsuppress the current user. This is not required if suppressing the current user.
Requires the Request to Speak permission.
Example
Invite a user to speak.
use serenity::model::ModelError;
// assuming the cache has been unlocked
let channel = cache.guild_channel(channel_id).ok_or(ModelError::ItemMissing)?;
channel.edit_voice_state(&http, user_id, |v| v.suppress(false)).await?;
Errors
Returns a ModelError::InvalidChannelType
if the channel type is not
stage.
sourcepub async fn edit_own_voice_state<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<()> where
F: FnOnce(&mut EditVoiceState) -> &mut EditVoiceState,
Available on crate feature model
only.
pub async fn edit_own_voice_state<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<()> where
F: FnOnce(&mut EditVoiceState) -> &mut EditVoiceState,
model
only.Edits the current user’s voice state in a stage channel.
The Mute Members permission is not required if suppressing the current user.
Requires the Request to Speak permission.
Example
Send a request to speak, then clear the request.
use serenity::model::ModelError;
// assuming the cache has been unlocked
let channel = cache.guild_channel(channel_id).ok_or(ModelError::ItemMissing)?;
// Send a request to speak
channel.edit_own_voice_state(&http, |v| v.request_to_speak(true)).await?;
// Clear own request to speak
channel.edit_own_voice_state(&http, |v| v.request_to_speak(false)).await?;
Errors
Returns a ModelError::InvalidChannelType
if the channel type is not
stage.
sourcepub async fn follow(
self,
http: impl AsRef<Http>,
target_channel_id: impl Into<ChannelId>
) -> Result<FollowedChannel>
Available on crate feature model
only.
pub async fn follow(
self,
http: impl AsRef<Http>,
target_channel_id: impl Into<ChannelId>
) -> Result<FollowedChannel>
model
only.Follows the News Channel
Requires [Manage Webhook] permissions on the target channel.
Note: Only available on news channels.
Errors
Returns Error::Http
if the current user lacks permission.
[Manage Messages]: Permissions::MANAGE_MESSAGES
sourcepub fn guild(&self, cache: impl AsRef<Cache>) -> Option<Guild>
Available on crate features model
and cache
only.
pub fn guild(&self, cache: impl AsRef<Cache>) -> Option<Guild>
model
and cache
only.Attempts to find this channel’s guild in the Cache.
sourcepub async fn invites(&self, http: impl AsRef<Http>) -> Result<Vec<RichInvite>>
Available on crate feature model
only.
pub async fn invites(&self, http: impl AsRef<Http>) -> Result<Vec<RichInvite>>
model
only.Gets all of the channel’s invites.
Requires the Manage Channels permission.
Errors
Returns Error::Http
if the current user lacks 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.
Only text channels are taken into consideration as being NSFW. voice channels are never NSFW.
sourcepub async fn message(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<Message>
Available on crate feature model
only.
pub async fn message(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<Message>
model
only.Gets a message from the channel.
Requires the Read Message History permission.
Errors
Returns Error::Http
if the current user lacks permission,
or if a message with the given Id does not exist in the channel.
sourcepub async fn messages<F>(
&self,
http: impl AsRef<Http>,
builder: F
) -> Result<Vec<Message>> where
F: FnOnce(&mut GetMessages) -> &mut GetMessages,
Available on crate feature model
only.
pub async fn messages<F>(
&self,
http: impl AsRef<Http>,
builder: F
) -> Result<Vec<Message>> where
F: FnOnce(&mut GetMessages) -> &mut GetMessages,
model
only.Gets messages from the channel.
Refer to the GetMessages
-builder for more information on how to
use builder
.
Note: Returns an empty Vec
if the current user does not have the
Read Message History permission.
Errors
Returns Error::Http
if the current user lacks permission to
view the channel.
sourcepub fn name(&self) -> &str
Available on crate feature model
only.
pub fn name(&self) -> &str
model
only.Returns the name of the guild channel.
sourcepub fn permissions_for_user(
&self,
cache: impl AsRef<Cache>,
user_id: impl Into<UserId>
) -> Result<Permissions>
Available on crate features model
and cache
only.
pub fn permissions_for_user(
&self,
cache: impl AsRef<Cache>,
user_id: impl Into<UserId>
) -> Result<Permissions>
model
and cache
only.Calculates the permissions of a member.
The Id of the argument must be a Member
of the Guild
that the
channel is in.
Examples
Calculate the permissions of a User
who posted a Message
in a
channel:
use serenity::model::prelude::*;
use serenity::prelude::*;
struct Handler;
#[serenity::async_trait]
impl EventHandler for Handler {
async fn message(&self, context: Context, msg: Message) {
let channel = match context.cache.guild_channel(msg.channel_id) {
Some(channel) => channel,
None => return,
};
if let Ok(permissions) = channel.permissions_for_user(&context.cache, &msg.author) {
println!("The user's permissions: {:?}", permissions);
}
}
}
let mut client =
Client::builder("token", GatewayIntents::default()).event_handler(Handler).await?;
client.start().await?;
Check if the current user has the Attach Files and Send Messages permissions (note: serenity will automatically check this for; this is for demonstrative purposes):
use serenity::model::channel::Channel;
use serenity::model::prelude::*;
use serenity::prelude::*;
use tokio::fs::File;
struct Handler;
#[serenity::async_trait]
impl EventHandler for Handler {
async fn message(&self, context: Context, mut msg: Message) {
let channel = match context.cache.guild_channel(msg.channel_id) {
Some(channel) => channel,
None => return,
};
let current_user_id = context.cache.current_user_id();
if let Ok(permissions) = channel.permissions_for_user(&context.cache, current_user_id) {
if !permissions.contains(Permissions::ATTACH_FILES | Permissions::SEND_MESSAGES) {
return;
}
let file = match File::open("./cat.png").await {
Ok(file) => file,
Err(why) => {
println!("Err opening file: {:?}", why);
return;
},
};
let _ = msg
.channel_id
.send_files(&context.http, vec![(&file, "cat.png")], |m| {
m.content("here's a cat")
})
.await;
}
}
}
let mut client =
Client::builder("token", GatewayIntents::default()).event_handler(Handler).await?;
client.start().await?;
Errors
Returns a ModelError::GuildNotFound
if the channel’s guild could
not be found in the Cache
.
sourcepub fn permissions_for_role(
&self,
cache: impl AsRef<Cache>,
role_id: impl Into<RoleId>
) -> Result<Permissions>
Available on crate features model
and cache
only.
pub fn permissions_for_role(
&self,
cache: impl AsRef<Cache>,
role_id: impl Into<RoleId>
) -> Result<Permissions>
model
and cache
only.Calculates the permissions of a role.
The Id of the argument must be a Role
of the Guild
that the
channel is in.
Errors
Returns a ModelError::GuildNotFound
if the channel’s guild could
not be found in the Cache
.
Returns a ModelError::RoleNotFound
if the given role could not
be found in the Cache
.
sourcepub async fn pin(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
Available on crate feature model
only.
pub async fn pin(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
model
only.Pins a Message
to the channel.
Note: Requires the Manage Messages permission.
Errors
Returns Error::Http
if the current user lacks permission,
or if the channel already has too many pinned messages.
sourcepub async fn pins(&self, http: impl AsRef<Http>) -> Result<Vec<Message>>
Available on crate feature model
only.
pub async fn pins(&self, http: impl AsRef<Http>) -> Result<Vec<Message>>
model
only.Gets all channel’s pins.
Note: If the current user lacks the Read Message History permission
an empty Vec
will be returned.
Errors
Returns Error::Http
if the current user lacks permission to view the channel.
sourcepub async fn reaction_users(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
reaction_type: impl Into<ReactionType>,
limit: Option<u8>,
after: impl Into<Option<UserId>>
) -> Result<Vec<User>>
Available on crate feature model
only.
pub async fn reaction_users(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
reaction_type: impl Into<ReactionType>,
limit: Option<u8>,
after: impl Into<Option<UserId>>
) -> Result<Vec<User>>
model
only.Gets the list of User
s who have reacted to a Message
with a
certain Emoji
.
The default limit
is 50
- specify otherwise to receive a different
maximum number of users. The maximum that may be retrieve at a time is
100
, if a greater number is provided then it is automatically reduced.
The optional after
attribute is to retrieve the users after a certain
user. This is useful for pagination.
Note: Requires the Read Message History permission.
Errors
Returns Error::Http
if the current user lacks permission.
sourcepub async fn say(
&self,
http: impl AsRef<Http>,
content: impl Display
) -> Result<Message>
Available on crate feature model
only.
pub async fn say(
&self,
http: impl AsRef<Http>,
content: impl Display
) -> Result<Message>
model
only.Sends a message with just the given message content in the channel.
Errors
Returns a ModelError::MessageTooLong
if the content of the message
is over the above limit, containing the number of unicode code points
over the limit.
May also return Error::Http
if the current user lacks permission
to send a message to the channel.
sourcepub async fn send_files<'a, F, T, It>(
&self,
http: impl AsRef<Http>,
files: It,
f: F
) -> Result<Message> where
for<'b> F: FnOnce(&'b mut CreateMessage<'a>) -> &'b mut CreateMessage<'a>,
T: Into<AttachmentType<'a>>,
It: IntoIterator<Item = T>,
Available on crate feature model
only.
pub async fn send_files<'a, F, T, It>(
&self,
http: impl AsRef<Http>,
files: It,
f: F
) -> Result<Message> where
for<'b> F: FnOnce(&'b mut CreateMessage<'a>) -> &'b mut CreateMessage<'a>,
T: Into<AttachmentType<'a>>,
It: IntoIterator<Item = T>,
model
only.Sends (a) file(s) along with optional message contents.
Refer to ChannelId::send_files
for examples and more information.
The Attach Files and Send Messages permissions are required.
Note: Message contents must be under 2000 unicode code points.
Errors
If the content of the message is over the above limit, then a
ModelError::MessageTooLong
will be returned, containing the number
of unicode code points over the limit.
sourcepub async fn send_message<'a, F>(
&self,
cache_http: impl CacheHttp,
f: F
) -> Result<Message> where
for<'b> F: FnOnce(&'b mut CreateMessage<'a>) -> &'b mut CreateMessage<'a>,
Available on crate feature model
only.
pub async fn send_message<'a, F>(
&self,
cache_http: impl CacheHttp,
f: F
) -> Result<Message> where
for<'b> F: FnOnce(&'b mut CreateMessage<'a>) -> &'b mut CreateMessage<'a>,
model
only.Sends a message to the channel with the given content.
Note: Requires the Send Messages permission.
Errors
Returns a ModelError::MessageTooLong
if the content of the message
is over the above limit, containing the number of unicode code points
over the limit.
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user does
not have the required permissions.
Otherwise will return Error::Http
if the current user lacks permission.
sourcepub fn start_typing(self, http: &Arc<Http>) -> Result<Typing>
Available on crate feature model
only.
pub fn start_typing(self, http: &Arc<Http>) -> Result<Typing>
model
only.Starts typing in the channel for an indefinite period of time.
Returns Typing
that is used to trigger the typing. Typing::stop
must be called
on the returned struct to stop typing. Note that on some clients, typing may persist
for a few seconds after Typing::stop
is called.
Typing is also stopped when the struct is dropped.
If a message is sent while typing is triggered, the user will stop typing for a brief period
of time and then resume again until either Typing::stop
is called or the struct is dropped.
This should rarely be used for bots, although it is a good indicator that a long-running command is still being processed.
Examples
// Initiate typing (assuming http is `Arc<Http>` and `channel` is bound)
let typing = channel.start_typing(&http)?;
// Run some long-running process
long_process();
// Stop typing
typing.stop();
sourcepub async fn unpin(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
Available on crate feature model
only.
pub async fn unpin(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>
) -> Result<()>
model
only.Unpins a Message
in the channel given by its Id.
Requires the Manage Messages permission.
Errors
Returns Error::Http
if the current user lacks permission.
sourcepub async fn webhooks(&self, http: impl AsRef<Http>) -> Result<Vec<Webhook>>
Available on crate feature model
only.
pub async fn webhooks(&self, http: impl AsRef<Http>) -> Result<Vec<Webhook>>
model
only.Retrieves the channel’s webhooks.
Note: Requires the Manage Webhooks permission.
Errors
Returns Error::Http
if the current user lacks permission.
sourcepub async fn members(&self, cache: impl AsRef<Cache>) -> Result<Vec<Member>>
Available on crate features model
and cache
only.
pub async fn members(&self, cache: impl AsRef<Cache>) -> Result<Vec<Member>>
model
and cache
only.Retrieves Member
s from the current channel.
ChannelType::Voice
and ChannelType::Stage
returns Member
s
using the channel.
ChannelType::Text
and ChannelType::News
return Member
s that
can read the channel.
Errors
Other ChannelType
s lack the concept of Member
s and
will return: ModelError::InvalidChannelType
.
sourcepub fn await_reply(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> CollectReplyⓘNotable traits for CollectReplyimpl Future for CollectReply type Output = Option<Arc<Message>>;
Available on crate features model
and collector
only.
pub fn await_reply(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> CollectReplyⓘNotable traits for CollectReplyimpl Future for CollectReply type Output = Option<Arc<Message>>;
model
and collector
only.Returns a future that will await one message by this guild channel.
sourcepub fn await_replies(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> MessageCollectorBuilder
Available on crate features model
and collector
only.
pub fn await_replies(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> MessageCollectorBuilder
model
and collector
only.Returns a stream builder which can be awaited to obtain a stream of messages sent by this guild channel.
sourcepub fn await_reaction(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> CollectReactionⓘNotable traits for CollectReactionimpl Future for CollectReaction type Output = Option<Arc<ReactionAction>>;
Available on crate features model
and collector
only.
pub fn await_reaction(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> CollectReactionⓘNotable traits for CollectReactionimpl Future for CollectReaction type Output = Option<Arc<ReactionAction>>;
model
and collector
only.Await a single reaction by this guild channel.
sourcepub fn await_reactions(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> ReactionCollectorBuilder
Available on crate features model
and collector
only.
pub fn await_reactions(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> ReactionCollectorBuilder
model
and collector
only.Returns a stream builder which can be awaited to obtain a stream of reactions sent by this guild channel.
sourcepub async fn create_webhook(
&self,
http: impl AsRef<Http>,
name: impl Display
) -> Result<Webhook>
Available on crate feature model
only.
pub async fn create_webhook(
&self,
http: impl AsRef<Http>,
name: impl Display
) -> Result<Webhook>
model
only.Creates a webhook with only a name.
Errors
Returns a ModelError::NameTooShort
if the name of the webhook is
under the limit of 2 characters.
Returns a ModelError::NameTooLong
if the name of the webhook is
over the limit of 100 characters.
Returns a ModelError::InvalidChannelType
if the channel type is not text.
sourcepub async fn create_webhook_with_avatar<'a>(
&self,
http: impl AsRef<Http>,
name: impl Display,
avatar: impl Into<AttachmentType<'a>>
) -> Result<Webhook>
Available on crate feature model
only.
pub async fn create_webhook_with_avatar<'a>(
&self,
http: impl AsRef<Http>,
name: impl Display,
avatar: impl Into<AttachmentType<'a>>
) -> Result<Webhook>
model
only.Creates a webhook with a name and an avatar.
Errors
In addition to the reasons Self::create_webhook
may return an Error::Http
,
if the image is too large.
sourcepub async fn get_stage_instance(
&self,
http: impl AsRef<Http>
) -> Result<StageInstance>
Available on crate feature model
only.
pub async fn get_stage_instance(
&self,
http: impl AsRef<Http>
) -> Result<StageInstance>
model
only.Gets a stage instance.
Errors
Returns ModelError::InvalidChannelType
if the channel is not a stage channel.
Returns Error::Http
if there is no stage instance currently.
sourcepub async fn create_stage_instance<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<StageInstance> where
F: FnOnce(&mut CreateStageInstance) -> &mut CreateStageInstance,
Available on crate feature model
only.
pub async fn create_stage_instance<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<StageInstance> where
F: FnOnce(&mut CreateStageInstance) -> &mut CreateStageInstance,
model
only.Creates a stage instance.
Errors
Returns ModelError::InvalidChannelType
if the channel is not a stage channel.
Returns Error::Http
if there is already a stage instance currently.
sourcepub async fn edit_stage_instance<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<StageInstance> where
F: FnOnce(&mut EditStageInstance) -> &mut EditStageInstance,
Available on crate feature model
only.
pub async fn edit_stage_instance<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<StageInstance> where
F: FnOnce(&mut EditStageInstance) -> &mut EditStageInstance,
model
only.Edits a stage instance.
Errors
Returns ModelError::InvalidChannelType
if the channel is not a stage channel.
Returns Error::Http
if there is no stage instance currently.
sourcepub async fn delete_stage_instance(&self, http: impl AsRef<Http>) -> Result<()>
Available on crate feature model
only.
pub async fn delete_stage_instance(&self, http: impl AsRef<Http>) -> Result<()>
model
only.Deletes a stage instance.
Errors
Returns ModelError::InvalidChannelType
if the channel is not a stage channel.
Returns Error::Http
if there is no stage instance currently.
sourcepub async fn create_public_thread<F>(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
f: F
) -> Result<GuildChannel> where
F: FnOnce(&mut CreateThread) -> &mut CreateThread,
Available on crate feature model
only.
pub async fn create_public_thread<F>(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
f: F
) -> Result<GuildChannel> where
F: FnOnce(&mut CreateThread) -> &mut CreateThread,
model
only.Creates a public thread that is connected to a message.
Errors
Returns Error::Http
if the current user lacks permission.
sourcepub async fn create_private_thread<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<GuildChannel> where
F: FnOnce(&mut CreateThread) -> &mut CreateThread,
Available on crate feature model
only.
pub async fn create_private_thread<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<GuildChannel> where
F: FnOnce(&mut CreateThread) -> &mut CreateThread,
model
only.Trait Implementations
sourceimpl ArgumentConvert for GuildChannel
impl ArgumentConvert for GuildChannel
Look up a GuildChannel by a string case-insensitively.
Lookup is done by the global cache, hence the cache feature needs to be enabled.
For more information, see the ArgumentConvert implementation for Channel
type Err = GuildChannelParseError
type Err = GuildChannelParseError
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 Clone for GuildChannel
impl Clone for GuildChannel
sourcefn clone(&self) -> GuildChannel
fn clone(&self) -> GuildChannel
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for GuildChannel
impl Debug for GuildChannel
sourceimpl<'de> Deserialize<'de> for GuildChannel
impl<'de> Deserialize<'de> for GuildChannel
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for GuildChannel
impl Display for GuildChannel
sourceimpl<'a> From<&'a GuildChannel> for ChannelId
impl<'a> From<&'a GuildChannel> for ChannelId
sourcefn from(public_channel: &GuildChannel) -> ChannelId
fn from(public_channel: &GuildChannel) -> ChannelId
Gets the Id of a guild channel.
sourceimpl From<GuildChannel> for ChannelId
impl From<GuildChannel> for ChannelId
sourcefn from(public_channel: GuildChannel) -> ChannelId
fn from(public_channel: GuildChannel) -> ChannelId
Gets the Id of a guild channel.
sourceimpl Mentionable for GuildChannel
impl Mentionable for GuildChannel
sourceimpl Serialize for GuildChannel
impl Serialize for GuildChannel
Auto Trait Implementations
impl RefUnwindSafe for GuildChannel
impl Send for GuildChannel
impl Sync for GuildChannel
impl Unpin for GuildChannel
impl UnwindSafe for GuildChannel
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