From 42406c18383902bbef5f3d78e5c04511eff9f519 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sat, 13 Jun 2026 20:24:12 +0200 Subject: [PATCH] Replace APIRole with schema --- assets/openapi.json | Bin 972276 -> 976879 bytes assets/schemas.json | Bin 439600 -> 443855 bytes .../routes/guilds/#guild_id/roles/index.ts | 2 +- src/schemas/api/guilds/Role.ts | 61 ++++++++++++++++++ src/schemas/responses/TypedResponses.ts | 4 +- 5 files changed, 63 insertions(+), 4 deletions(-) diff --git a/assets/openapi.json b/assets/openapi.json index 95a8807f5a6b4a7a8781fd84ed76e48585c4922a..45a151ba04dba199bfd7883c42295a8e31b4a806 100644 GIT binary patch delta 449 zcmeye+WP%@>xLG_Elm1+%t84%lM5fFZWma^_>Xb&gNbod4=`FxS{XjQ|1uxPbiYzo z?a2Xgx*#6wboF*-`RNWR9CFi*SFxH;*IL4wFg-w+rDOW;HfAfJp2-2ls*?rQ*iSEL zVNRLewS@J=^bbNT3DZBg^0H6o$zYZSYi7;QNexMy9ypU#a=JkitIzb`t60q@Z;(`; z-o2Xj%k*m71^Oa2WctD9Y>Lwz`dI9zZ(Gi)H2uL&E`jX^eT?TBr!VMaW}SRNn0>nC3RZa} ziOKr&d8YI2X3?Df;W0ZuMDgSUKl!KcS;49>-Qfb0;Pem7KzCo*#$+?SPlbh(J3cMH zD88VyC^;i>dSfu7`1A)=+?>+|Bw4k=iY5p2v9TrR=jEj)PkwkxdwRi37Uk&$<*eqD z6)bos8|VnM>(5~aVh$kY+^#=|E3p9LSqE$GY1<2Gxf@u3dN`b?PpIVbpUx-FE!OTQ R#0|teK+L<{Pl#{XVE`aYt406- delta 149 zcmaEV-ulaG>xLG_Elm1+)8FZ{v2U-HU@AGw5|p2lI{m?3ri$qgWVl(TZ-`b8gpP#}!e)?ik<+Hj7c1 rvuyeTe@@Bm2@*U)tke1Ux!I=kYjO*;d#Z2)F%J;)ZueB-TXq-#+0i$+ diff --git a/assets/schemas.json b/assets/schemas.json index 9506fab1c452f0243d49dfc6ba3c011fdd8bba08..b82fe51886b7c7d7a7b248a276b063e3b1b382e7 100644 GIT binary patch delta 358 zcmX|+%PT}-7{>d~_nu>9m`TZ)(@aJwkuoWik|ZollW8_)gHGcTnHwv&vm-3%E00qA z0diTWvyqK4Xkv~XvKSkSSeHci|j_cp4=>q+_|;$#H2=;mt2MVKm{6{O3mTH#k`2G@vfapiQvCt zQR6PnZVp$23CV(6kcDgn6Ut?|&AL1q9-Bys1nY%-PpXlRuxo}7Rkq`8npgkM!n0<_ z>ofQLJy-0IY;az%61?1#OXy`b. +*/ + +import { Snowflake } from "../../Identifiers"; + +export interface RoleResponse { + id: Snowflake; + name: string; + description: string | null; + // @deprecated + color: number; + colors: RoleColors; + hoist: boolean; + icon?: string | null; + unicode_emoji?: string | null; + position: number; + // @format number + permissions: string; + managed: boolean; + mentionable: boolean; + flags?: number; + tags?: RoleTags; // unused currently +} + +export type RoleListResponse = RoleResponse[]; + export class RoleColors { primary_color: number; secondary_color: number | undefined; // only used for "holographic" and "gradient" styles @@ -11,3 +52,23 @@ export class RoleColors { }; } } + +export class RoleTags { + bot_id?: Snowflake; + integration_id?: Snowflake; + subscription_listing_id?: Snowflake; + // ??? https://github.com/discord-userdoccers/discord-userdoccers/issues/576 - in other words, types are currently unknown + premium_subscriber?: boolean | null; + available_for_purchase?: boolean | null; + guild_connections?: boolean | null; + + toJSON(): RoleTags { + return { + ...this, + // "forward compatibility" + premium_subscriber: this.premium_subscriber ? null : undefined, + available_for_purchase: this.available_for_purchase ? null : undefined, + guild_connections: this.subscription_listing_id ? null : undefined, + }; + } +} diff --git a/src/schemas/responses/TypedResponses.ts b/src/schemas/responses/TypedResponses.ts index 692487b0a..e0413a72e 100644 --- a/src/schemas/responses/TypedResponses.ts +++ b/src/schemas/responses/TypedResponses.ts @@ -20,8 +20,7 @@ import { GeneralConfiguration, LimitsConfiguration } from "../../util/config/types"; import { DmChannelDTO } from "../../util/dtos"; // TODO: remove entity imports -import { Application, BackupCode, Categories, Channel, Guild, Invite, Member, Message, Role, Template, Webhook } from "@spacebar/database"; -import { GuildVoiceRegion } from "./GuildVoiceRegionsResponse"; +import { Application, BackupCode, Categories, Channel, Guild, Invite, Member, Message, Template, Webhook } from "@spacebar/database"; import { GuildCreateResponse, PrivateUser, PublicMember, PublicUser } from "@spacebar/schemas"; // TODO: remove this entire file! @@ -54,7 +53,6 @@ export interface APIGuildWithJoinedAt extends GuildCreateResponse { joined_at: string; } -export type APIRoleArray = Role[]; export type APITemplateArray = Template[]; export type APILimitsConfiguration = LimitsConfiguration;