adiscord 0.0.10

An API and Gateway Discord wrapper in Rust
Documentation
use crate::Error;
use adiscord_types::api::channels::Channel;
use reqwest::StatusCode;

impl crate::Guild {
    /// # Examples
    ///
    /// ```
    /// match client.guild.get_channels("1089521338286342195").await {
    ///     Ok(channels) => println!("{:?}", channels),
    ///     Err(error) => println!("{:?}", error),
    /// };
    /// ```
    pub async fn get_channels(&self, index: &str) -> Result<Vec<Channel>, Error> {
        let response = self
            .client
            .get(format!("{}/guilds/{index}/channels", self.url))
            .send()
            .await
            .unwrap();

        let status = response.status();
        match status {
            StatusCode::OK => {
                let body: Vec<Channel> = response.json().await.unwrap();
                Ok(body)
            }
            _ => {
                let body: Error = response.json().await.unwrap();
                Err(body)
            }
        }
    }
}