pub struct Channel {Show 33 fields
pub id: String,
pub kind: ChannelType,
pub guild_id: Option<String>,
pub position: Option<i32>,
pub permission_overwrites: Vec<PermissionOverwrite>,
pub name: Option<String>,
pub topic: Option<String>,
pub nsfw: bool,
pub last_message_id: Option<String>,
pub bitrate: Option<u64>,
pub user_limit: Option<u64>,
pub rate_limit_per_user: Option<u64>,
pub recipients: Option<Vec<User>>,
pub icon: Option<String>,
pub owner_id: Option<String>,
pub application_id: Option<String>,
pub managed: bool,
pub parent_id: Option<String>,
pub last_pin_timestamp: Option<String>,
pub rtc_region: Option<String>,
pub video_quality_mode: Option<u8>,
pub message_count: Option<u64>,
pub member_count: Option<u64>,
pub thread_metadata: Option<ThreadMetadata>,
pub member: Option<ThreadMember>,
pub default_auto_archive_duration: Option<u64>,
pub permissions: Option<Permissions>,
pub flags: Option<u64>,
pub total_messages: Option<u64>,
pub available_tags: Option<Vec<ForumTag>>,
pub applied_tags: Option<Vec<String>>,
pub default_sort_order: Option<u8>,
pub default_forum_layout: Option<u8>,
}Fields§
§id: StringUnique ID of the channel
kind: ChannelTypeType of the channel (text, voice, DM, etc.)
guild_id: Option<String>Id of the guild (if applicable)
position: Option<i32>Position of the channel in the guild (if applicable)
permission_overwrites: Vec<PermissionOverwrite>Explicit permission overwrites for roles/users in this channel
name: Option<String>Name of the channel (if applicable)
topic: Option<String>Topic of the channel (if applicable)
nsfw: boolWhether the channel is NSFW (if applicable)
last_message_id: Option<String>Id of the last message sent in the channel (if applicable)
bitrate: Option<u64>Bitrate (for voice channels)
user_limit: Option<u64>User limit (for voice channels)
rate_limit_per_user: Option<u64>Rate limit per user (for text channels)
recipients: Option<Vec<User>>recipients (for DM channels)
icon: Option<String>Icon hash (for group DM channels)
owner_id: Option<String>Owner ID (for group DM channels)
application_id: Option<String>Application ID (for group DM channels)
managed: boolWhether the channel is managed
parent_id: Option<String>Channel’s parent category ID (if applicable)
last_pin_timestamp: Option<String>The channel’s last pinned message ID (if applicable)
rtc_region: Option<String>The channel’s rtc region (for voice channels)
video_quality_mode: Option<u8>The channel’s video quality mode (for voice channels)
message_count: Option<u64>The channel’s message count (for threads)
member_count: Option<u64>The channel’s member count (for threads)
thread_metadata: Option<ThreadMetadata>Thread metdata
member: Option<ThreadMember>Thread member object (for threads the current user has joined)
default_auto_archive_duration: Option<u64>Default auto archive duration for threads in this channel (if applicable)
permissions: Option<Permissions>Permissions (for threads)
flags: Option<u64>Flags
total_messages: Option<u64>Total number of messages in the thread, even when messages are deleted (if applicable)
Available tags in a guild forum channel
Applied tags IDs in a thread in a guild forum channel
default_sort_order: Option<u8>Default sort order type for a guild forum channel
default_forum_layout: Option<u8>Default forum layout view for a guild forum channel
Implementations§
Source§impl Channel
impl Channel
Sourcepub async fn guild(&self, http: &HttpClient) -> Option<Guild>
pub async fn guild(&self, http: &HttpClient) -> Option<Guild>
Get the guild for this channel (if applicable)
§Example
use diself::{HttpClient, model::channel::Channel};
async fn example(http: &HttpClient, channel: &Channel) {
if let Some(guild) = channel.guild(http).await {
println!("Channel is in guild: {}", guild.name);
} else {
println!("Channel is not in a guild");
}
}Sourcepub async fn send(
&self,
http: &HttpClient,
content: impl Into<String>,
) -> Result<Message, Error>
pub async fn send( &self, http: &HttpClient, content: impl Into<String>, ) -> Result<Message, Error>
Sends a message to this channel
Sourcepub async fn messages(
&self,
http: &HttpClient,
around: Option<String>,
before: Option<String>,
after: Option<String>,
limit: Option<u8>,
) -> Result<Vec<Message>, Error>
pub async fn messages( &self, http: &HttpClient, around: Option<String>, before: Option<String>, after: Option<String>, limit: Option<u8>, ) -> Result<Vec<Message>, Error>
Fetches messages from this channel. (GET /channels/{channel_id}/messages) SEE: https://docs.discord.food/resources/message#get-messages
§Params
- around?: Snowflake - Get messages around this message ID
- before?: Snowflake - Get messages before this message ID
- after?: Snowflake - Get messages after this message ID
- limit?: number - Max number of messages to return (1-100, default 50)
Sourcepub async fn get_message(
&self,
http: &HttpClient,
message_id: impl AsRef<str>,
) -> Result<Message, Error>
pub async fn get_message( &self, http: &HttpClient, message_id: impl AsRef<str>, ) -> Result<Message, Error>
Fetches a single message by ID from this channel. (GET /channels/{channel_id}/messages/{message_id}) SEE: https://docs.discord.food/resources/message#get-message