qq_bot/restful/
get_channel.rs1use super::*;
2
3#[derive(Serialize, Deserialize, Debug)]
7pub struct GetChannelListResponse {
8 pub items: Vec<ChannelItem>,
9}
10
11impl GetChannelListResponse {
12 pub fn end_point(key: &QQSecret) -> String {
13 if cfg!(debug_assertions) {
14 format!("https://sandbox.api.sgroup.qq.com/guilds/{guild_id}/channels", guild_id = key.guild_id())
15 }
16 else {
17 format!("https://api.sgroup.qq.com/guilds/{guild_id}/channels", guild_id = key.guild_id())
18 }
19 }
20
21 pub async fn send(key: &QQSecret) -> QQResult<Self> {
22 let url = Url::from_str(&Self::end_point(key))?;
23 let response = key.as_request(Method::GET, url).send().await?;
24 let out: Vec<ChannelItem> = response.json().await?;
25 return Ok(Self { items: out });
26 }
27}
28
29#[derive(Serialize, Deserialize, Debug)]
30pub struct ChannelItem {
31 pub id: String,
33 pub guild_id: String,
35 pub name: String,
37 pub r#type: u32,
39 pub sub_type: u32,
41 pub position: u32,
43 pub parent_id: String,
45 pub owner_id: String,
47 pub private_type: Option<u32>,
49 pub speak_permission: Option<u32>,
51 pub application_id: Option<String>,
53 pub permissions: Option<String>,
55}