guild creation

This commit is contained in:
MathMan05 2024-08-17 11:36:25 -05:00
parent f04efa6930
commit 0c0611adf2
4 changed files with 73 additions and 8 deletions

View file

@ -1005,7 +1005,7 @@ class Channel{
body:JSON.stringify({
allow:"0",
deny:"0",
id:role.snowflake,
id:role.id,
type:0
})
})

View file

@ -487,7 +487,10 @@ class Localuser{
createGuild(){
let inviteurl="";
const error=document.createElement("span");
const fields:{name:string,icon:string}={
name:"",
icon:null,
}
const full=new Dialog(["tabs",[
["Join using invite",[
"vdiv",
@ -522,12 +525,41 @@ class Localuser{
]
]],
["Create Server",[
"text","Not currently implemented, sorry"
["Create Guild",
["vdiv",
["title","Create a guild"],
["fileupload","Icon:",function(event:InputEvent){
const reader=new FileReader();
const target=event.target as HTMLInputElement;
reader.readAsDataURL(target.files[0]);
reader.onload=() => {
fields.icon=reader.result as string;
}
}],
["textbox","Name:","",function(event:InputEvent){
const target=event.target as HTMLInputElement;
fields.name=target.value;
}],
["button","","submit",()=>{
this.makeGuild(fields).then(_=>{
if(_.message){
alert(_.errors.name._errors[0].message)
}else{
full.hide();
}
})
}]
]]
]])
full.show();
}
async makeGuild(fields:{name:string,icon:string}){
return await (await fetch(this.info.api+"/guilds",{
method:"POST",
headers:this.headers,
body:JSON.stringify(fields),
})).json();
}
async guildDiscovery() {
const content=document.createElement("div");
content.classList.add("guildy");