Skip to main content

Channel

Struct Channel 

Source
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: String

Unique ID of the channel

§kind: ChannelType

Type 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: bool

Whether 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: bool

Whether 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: Option<Vec<ForumTag>>

Available tags in a guild forum channel

§applied_tags: Option<Vec<String>>

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

Source

pub fn is_dm(&self) -> bool

Helper method to check if the channel is a DM or Group DM

Source

pub fn mention(&self) -> String

Helper method to get the mention string for the channel

Source

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

pub async fn send( &self, http: &HttpClient, content: impl Into<String>, ) -> Result<Message, Error>

Sends a message to this channel

Source

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)
Source

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

Trait Implementations§

Source§

impl Clone for Channel

Source§

fn clone(&self) -> Channel

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Channel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Channel

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Channel

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,