From 39cf289d2e91089234744cbf8d634ce98f188769 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Wed, 25 Sep 2024 00:05:47 -0500 Subject: [PATCH] fixes --- src/webpage/jsontypes.ts | 20 ++++++++++---------- src/webpage/localuser.ts | 6 ++++-- src/webpage/settings.ts | 15 ++++++++++++--- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/webpage/jsontypes.ts b/src/webpage/jsontypes.ts index 387fdd9..6be9e9c 100644 --- a/src/webpage/jsontypes.ts +++ b/src/webpage/jsontypes.ts @@ -117,16 +117,16 @@ flags: number; }; }; type mainuserjson = userjson & { -flags: number; -mfa_enabled?: boolean; -email?: string; -phone?: string; -verified: boolean; -nsfw_allowed: boolean; -premium: boolean; -purchased_flags: number; -premium_usage_flags: number; -disabled: boolean; + flags: number; + mfa_enabled?: boolean; + email?: string; + phone?: string; + verified: boolean; + nsfw_allowed: boolean; + premium: boolean; + purchased_flags: number; + premium_usage_flags: number; + disabled: boolean; }; type userjson = { username: string; diff --git a/src/webpage/localuser.ts b/src/webpage/localuser.ts index 62eeeb3..c9d58b8 100644 --- a/src/webpage/localuser.ts +++ b/src/webpage/localuser.ts @@ -8,6 +8,7 @@ import{ getapiurls, getBulkInfo, setTheme, Specialuser }from"./login.js"; import{ channeljson, guildjson, + mainuserjson, memberjson, messageCreateJson, presencejson, @@ -1412,13 +1413,14 @@ class Localuser{ if(!json.bot){ return alert("For some reason, this application doesn't have a bot (yet)."); } - const form=container.addSubForm("Editing bot "+json.bot.username,()=>{},{ + const bot:mainuserjson=json.bot; + const form=container.addSubForm("Editing bot "+bot.username,out=>{console.log(out)},{ method:"PATCH", fetchURL:this.info.api + "/applications/" + appId + "/bot", headers:this.headers, traditionalSubmit:true }); - form.addTextInput("Bot username:","username",{initText:json.bot.username}); + form.addTextInput("Bot username:","username",{initText:bot.username}); form.addFileInput("Bot avatar:","avatar"); form.addButtonInput("Reset Token:","Reset",async ()=>{ if(!confirm("Are you sure you want to reset the bot token? Your bot will stop working until you update it.")){ diff --git a/src/webpage/settings.ts b/src/webpage/settings.ts index feadabb..cc01f85 100644 --- a/src/webpage/settings.ts +++ b/src/webpage/settings.ts @@ -748,9 +748,6 @@ class Options implements OptionsElement{ return build; } isTop(){ - (this.owner instanceof Form&&this.owner.owner.subOptions!==this.owner), - (this.owner instanceof Settings), - (this.owner instanceof Buttons)); return (this.owner instanceof Options&&this.owner.subOptions!==this)|| (this.owner instanceof Form&&this.owner.owner.subOptions!==this.owner)|| (this.owner instanceof Settings)|| @@ -818,6 +815,11 @@ class Options implements OptionsElement{ } submit(){ this.haschanged = false; + if(this.subOptions){ + this.subOptions.submit(); + return; + } + for(const thing of this.options){ thing.submit(); } @@ -1029,6 +1031,11 @@ class Form implements OptionsElement{ } } async submit(){ + if(this.options.subOptions){ + this.options.subOptions.submit(); + return; + } + console.log("start"); const build = {}; for(const key of Object.keys(this.values)){ const thing = this.values[key]; @@ -1051,6 +1058,7 @@ class Form implements OptionsElement{ (build as any)[thing] = thing; } } + console.log("middle"); const promises: Promise[] = []; for(const thing of this.names.keys()){ if(thing === "")continue; @@ -1084,6 +1092,7 @@ class Form implements OptionsElement{ } (build as any)[thing] = input.value; } + console.log("middle2"); await Promise.allSettled(promises); if(this.fetchURL !== ""){ fetch(this.fetchURL, {