From 68ab121d631ea18c3311ee86d0b9f8d3a47936e2 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Tue, 10 Sep 2024 14:52:30 -0500 Subject: [PATCH] guild settings --- .dist/guild.js | 8 ++++++++ .dist/message.js | 8 ++++---- .dist/settings.js | 13 +++++++++---- webpage/guild.ts | 12 ++++++++++-- webpage/jsontypes.ts | 46 ++------------------------------------------ webpage/message.ts | 8 ++++---- webpage/settings.ts | 12 ++++++++---- 7 files changed, 45 insertions(+), 62 deletions(-) diff --git a/.dist/guild.js b/.dist/guild.js index f19c40d..2eee51f 100644 --- a/.dist/guild.js +++ b/.dist/guild.js @@ -71,6 +71,14 @@ class Guild extends SnowFlake { method: "PATCH" }); form.addTextInput("Name:", "name", { initText: this.properties.name }); + form.addMDInput("Description:", "description", { initText: this.properties.description }); + form.addFileInput("Banner:", "banner", { clear: true }); + form.addFileInput("Icon:", "icon", { clear: true }); + let region = this.properties.region; + if (!region) { + region = ""; + } + form.addTextInput("Region:", "region", { initText: region }); } const s1 = settings.addButton("roles"); const permlist = []; diff --git a/.dist/message.js b/.dist/message.js index 1bf4cf1..37790f5 100644 --- a/.dist/message.js +++ b/.dist/message.js @@ -299,8 +299,8 @@ class Message extends SnowFlake { next.generateMessage(); next = this.channel.messages.get(this.channel.idToNext.get(next.id)); } - if (this.channel.infinite.div && scroll) { - this.channel.infinite.div.scrollTop = scroll; + if (this.channel.infinite.scollDiv && scroll) { + this.channel.infinite.scollDiv.scrollTop = scroll; } }; } @@ -333,9 +333,9 @@ class Message extends SnowFlake { next = this.channel.messages.get(this.channel.idToNext.get(next.id)); console.log("loopy"); } - if (this.channel.infinite.div && scroll) { + if (this.channel.infinite.scollDiv && scroll) { func(); - this.channel.infinite.div.scrollTop = scroll; + this.channel.infinite.scollDiv.scrollTop = scroll; } }; div.appendChild(build); diff --git a/.dist/settings.js b/.dist/settings.js index 60b4073..f92c485 100644 --- a/.dist/settings.js +++ b/.dist/settings.js @@ -390,9 +390,11 @@ class FileInput { onChange(ev) { this.owner.changed(); const input = this.input.deref(); - if (this.onchange && input) { + if (input) { this.value = input.files; - this.onchange(input.files); + if (this.onchange) { + this.onchange(input.files); + } } } onchange = null; @@ -698,8 +700,10 @@ class Form { return select; } fileOptions = new Map(); - addFileInput(label, formName, { required, files } = { required: false, files: "multi" }) { - const FI = this.options.addFileInput(label, _ => { }, {}); + addFileInput(label, formName, { required = false, files = "one", clear = false } = {}) { + const FI = this.options.addFileInput(label, _ => { }, { clear }); + if (files !== "one" && files !== "multi") + throw new Error("files should equal one or multi"); this.fileOptions.set(FI, { files }); this.names.set(formName, FI); if (required) { @@ -808,6 +812,7 @@ class Form { throw new Error("FileInput without its options is in this form, this should never happen."); } if (options.files === "one") { + console.log(input.value); if (input.value) { const reader = new FileReader(); reader.readAsDataURL(input.value[0]); diff --git a/webpage/guild.ts b/webpage/guild.ts index a84f7c0..11fe3ab 100644 --- a/webpage/guild.ts +++ b/webpage/guild.ts @@ -14,7 +14,7 @@ class Guild extends SnowFlake{ owner:Localuser; headers:Localuser["headers"]; channels:Channel[]; - properties; + properties:guildjson["properties"]; member_count:number; roles:Role[]; roleids:Map; @@ -79,7 +79,15 @@ class Guild extends SnowFlake{ fetchURL:this.info.api+"/guilds/"+this.id, method:"PATCH" }) - form.addTextInput("Name:","name",{initText:this.properties.name}) + form.addTextInput("Name:","name",{initText:this.properties.name}); + form.addMDInput("Description:","description",{initText:this.properties.description}); + form.addFileInput("Banner:","banner",{clear:true}); + form.addFileInput("Icon:","icon",{clear:true}); + let region=this.properties.region; + if(!region){ + region=""; + } + form.addTextInput("Region:","region",{initText:region}); } const s1=settings.addButton("roles"); const permlist:[Role,Permissions][]=[]; diff --git a/webpage/jsontypes.ts b/webpage/jsontypes.ts index 8dcb3ad..2072f0f 100644 --- a/webpage/jsontypes.ts +++ b/webpage/jsontypes.ts @@ -179,6 +179,7 @@ type guildjson={ member_count: number, premium_subscription_count: number, properties: { + region: string|null, name: string, description: string, icon: string, @@ -359,50 +360,7 @@ type invitejson={ target_user_type: string|null, vanity_url: string|null, flags: number, - guild: { - id: string, - afk_channel_id: string|null, - afk_timeout: number, - banner: string|null, - default_message_notifications: number, - description: string|null, - discovery_splash: string|null, - explicit_content_filter: number, - features: [], - primary_category_id: string|null, - icon: string|null, - large: boolean, - max_members: number, - max_presences: number, - max_video_channel_users: number, - member_count: number, - presence_count: number, - template_id: string|null, - mfa_level: number, - name: string, - owner_id: string, - preferred_locale: string, - premium_subscription_count: number, - premium_tier: number, - public_updates_channel_id: string|null, - rules_channel_id: string|null, - region: string|null, - splash: string|null, - system_channel_id: string|null, - system_channel_flags: number, - verification_level: number, - welcome_screen: { - enabled: boolean, - description: string, - welcome_channels: string[] - }, - widget_channel_id: string|null, - widget_enabled: boolean, - nsfw_level: number, - nsfw: boolean, - parent: string|null, - premium_progress_bar_enabled: boolean - }, + guild: guildjson["properties"], channel: channeljson, inviter: userjson } diff --git a/webpage/message.ts b/webpage/message.ts index 09463a2..8d6afd4 100644 --- a/webpage/message.ts +++ b/webpage/message.ts @@ -295,8 +295,8 @@ class Message extends SnowFlake{ next.generateMessage(); next=this.channel.messages.get(this.channel.idToNext.get(next.id) as string); } - if(this.channel.infinite.div&&scroll){ - this.channel.infinite.div.scrollTop=scroll; + if(this.channel.infinite.scollDiv&&scroll){ + this.channel.infinite.scollDiv.scrollTop=scroll; } }; } @@ -327,9 +327,9 @@ class Message extends SnowFlake{ next=this.channel.messages.get(this.channel.idToNext.get(next.id) as string); console.log("loopy"); } - if(this.channel.infinite.div&&scroll){ + if(this.channel.infinite.scollDiv&&scroll){ func(); - this.channel.infinite.div.scrollTop=scroll; + this.channel.infinite.scollDiv.scrollTop=scroll; } }; div.appendChild(build); diff --git a/webpage/settings.ts b/webpage/settings.ts index a42edc6..5edb3ff 100644 --- a/webpage/settings.ts +++ b/webpage/settings.ts @@ -404,9 +404,11 @@ class FileInput implements OptionsElement{ onChange(ev:Event){ this.owner.changed(); const input=this.input.deref(); - if(this.onchange&&input){ + if(input){ this.value=input.files; - this.onchange(input.files); + if(this.onchange){ + this.onchange(input.files); + } } } onchange:((str:FileList|null)=>void)|null=null; @@ -706,8 +708,9 @@ class Form implements OptionsElement{ return select; } readonly fileOptions:Map=new Map(); - addFileInput(label:string,formName:string,{required,files}:{required:boolean,files:"one"|"multi"}={required:false,files:"multi"}){ - const FI=this.options.addFileInput(label,_=>{},{}); + addFileInput(label:string,formName:string,{required=false,files="one",clear=false}={}){ + const FI=this.options.addFileInput(label,_=>{},{clear}); + if(files!=="one"&&files!=="multi") throw new Error("files should equal one or multi"); this.fileOptions.set(FI,{files}); this.names.set(formName,FI); if(required){ @@ -815,6 +818,7 @@ class Form implements OptionsElement{ throw new Error("FileInput without its options is in this form, this should never happen."); } if(options.files==="one"){ + console.log(input.value); if(input.value){ const reader=new FileReader(); reader.readAsDataURL(input.value[0]);