use reqwest::Client;
use serde_json::Value;
use std::error::Error;
#[allow(dead_code)]
pub async fn get_sticker(client: &Client, token: &str, sticker_id: &str) -> Result<Value, Box<dyn Error>> {
let url = format!("https://discord.com/api/v9/stickers/{}", sticker_id);
let response: Value = client.get(&url)
.bearer_auth(token)
.send()
.await?
.json()
.await?;
Ok(response)
}
#[allow(dead_code)]
pub async fn list_sticker_packs(client: &Client, token: &str) -> Result<Value, Box<dyn Error>> {
let url = "https://discord.com/api/v9/sticker-packs";
let response: Value = client.get(url)
.bearer_auth(token)
.send()
.await?
.json()
.await?;
Ok(response)
}
#[allow(dead_code)]
pub async fn list_guild_stickers(client: &Client, token: &str, guild_id: &str) -> Result<Value, Box<dyn Error>> {
let url = format!("https://discord.com/api/v9/guilds/{}/stickers", guild_id);
let response: Value = client.get(&url)
.bearer_auth(token)
.send()
.await?
.json()
.await?;
Ok(response)
}
#[allow(dead_code)]
pub async fn get_guild_sticker(client: &Client, token: &str, guild_id: &str, sticker_id: &str) -> Result<Value, Box<dyn Error>> {
let url = format!("https://discord.com/api/v9/guilds/{}/stickers/{}", guild_id, sticker_id);
let response: Value = client.get(&url)
.bearer_auth(token)
.send()
.await?
.json()
.await?;
Ok(response)
}
#[allow(dead_code)]
pub async fn create_guild_sticker(client: &Client, token: &str, guild_id: &str, sticker_data: Value) -> Result<Value, Box<dyn Error>> {
let url = format!("https://discord.com/api/v9/guilds/{}/stickers", guild_id);
let response: Value = client.post(&url)
.bearer_auth(token)
.json(&sticker_data)
.send()
.await?
.json()
.await?;
Ok(response)
}
#[allow(dead_code)]
pub async fn modify_guild_sticker(client: &Client, token: &str, guild_id: &str, sticker_id: &str, sticker_data: Value) -> Result<Value, Box<dyn Error>> {
let url = format!("https://discord.com/api/v9/guilds/{}/stickers/{}", guild_id, sticker_id);
let response: Value = client.patch(&url)
.bearer_auth(token)
.json(&sticker_data)
.send()
.await?
.json()
.await?;
Ok(response)
}
#[allow(dead_code)]
pub async fn delete_guild_sticker(client: &Client, token: &str, guild_id: &str, sticker_id: &str) -> Result<(), Box<dyn Error>> {
let url = format!("https://discord.com/api/v9/guilds/{}/stickers/{}", guild_id, sticker_id);
client.delete(&url)
.bearer_auth(token)
.send()
.await?
.error_for_status()?;
Ok(())
}