feat: Ajout de l'id dans /info

This commit is contained in:
Max batleforc 2024-06-18 13:53:13 +02:00
parent 458e239b35
commit c8cc1dd39a
No known key found for this signature in database
GPG Key ID: 25D243AB4B6AC9E7
2 changed files with 15 additions and 2 deletions

View File

@ -17,6 +17,7 @@ use crate::api::bot::info;
components(
schemas(
info::Info,
info::InfoGuild,
)
),
paths(

View File

@ -7,12 +7,18 @@ use utoipa::ToSchema;
use crate::config::Config;
#[derive(Serialize, Deserialize, ToSchema)]
pub struct InfoGuild {
pub name: String,
pub id: u64,
}
#[derive(Serialize, Deserialize, ToSchema)]
pub struct Info {
pub name: String,
pub version: String,
pub description: String,
pub available_guids: Vec<String>,
pub available_guids: Vec<InfoGuild>,
}
#[utoipa::path(
@ -33,7 +39,13 @@ pub async fn get_info(config: web::Data<Config>, http: web::Data<Arc<Http>>) ->
name: "BotDiscord".to_string(),
version: env!("CARGO_PKG_VERSION").to_string(),
description: config.bot_name.clone(),
available_guids: guilds.iter().map(|g| g.name.clone()).collect(),
available_guids: guilds
.iter()
.map(|g| InfoGuild {
name: g.name.clone(),
id: g.id.get(),
})
.collect(),
}),
Err(e) => HttpResponse::InternalServerError().body(format!("Error getting guilds: {}", e)),
}