diff --git a/src/api/guilds/guilds.rs b/src/api/guilds/guilds.rs index 9b9d87f..f598414 100644 --- a/src/api/guilds/guilds.rs +++ b/src/api/guilds/guilds.rs @@ -12,6 +12,9 @@ use crate::types::{Channel, ChannelCreateSchema, Guild, GuildCreateSchema}; impl Guild { /// Creates a new guild. + /// + /// # Reference + /// See pub async fn create( user: &mut UserMeta, guild_create_schema: GuildCreateSchema, @@ -41,6 +44,9 @@ impl Guild { /// Ok(_) => println!("Guild deleted successfully"), /// } /// ``` + /// + /// # Reference + /// See pub async fn delete(user: &mut UserMeta, guild_id: Snowflake) -> ChorusResult<()> { let url = format!( "{}/guilds/{}/delete/", @@ -57,6 +63,14 @@ impl Guild { } /// Creates a new channel in a guild. + /// + /// Requires the [MANAGE_CHANNELS](crate::types::PermissionFlags::MANAGE_CHANNELS) permission. + /// + /// # Notes + /// This method is a wrapper for [Channel::create]. + /// + /// # Reference + /// See pub async fn create_channel( &self, user: &mut UserMeta, @@ -65,7 +79,12 @@ impl Guild { Channel::create(user, self.id, schema).await } - /// Returns a list of the guild's channels + /// Returns a list of the guild's channels. + /// + /// Doesn't include threads. + /// + /// # Reference + /// See pub async fn channels(&self, user: &mut UserMeta) -> ChorusResult> { let chorus_request = ChorusRequest { request: Client::new() @@ -97,6 +116,9 @@ impl Guild { } /// Fetches a guild by its id. + /// + /// # Reference + /// See pub async fn get(guild_id: Snowflake, user: &mut UserMeta) -> ChorusResult { let chorus_request = ChorusRequest { request: Client::new() @@ -115,6 +137,11 @@ impl Guild { impl Channel { /// Creates a new channel in a guild. + /// + /// Requires the [MANAGE_CHANNELS](crate::types::PermissionFlags::MANAGE_CHANNELS) permission. + /// + /// # Reference + /// See pub async fn create( user: &mut UserMeta, guild_id: Snowflake, diff --git a/src/api/guilds/member.rs b/src/api/guilds/member.rs index 1cf1a08..06b5154 100644 --- a/src/api/guilds/member.rs +++ b/src/api/guilds/member.rs @@ -10,6 +10,9 @@ use crate::{ impl types::GuildMember { /// Retrieves a guild member. + /// + /// # Reference + /// See pub async fn get( user: &mut UserMeta, guild_id: Snowflake, @@ -31,6 +34,9 @@ impl types::GuildMember { } /// Adds a role to a guild member. + /// + /// # Reference + /// See pub async fn add_role( user: &mut UserMeta, guild_id: Snowflake, @@ -52,6 +58,9 @@ impl types::GuildMember { } /// Removes a role from a guild member. + /// + /// # Reference + /// See pub async fn remove_role( user: &mut UserMeta, guild_id: Snowflake, diff --git a/src/api/guilds/roles.rs b/src/api/guilds/roles.rs index 81aca03..e76749e 100644 --- a/src/api/guilds/roles.rs +++ b/src/api/guilds/roles.rs @@ -12,11 +12,12 @@ use crate::{ impl types::RoleObject { /// Retrieves a list of roles for a given guild. /// - /// Returns Ok(None) if the guild has no roles. + /// # Reference + /// See pub async fn get_all( user: &mut UserMeta, guild_id: Snowflake, - ) -> ChorusResult>> { + ) -> ChorusResult> { let url = format!( "{}/guilds/{}/roles/", user.belongs_to.borrow().urls.api, @@ -30,13 +31,11 @@ impl types::RoleObject { .deserialize_response::>(user) .await .unwrap(); - if roles.is_empty() { - return Ok(None); - } - Ok(Some(roles)) + Ok(roles) } /// Retrieves a single role for a given guild. + // TODO: Couldn't find reference pub async fn get( user: &mut UserMeta, guild_id: Snowflake, @@ -58,6 +57,9 @@ impl types::RoleObject { } /// Creates a new role for a given guild. + /// + /// # Reference + /// See pub async fn create( user: &mut UserMeta, guild_id: Snowflake, @@ -83,6 +85,9 @@ impl types::RoleObject { } /// Updates the position of a role in a given guild's hierarchy. + /// + /// # Reference + /// See pub async fn position_update( user: &mut UserMeta, guild_id: Snowflake, @@ -110,6 +115,9 @@ impl types::RoleObject { } /// Updates a role in a guild. + /// + /// # Reference + /// See pub async fn update( user: &mut UserMeta, guild_id: Snowflake, diff --git a/src/types/entities/channel.rs b/src/types/entities/channel.rs index 43ca54b..60304f9 100644 --- a/src/types/entities/channel.rs +++ b/src/types/entities/channel.rs @@ -72,9 +72,15 @@ pub struct Channel { } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)] +/// A tag that can be applied to a thread in a [ChannelType::GuildForum] or [ChannelType::GuildMedia] channel. +/// +/// # Reference +/// See pub struct Tag { pub id: Snowflake, + /// The name of the tag (max 20 characters) pub name: String, + /// Whether this tag can only be added to or removed from threads by members with the [MANAGE_THREADS](crate::types::PermissionFlags::MANAGE_THREADS) permission pub moderated: bool, pub emoji_id: Option, pub emoji_name: Option, @@ -95,6 +101,8 @@ pub struct PermissionOverwrite { } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)] +/// # Reference +/// See pub struct ThreadMetadata { pub archived: bool, pub auto_archive_duration: i32, @@ -105,6 +113,8 @@ pub struct ThreadMetadata { } #[derive(Default, Debug, Deserialize, Serialize, Clone, PartialEq, Eq)] +/// # Reference +/// See pub struct ThreadMember { pub id: Option, pub user_id: Option, @@ -114,6 +124,10 @@ pub struct ThreadMember { } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)] +/// Specifies the emoji to use as the default way to react to a [ChannelType::GuildForum] or [ChannelType::GuildMedia] channel post. +/// +/// # Reference +/// See pub struct DefaultReaction { #[serde(default)] pub emoji_id: Option,