use serde::Deserialize;
use crate::Result;
use super::DiscordRest;
#[derive(Debug, Deserialize)]
pub(in crate::discord) struct ApplicationRpcInfo {
pub name: String,
}
#[derive(Debug, Deserialize)]
pub(in crate::discord) struct ApplicationAsset {
pub id: String,
pub name: String,
}
#[derive(Debug, Deserialize)]
pub(in crate::discord) struct ExternalAsset {
pub external_asset_path: String,
}
impl DiscordRest {
pub(in crate::discord) async fn application_rpc(
&self,
application_id: &str,
) -> Result<ApplicationRpcInfo> {
self.send_json(
self.raw_http.get(format!(
"https://discord.com/api/v9/applications/{application_id}/rpc"
)),
"application rpc info",
)
.await
}
pub(in crate::discord) async fn application_assets(
&self,
application_id: &str,
) -> Result<Vec<ApplicationAsset>> {
self.send_json(
self.raw_http.get(format!(
"https://discord.com/api/v9/oauth2/applications/{application_id}/assets"
)),
"application assets",
)
.await
}
pub(in crate::discord) async fn application_external_assets(
&self,
application_id: &str,
urls: &[&str],
) -> Result<Vec<ExternalAsset>> {
self.send_json(
self.raw_http
.post(format!(
"https://discord.com/api/v9/applications/{application_id}/external-assets"
))
.json(&serde_json::json!({ "urls": urls })),
"application external assets",
)
.await
}
}