Skip to content

Commit 676697c

Browse files
committed
Condense
1 parent e418108 commit 676697c

16 files changed

+160
-2739
lines changed
+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
* Vencord, a modification for Discord's desktop app
3+
* Copyright (c) 2023 Vendicated and contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
const API_URL = "https://api.pluralkit.me/v2/";
20+
const API_HEADERS = {
21+
"Content-Type": "application/json",
22+
"User-Agent": "Scyye Vencord/1.0 (contact @scyye on Discord for any issues)"
23+
}
24+
async function request<T>(endpoint: string) {
25+
return fetch(API_URL + endpoint, {
26+
method:"GET",
27+
headers: API_HEADERS,
28+
}).then(res => res.json() as T);
29+
}
30+
31+
async function getSystem(id: string) {
32+
return await request<System>(`systems/${id}`);
33+
}
34+
35+
async function getMessage(id: string) {
36+
return await request<PKMessage>(`messages/${id}`);
37+
}
38+
39+
async function getSystemGuildSettings(system: string, guild: string) {
40+
return await request<SystemGuildSettings>(`systems/${system}/guilds/${guild}`);
41+
}
42+
43+
async function getMembers(system: string) {
44+
return await request<Member[]>(`systems/${system}/members`);
45+
}
46+
47+
async function getMember(member: string) {
48+
return await request<Member>(`members/${member}`);
49+
}
50+
51+
async function getMemberGuildSettings(member: string, guild: string) {
52+
return await request<MemberGuildSettings>(`members/${member}/guilds/${guild}`);
53+
}
54+
55+
type System = {
56+
id: string;
57+
uuid: string;
58+
name: string;
59+
description: string;
60+
tag: string;
61+
pronouns: string;
62+
avatar_url: string;
63+
banner: string;
64+
color: string;
65+
created: string;
66+
privacy: SystemPrivacy;
67+
}
68+
69+
type SystemPrivacy = {
70+
description_privacy: "public"|"private";
71+
pronoun_privacy: "public"|"private";
72+
member_list_privacy: "public"|"private";
73+
group_list_privacy: "public"|"private";
74+
front_privacy: "public"|"private";
75+
front_history_privacy: "public"|"private";
76+
}
77+
78+
type Member = {
79+
id: string;
80+
uuid: string;
81+
system: string;
82+
name: string;
83+
display_name: string;
84+
color: string;
85+
birthday: string;
86+
pronouns: string;
87+
avatar_url: string;
88+
webhook_avatar_url: string;
89+
banner: string;
90+
description: string;
91+
created: string;
92+
proxy_tags: { prefix:string; suffix:string }[];
93+
keep_proxy: boolean;
94+
tts: boolean;
95+
autoproxy_enabled: boolean;
96+
message_count: number;
97+
last_message_timestamp: string;
98+
privacy: MemberPrivacy;
99+
}
100+
101+
type MemberPrivacy = {
102+
visibility: "public"|"private";
103+
name_privacy: "public"|"private";
104+
description_privacy: "public"|"private";
105+
birthday_privacy: "public"|"private";
106+
pronoun_privacy: "public"|"private";
107+
avatar_privacy: "public"|"private";
108+
metadata_privacy: "public"|"private";
109+
proxy_privacy: "public"|"private";
110+
}
111+
112+
type PKMessage = {
113+
timestamp: string;
114+
id: string;
115+
original: string;
116+
sender: string;
117+
channel: string;
118+
guild: string;
119+
system?: System;
120+
member?: Member;
121+
}
122+
123+
type SystemGuildSettings = {
124+
guild_id?: string;
125+
proxying_enabled: boolean;
126+
tag: string;
127+
tag_enabled: boolean;
128+
}
129+
130+
type MemberGuildSettings = {
131+
guild_id: string;
132+
display_name: string;
133+
avatar_url?: string;
134+
keep_proxy?: boolean;
135+
}
136+

0 commit comments

Comments
 (0)