fix API bugs

This commit is contained in:
MathMan05 2024-08-11 17:49:57 -05:00
parent 1d705a6f63
commit 01be46d5e1
8 changed files with 42 additions and 42 deletions

View file

@ -117,7 +117,7 @@ class Guild {
noti noti
], ],
["button", "", "submit", _ => { ["button", "", "submit", _ => {
fetch(this.info.api + "/v9/users/@me/guilds/settings", { fetch(this.info.api + "/users/@me/guilds/settings", {
method: "PATCH", method: "PATCH",
headers: this.headers, headers: this.headers,
body: JSON.stringify({ body: JSON.stringify({
@ -211,7 +211,7 @@ class Guild {
if (serverbug) { if (serverbug) {
for (const thing of build) { for (const thing of build) {
console.log(build, thing); console.log(build, thing);
fetch(this.info.api + "/v9/guilds/" + this.snowflake + "/channels", { fetch(this.info.api + "/guilds/" + this.snowflake + "/channels", {
method: "PATCH", method: "PATCH",
headers: this.headers, headers: this.headers,
body: JSON.stringify([thing]) body: JSON.stringify([thing])
@ -219,7 +219,7 @@ class Guild {
} }
} }
else { else {
fetch(this.info.api + "/v9/guilds/" + this.snowflake + "/channels", { fetch(this.info.api + "/guilds/" + this.snowflake + "/channels", {
method: "PATCH", method: "PATCH",
headers: this.headers, headers: this.headers,
body: JSON.stringify(build) body: JSON.stringify(build)
@ -361,7 +361,7 @@ class Guild {
} }
} }
this.unreads(); this.unreads();
fetch(this.info.api + "/v9/read-states/ack-bulk", { fetch(this.info.api + "/read-states/ack-bulk", {
method: "POST", method: "POST",
headers: this.headers, headers: this.headers,
body: JSON.stringify(build) body: JSON.stringify(build)

View file

@ -479,7 +479,7 @@ class Localuser {
else { else {
parsed = inviteurl; parsed = inviteurl;
} }
fetch(this.info.api + "/v9/invites/" + parsed, { fetch(this.info.api + "/invites/" + parsed, {
method: "POST", method: "POST",
headers: this.headers, headers: this.headers,
}).then(r => r.json()).then(_ => { }).then(r => r.json()).then(_ => {
@ -502,7 +502,7 @@ class Localuser {
content.textContent = "Loading..."; content.textContent = "Loading...";
const full = new Fullscreen(["html", content]); const full = new Fullscreen(["html", content]);
full.show(); full.show();
const res = await fetch(this.info.api + "/v9/discoverable-guilds?limit=50", { const res = await fetch(this.info.api + "/discoverable-guilds?limit=50", {
headers: this.headers headers: this.headers
}); });
const json = await res.json(); const json = await res.json();
@ -539,7 +539,7 @@ class Localuser {
desc.textContent = guild.description; desc.textContent = guild.description;
content.appendChild(desc); content.appendChild(desc);
content.addEventListener("click", async () => { content.addEventListener("click", async () => {
const joinRes = await fetch(this.info.api + "/v9/guilds/" + guild.id + "/members/@me", { const joinRes = await fetch(this.info.api + "/guilds/" + guild.id + "/members/@me", {
method: "PUT", method: "PUT",
headers: this.headers headers: this.headers
}); });
@ -617,7 +617,7 @@ class Localuser {
}); });
} }
updatebio(bio) { updatebio(bio) {
fetch(this.info.api + "/v9/users/@me/profile", { fetch(this.info.api + "/users/@me/profile", {
method: "PATCH", method: "PATCH",
headers: this.headers, headers: this.headers,
body: JSON.stringify({ body: JSON.stringify({
@ -810,7 +810,7 @@ class Localuser {
connectionContainer connectionContainer
], () => { }, async () => { ], () => { }, async () => {
connectionContainer.innerHTML = ""; connectionContainer.innerHTML = "";
const res = await fetch(this.info.api + "/v9/connections", { const res = await fetch(this.info.api + "/connections", {
headers: this.headers headers: this.headers
}); });
const json = await res.json(); const json = await res.json();
@ -820,7 +820,7 @@ class Localuser {
container.textContent = key.charAt(0).toUpperCase() + key.slice(1); container.textContent = key.charAt(0).toUpperCase() + key.slice(1);
if (connection.enabled) { if (connection.enabled) {
container.addEventListener("click", async () => { container.addEventListener("click", async () => {
const connectionRes = await fetch(this.info.api + "/v9/connections/" + key + "/authorize", { const connectionRes = await fetch(this.info.api + "/connections/" + key + "/authorize", {
headers: this.headers headers: this.headers
}); });
const connectionJSON = await connectionRes.json(); const connectionJSON = await connectionRes.json();
@ -848,7 +848,7 @@ class Localuser {
async () => { async () => {
if (appName.trim().length == 0) if (appName.trim().length == 0)
return alert("Please enter a name for the application."); return alert("Please enter a name for the application.");
const res = await fetch(this.info.api + "/v9/applications", { const res = await fetch(this.info.api + "/applications", {
method: "POST", method: "POST",
headers: this.headers, headers: this.headers,
body: JSON.stringify({ body: JSON.stringify({
@ -866,7 +866,7 @@ class Localuser {
] ]
], () => { }, async () => { ], () => { }, async () => {
appListContainer.innerHTML = ""; appListContainer.innerHTML = "";
const res = await fetch(this.info.api + "/v9/applications", { const res = await fetch(this.info.api + "/applications", {
headers: this.headers headers: this.headers
}); });
const json = await res.json(); const json = await res.json();
@ -892,7 +892,7 @@ class Localuser {
}); });
} }
async manageApplication(appId = "") { async manageApplication(appId = "") {
const res = await fetch(this.info.api + "/v9/applications/" + appId, { const res = await fetch(this.info.api + "/applications/" + appId, {
headers: this.headers headers: this.headers
}); });
const json = await res.json(); const json = await res.json();
@ -940,7 +940,7 @@ class Localuser {
"", "",
"Save changes", "Save changes",
async () => { async () => {
const updateRes = await fetch(this.info.api + "/v9/applications/" + appId, { const updateRes = await fetch(this.info.api + "/applications/" + appId, {
method: "PATCH", method: "PATCH",
headers: this.headers, headers: this.headers,
body: JSON.stringify(fields) body: JSON.stringify(fields)
@ -960,7 +960,7 @@ class Localuser {
if (!json.bot) { if (!json.bot) {
if (!confirm("Are you sure you want to add a bot to this application? There's no going back.")) if (!confirm("Are you sure you want to add a bot to this application? There's no going back."))
return; return;
const updateRes = await fetch(this.info.api + "/v9/applications/" + appId + "/bot", { const updateRes = await fetch(this.info.api + "/applications/" + appId + "/bot", {
method: "POST", method: "POST",
headers: this.headers headers: this.headers
}); });
@ -976,7 +976,7 @@ class Localuser {
appDialog.show(); appDialog.show();
} }
async manageBot(appId = "") { async manageBot(appId = "") {
const res = await fetch(this.info.api + "/v9/applications/" + appId, { const res = await fetch(this.info.api + "/applications/" + appId, {
headers: this.headers headers: this.headers
}); });
const json = await res.json(); const json = await res.json();
@ -1010,7 +1010,7 @@ class Localuser {
"", "",
"Save changes", "Save changes",
async () => { async () => {
const updateRes = await fetch(this.info.api + "/v9/applications/" + appId + "/bot", { const updateRes = await fetch(this.info.api + "/applications/" + appId + "/bot", {
method: "PATCH", method: "PATCH",
headers: this.headers, headers: this.headers,
body: JSON.stringify(fields) body: JSON.stringify(fields)
@ -1029,7 +1029,7 @@ class Localuser {
async () => { async () => {
if (!confirm("Are you sure you want to reset the bot token? Your bot will stop working until you update it.")) if (!confirm("Are you sure you want to reset the bot token? Your bot will stop working until you update it."))
return; return;
const updateRes = await fetch(this.info.api + "/v9/applications/" + appId + "/bot/reset", { const updateRes = await fetch(this.info.api + "/applications/" + appId + "/bot/reset", {
method: "POST", method: "POST",
headers: this.headers headers: this.headers
}); });

View file

@ -16,7 +16,7 @@ class Member {
navigator.clipboard.writeText(this.id); navigator.clipboard.writeText(this.id);
}); });
this.contextmenu.addbutton("Message user", function () { this.contextmenu.addbutton("Message user", function () {
fetch(this.info.api + "/v9/users/@me/channels", { method: "POST", fetch(this.info.api + "/users/@me/channels", { method: "POST",
body: JSON.stringify({ "recipients": [this.id] }), body: JSON.stringify({ "recipients": [this.id] }),
headers: this.headers headers: this.headers
}); });

View file

@ -48,7 +48,7 @@ class User {
navigator.clipboard.writeText(this.id.id); navigator.clipboard.writeText(this.id.id);
}); });
this.contextmenu.addbutton("Message user", function () { this.contextmenu.addbutton("Message user", function () {
fetch(this.info.api + "/v9/users/@me/channels", { method: "POST", fetch(this.info.api + "/users/@me/channels", { method: "POST",
body: JSON.stringify({ "recipients": [this.id.id] }), body: JSON.stringify({ "recipients": [this.id.id] }),
headers: this.localuser.headers headers: this.localuser.headers
}); });
@ -124,7 +124,7 @@ class User {
User.contextmenu.bind(html, this); User.contextmenu.bind(html, this);
} }
static async resolve(id, localuser) { static async resolve(id, localuser) {
const json = await fetch(localuser.info.api.toString() + "/v9/users/" + id + "/profile", { headers: localuser.headers }).then(_ => _.json()); const json = await fetch(localuser.info.api.toString() + "/users/" + id + "/profile", { headers: localuser.headers }).then(_ => _.json());
return new User(json, localuser); return new User(json, localuser);
} }
changepfp(update) { changepfp(update) {

View file

@ -128,7 +128,7 @@ class Guild{
noti noti
], ],
["button","","submit",_=>{ ["button","","submit",_=>{
fetch(this.info.api+"/v9/users/@me/guilds/settings",{ fetch(this.info.api+"/users/@me/guilds/settings",{
method:"PATCH", method:"PATCH",
headers:this.headers, headers:this.headers,
body:JSON.stringify({ body:JSON.stringify({
@ -221,14 +221,14 @@ class Guild{
if(serverbug){ if(serverbug){
for(const thing of build){ for(const thing of build){
console.log(build,thing) console.log(build,thing)
fetch(this.info.api+"/v9/guilds/"+this.snowflake+"/channels",{ fetch(this.info.api+"/guilds/"+this.snowflake+"/channels",{
method:"PATCH", method:"PATCH",
headers:this.headers, headers:this.headers,
body:JSON.stringify([thing]) body:JSON.stringify([thing])
}); });
} }
}else{ }else{
fetch(this.info.api+"/v9/guilds/"+this.snowflake+"/channels",{ fetch(this.info.api+"/guilds/"+this.snowflake+"/channels",{
method:"PATCH", method:"PATCH",
headers:this.headers, headers:this.headers,
body:JSON.stringify(build) body:JSON.stringify(build)
@ -369,7 +369,7 @@ class Guild{
} }
} }
this.unreads(); this.unreads();
fetch(this.info.api+"/v9/read-states/ack-bulk",{ fetch(this.info.api+"/read-states/ack-bulk",{
method:"POST", method:"POST",
headers:this.headers, headers:this.headers,
body:JSON.stringify(build) body:JSON.stringify(build)

View file

@ -493,7 +493,7 @@ class Localuser{
}else{ }else{
parsed=inviteurl; parsed=inviteurl;
} }
fetch(this.info.api+"/v9/invites/"+parsed,{ fetch(this.info.api+"/invites/"+parsed,{
method:"POST", method:"POST",
headers:this.headers, headers:this.headers,
}).then(r=>r.json()).then(_=>{ }).then(r=>r.json()).then(_=>{
@ -518,7 +518,7 @@ class Localuser{
const full=new Fullscreen(["html", content]); const full=new Fullscreen(["html", content]);
full.show(); full.show();
const res=await fetch(this.info.api+"/v9/discoverable-guilds?limit=50", { const res=await fetch(this.info.api+"/discoverable-guilds?limit=50", {
headers: this.headers headers: this.headers
}); });
const json=await res.json(); const json=await res.json();
@ -562,7 +562,7 @@ class Localuser{
content.appendChild(desc); content.appendChild(desc);
content.addEventListener("click", async ()=>{ content.addEventListener("click", async ()=>{
const joinRes=await fetch(this.info.api+"/v9/guilds/"+guild.id+"/members/@me", { const joinRes=await fetch(this.info.api+"/guilds/"+guild.id+"/members/@me", {
method: "PUT", method: "PUT",
headers: this.headers headers: this.headers
}); });
@ -637,7 +637,7 @@ class Localuser{
}); });
} }
updatebio(bio:string):void{ updatebio(bio:string):void{
fetch(this.info.api+"/v9/users/@me/profile",{ fetch(this.info.api+"/users/@me/profile",{
method:"PATCH", method:"PATCH",
headers:this.headers, headers:this.headers,
body:JSON.stringify({ body:JSON.stringify({
@ -832,7 +832,7 @@ class Localuser{
], () => {}, async () => { ], () => {}, async () => {
connectionContainer.innerHTML=""; connectionContainer.innerHTML="";
const res=await fetch(this.info.api+"/v9/connections", { const res=await fetch(this.info.api+"/connections", {
headers: this.headers headers: this.headers
}); });
const json=await res.json(); const json=await res.json();
@ -845,7 +845,7 @@ class Localuser{
if (connection.enabled) { if (connection.enabled) {
container.addEventListener("click", async () => { container.addEventListener("click", async () => {
const connectionRes=await fetch(this.info.api+"/v9/connections/" + key + "/authorize", { const connectionRes=await fetch(this.info.api+"/connections/" + key + "/authorize", {
headers: this.headers headers: this.headers
}); });
const connectionJSON=await connectionRes.json(); const connectionJSON=await connectionRes.json();
@ -876,7 +876,7 @@ class Localuser{
async () => { async () => {
if (appName.trim().length == 0) return alert("Please enter a name for the application."); if (appName.trim().length == 0) return alert("Please enter a name for the application.");
const res=await fetch(this.info.api+"/v9/applications", { const res=await fetch(this.info.api+"/applications", {
method: "POST", method: "POST",
headers: this.headers, headers: this.headers,
body: JSON.stringify({ body: JSON.stringify({
@ -895,7 +895,7 @@ class Localuser{
], () => {}, async () => { ], () => {}, async () => {
appListContainer.innerHTML=""; appListContainer.innerHTML="";
const res=await fetch(this.info.api+"/v9/applications", { const res=await fetch(this.info.api+"/applications", {
headers: this.headers headers: this.headers
}); });
const json=await res.json(); const json=await res.json();
@ -926,7 +926,7 @@ class Localuser{
) )
} }
async manageApplication(appId="") { async manageApplication(appId="") {
const res=await fetch(this.info.api+"/v9/applications/" + appId, { const res=await fetch(this.info.api+"/applications/" + appId, {
headers: this.headers headers: this.headers
}); });
const json=await res.json(); const json=await res.json();
@ -976,7 +976,7 @@ class Localuser{
"", "",
"Save changes", "Save changes",
async () => { async () => {
const updateRes=await fetch(this.info.api+"/v9/applications/" + appId, { const updateRes=await fetch(this.info.api+"/applications/" + appId, {
method: "PATCH", method: "PATCH",
headers: this.headers, headers: this.headers,
body: JSON.stringify(fields) body: JSON.stringify(fields)
@ -995,7 +995,7 @@ class Localuser{
if (!json.bot) { if (!json.bot) {
if (!confirm("Are you sure you want to add a bot to this application? There's no going back.")) return; if (!confirm("Are you sure you want to add a bot to this application? There's no going back.")) return;
const updateRes=await fetch(this.info.api+"/v9/applications/" + appId + "/bot", { const updateRes=await fetch(this.info.api+"/applications/" + appId + "/bot", {
method: "POST", method: "POST",
headers: this.headers headers: this.headers
}); });
@ -1013,7 +1013,7 @@ class Localuser{
appDialog.show(); appDialog.show();
} }
async manageBot(appId="") { async manageBot(appId="") {
const res=await fetch(this.info.api+"/v9/applications/" + appId, { const res=await fetch(this.info.api+"/applications/" + appId, {
headers: this.headers headers: this.headers
}); });
const json=await res.json(); const json=await res.json();
@ -1048,7 +1048,7 @@ class Localuser{
"", "",
"Save changes", "Save changes",
async () => { async () => {
const updateRes=await fetch(this.info.api+"/v9/applications/" + appId + "/bot", { const updateRes=await fetch(this.info.api+"/applications/" + appId + "/bot", {
method: "PATCH", method: "PATCH",
headers: this.headers, headers: this.headers,
body: JSON.stringify(fields) body: JSON.stringify(fields)
@ -1066,7 +1066,7 @@ class Localuser{
async () => { async () => {
if (!confirm("Are you sure you want to reset the bot token? Your bot will stop working until you update it.")) return; if (!confirm("Are you sure you want to reset the bot token? Your bot will stop working until you update it.")) return;
const updateRes=await fetch(this.info.api+"/v9/applications/" + appId + "/bot/reset", { const updateRes=await fetch(this.info.api+"/applications/" + appId + "/bot/reset", {
method: "POST", method: "POST",
headers: this.headers headers: this.headers
}); });

View file

@ -18,7 +18,7 @@ class Member{
navigator.clipboard.writeText(this.id); navigator.clipboard.writeText(this.id);
}); });
this.contextmenu.addbutton("Message user",function(){ this.contextmenu.addbutton("Message user",function(){
fetch(this.info.api+"/v9/users/@me/channels", fetch(this.info.api+"/users/@me/channels",
{method:"POST", {method:"POST",
body:JSON.stringify({"recipients":[this.id]}), body:JSON.stringify({"recipients":[this.id]}),
headers: this.headers headers: this.headers

View file

@ -52,7 +52,7 @@ class User{
navigator.clipboard.writeText(this.id.id); navigator.clipboard.writeText(this.id.id);
}); });
this.contextmenu.addbutton("Message user",function(){ this.contextmenu.addbutton("Message user",function(){
fetch(this.info.api+"/v9/users/@me/channels", fetch(this.info.api+"/users/@me/channels",
{method:"POST", {method:"POST",
body:JSON.stringify({"recipients":[this.id.id]}), body:JSON.stringify({"recipients":[this.id.id]}),
headers: this.localuser.headers headers: this.localuser.headers
@ -125,7 +125,7 @@ class User{
User.contextmenu.bind(html,this); User.contextmenu.bind(html,this);
} }
static async resolve(id:string,localuser:Localuser){ static async resolve(id:string,localuser:Localuser){
const json=await fetch(localuser.info.api.toString()+"/v9/users/"+id+"/profile", const json=await fetch(localuser.info.api.toString()+"/users/"+id+"/profile",
{headers:localuser.headers} {headers:localuser.headers}
).then(_=>_.json()); ).then(_=>_.json());
return new User(json,localuser); return new User(json,localuser);