Transmit guild name with patreon information

This commit is contained in:
jude 2023-10-07 16:08:25 +01:00
parent e3d3418f99
commit e8bd05893f
3 changed files with 6 additions and 13 deletions

View File

@ -124,7 +124,7 @@ pub async fn initialize(
routes::dashboard::user::get_user_info,
routes::dashboard::user::update_user_info,
routes::dashboard::user::get_user_guilds,
routes::dashboard::guild::get_guild_patreon,
routes::dashboard::guild::get_guild_info,
routes::dashboard::guild::get_guild_channels,
routes::dashboard::guild::get_guild_roles,
routes::dashboard::guild::get_reminder_templates,
@ -202,9 +202,6 @@ pub async fn check_authorization(
if std::env::var("OFFLINE").map_or(true, |v| v != "1") {
match user_id {
Some(user_id) => {
println!("{:?}", std::env::var("ADMIN_ID"));
println!("{:?}", user_id);
let admin_id = std::env::var("ADMIN_ID")
.map_or(false, |u| u.parse::<u64>().map_or(false, |u| u == user_id));

View File

@ -42,13 +42,9 @@ struct ChannelInfo {
webhook_name: Option<String>,
}
#[get("/api/guild/<id>/patreon")]
pub async fn get_guild_patreon(
id: u64,
cookies: &CookieJar<'_>,
ctx: &State<Context>,
) -> JsonResult {
offline!(Ok(json!({ "patreon": true })));
#[get("/api/guild/<id>")]
pub async fn get_guild_info(id: u64, cookies: &CookieJar<'_>, ctx: &State<Context>) -> JsonResult {
offline!(Ok(json!({ "patreon": true, "name": "Guild" })));
check_authorization(cookies, ctx.inner(), id).await?;
match GuildId(id).to_guild_cached(ctx.inner()) {
@ -63,7 +59,7 @@ pub async fn get_guild_patreon(
.contains(&RoleId(env::var("PATREON_ROLE_ID").unwrap().parse().unwrap()))
});
Ok(json!({ "patreon": patreon }))
Ok(json!({ "patreon": patreon, "name": guild.name }))
}
None => json_err!("Bot not in guild"),

View File

@ -105,7 +105,7 @@ function reset_guild_pane() {
}
async function fetch_patreon(guild_id) {
fetch(`/dashboard/api/guild/${guild_id}/patreon`)
fetch(`/dashboard/api/guild/${guild_id}`)
.then((response) => response.json())
.then((data) => {
if (data.error) {