guild settings

This commit is contained in:
MathMan05 2024-09-10 14:52:30 -05:00
parent 72ac3a14ed
commit 68ab121d63
7 changed files with 45 additions and 62 deletions

View file

@ -71,6 +71,14 @@ class Guild extends SnowFlake {
method: "PATCH" 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 s1 = settings.addButton("roles");
const permlist = []; const permlist = [];

View file

@ -299,8 +299,8 @@ class Message extends SnowFlake {
next.generateMessage(); next.generateMessage();
next = this.channel.messages.get(this.channel.idToNext.get(next.id)); next = this.channel.messages.get(this.channel.idToNext.get(next.id));
} }
if (this.channel.infinite.div && scroll) { if (this.channel.infinite.scollDiv && scroll) {
this.channel.infinite.div.scrollTop = 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)); next = this.channel.messages.get(this.channel.idToNext.get(next.id));
console.log("loopy"); console.log("loopy");
} }
if (this.channel.infinite.div && scroll) { if (this.channel.infinite.scollDiv && scroll) {
func(); func();
this.channel.infinite.div.scrollTop = scroll; this.channel.infinite.scollDiv.scrollTop = scroll;
} }
}; };
div.appendChild(build); div.appendChild(build);

View file

@ -390,9 +390,11 @@ class FileInput {
onChange(ev) { onChange(ev) {
this.owner.changed(); this.owner.changed();
const input = this.input.deref(); const input = this.input.deref();
if (this.onchange && input) { if (input) {
this.value = input.files; this.value = input.files;
this.onchange(input.files); if (this.onchange) {
this.onchange(input.files);
}
} }
} }
onchange = null; onchange = null;
@ -698,8 +700,10 @@ class Form {
return select; return select;
} }
fileOptions = new Map(); fileOptions = new Map();
addFileInput(label, formName, { required, files } = { required: false, files: "multi" }) { addFileInput(label, formName, { required = false, files = "one", clear = false } = {}) {
const FI = this.options.addFileInput(label, _ => { }, {}); 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.fileOptions.set(FI, { files });
this.names.set(formName, FI); this.names.set(formName, FI);
if (required) { if (required) {
@ -808,6 +812,7 @@ class Form {
throw new Error("FileInput without its options is in this form, this should never happen."); throw new Error("FileInput without its options is in this form, this should never happen.");
} }
if (options.files === "one") { if (options.files === "one") {
console.log(input.value);
if (input.value) { if (input.value) {
const reader = new FileReader(); const reader = new FileReader();
reader.readAsDataURL(input.value[0]); reader.readAsDataURL(input.value[0]);

View file

@ -14,7 +14,7 @@ class Guild extends SnowFlake{
owner:Localuser; owner:Localuser;
headers:Localuser["headers"]; headers:Localuser["headers"];
channels:Channel[]; channels:Channel[];
properties; properties:guildjson["properties"];
member_count:number; member_count:number;
roles:Role[]; roles:Role[];
roleids:Map<string,Role>; roleids:Map<string,Role>;
@ -79,7 +79,15 @@ class Guild extends SnowFlake{
fetchURL:this.info.api+"/guilds/"+this.id, fetchURL:this.info.api+"/guilds/"+this.id,
method:"PATCH" 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 s1=settings.addButton("roles");
const permlist:[Role,Permissions][]=[]; const permlist:[Role,Permissions][]=[];

View file

@ -179,6 +179,7 @@ type guildjson={
member_count: number, member_count: number,
premium_subscription_count: number, premium_subscription_count: number,
properties: { properties: {
region: string|null,
name: string, name: string,
description: string, description: string,
icon: string, icon: string,
@ -359,50 +360,7 @@ type invitejson={
target_user_type: string|null, target_user_type: string|null,
vanity_url: string|null, vanity_url: string|null,
flags: number, flags: number,
guild: { guild: guildjson["properties"],
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
},
channel: channeljson, channel: channeljson,
inviter: userjson inviter: userjson
} }

View file

@ -295,8 +295,8 @@ class Message extends SnowFlake{
next.generateMessage(); next.generateMessage();
next=this.channel.messages.get(this.channel.idToNext.get(next.id) as string); next=this.channel.messages.get(this.channel.idToNext.get(next.id) as string);
} }
if(this.channel.infinite.div&&scroll){ if(this.channel.infinite.scollDiv&&scroll){
this.channel.infinite.div.scrollTop=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); next=this.channel.messages.get(this.channel.idToNext.get(next.id) as string);
console.log("loopy"); console.log("loopy");
} }
if(this.channel.infinite.div&&scroll){ if(this.channel.infinite.scollDiv&&scroll){
func(); func();
this.channel.infinite.div.scrollTop=scroll; this.channel.infinite.scollDiv.scrollTop=scroll;
} }
}; };
div.appendChild(build); div.appendChild(build);

View file

@ -404,9 +404,11 @@ class FileInput implements OptionsElement<FileList|null>{
onChange(ev:Event){ onChange(ev:Event){
this.owner.changed(); this.owner.changed();
const input=this.input.deref(); const input=this.input.deref();
if(this.onchange&&input){ if(input){
this.value=input.files; this.value=input.files;
this.onchange(input.files); if(this.onchange){
this.onchange(input.files);
}
} }
} }
onchange:((str:FileList|null)=>void)|null=null; onchange:((str:FileList|null)=>void)|null=null;
@ -706,8 +708,9 @@ class Form implements OptionsElement<object>{
return select; return select;
} }
readonly fileOptions:Map<FileInput,{files:"one"|"multi"}>=new Map(); readonly fileOptions:Map<FileInput,{files:"one"|"multi"}>=new Map();
addFileInput(label:string,formName:string,{required,files}:{required:boolean,files:"one"|"multi"}={required:false,files:"multi"}){ addFileInput(label:string,formName:string,{required=false,files="one",clear=false}={}){
const FI=this.options.addFileInput(label,_=>{},{}); 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.fileOptions.set(FI,{files});
this.names.set(formName,FI); this.names.set(formName,FI);
if(required){ if(required){
@ -815,6 +818,7 @@ class Form implements OptionsElement<object>{
throw new Error("FileInput without its options is in this form, this should never happen."); throw new Error("FileInput without its options is in this form, this should never happen.");
} }
if(options.files==="one"){ if(options.files==="one"){
console.log(input.value);
if(input.value){ if(input.value){
const reader=new FileReader(); const reader=new FileReader();
reader.readAsDataURL(input.value[0]); reader.readAsDataURL(input.value[0]);