use super::*;
#[derive(Serialize, Deserialize, Debug)]
pub struct GetChannelListResponse {
pub items: Vec<ChannelItem>,
}
impl GetChannelListResponse {
pub fn end_point(key: &QQSecret) -> String {
if cfg!(debug_assertions) {
format!("https://sandbox.api.sgroup.qq.com/guilds/{guild_id}/channels", guild_id = key.guild_id())
}
else {
format!("https://api.sgroup.qq.com/guilds/{guild_id}/channels", guild_id = key.guild_id())
}
}
pub async fn send(key: &QQSecret) -> QQResult<Self> {
let url = Url::from_str(&Self::end_point(key))?;
let response = key.as_request(Method::GET, url).send().await?;
let out: Vec<ChannelItem> = response.json().await?;
return Ok(Self { items: out });
}
}
#[derive(Serialize, Deserialize, Debug)]
pub struct ChannelItem {
pub id: String,
pub guild_id: String,
pub name: String,
pub r#type: u32,
pub sub_type: u32,
pub position: u32,
pub parent_id: String,
pub owner_id: String,
pub private_type: Option<u32>,
pub speak_permission: Option<u32>,
pub application_id: Option<String>,
pub permissions: Option<String>,
}