From fc660366747491473f9bb22a0657701a80bc1f5c Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Thu, 8 Jun 2023 22:39:06 +0200 Subject: [PATCH] Add documentation --- src/api/guilds/roles.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/api/guilds/roles.rs b/src/api/guilds/roles.rs index e246efe..482a859 100644 --- a/src/api/guilds/roles.rs +++ b/src/api/guilds/roles.rs @@ -9,6 +9,20 @@ use crate::{ }; impl types::RoleObject { + /// Retrieves all roles for a given guild. + /// + /// # Arguments + /// + /// * `user` - A mutable reference to a [`UserMeta`] instance. + /// * `guild_id` - The ID of the guild to retrieve roles from. + /// + /// # Returns + /// + /// An `Option` containing a `Vec` of [`RoleObject`]s if roles were found, or `None` if no roles were found. + /// + /// # Errors + /// + /// Returns a [`ChorusLibError`] if the request fails or if the response is invalid. pub async fn get_all( user: &mut UserMeta, guild_id: &str, @@ -38,6 +52,21 @@ impl types::RoleObject { Ok(Some(roles)) } + /// Creates a new role for a given guild. + /// + /// # Arguments + /// + /// * `user` - A mutable reference to a [`UserMeta`] instance. + /// * `guild_id` - The ID of the guild to create the role in. + /// * `role_create_schema` - A [`RoleCreateModifySchema`] instance containing the properties of the role to be created. + /// + /// # Returns + /// + /// A `Result` containing the newly created [`RoleObject`] if successful, or a [`ChorusLibError`] if the request fails or if the response is invalid. + /// + /// # Errors + /// + /// Returns a [`ChorusLibError`] if the request fails or if the response is invalid. pub async fn create( user: &mut UserMeta, guild_id: &str,