guild creation
This commit is contained in:
parent
f04efa6930
commit
0c0611adf2
4 changed files with 73 additions and 8 deletions
|
@ -1017,7 +1017,7 @@ class Channel {
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
allow: "0",
|
allow: "0",
|
||||||
deny: "0",
|
deny: "0",
|
||||||
id: role.snowflake,
|
id: role.id,
|
||||||
type: 0
|
type: 0
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -476,6 +476,10 @@ class Localuser {
|
||||||
createGuild() {
|
createGuild() {
|
||||||
let inviteurl = "";
|
let inviteurl = "";
|
||||||
const error = document.createElement("span");
|
const error = document.createElement("span");
|
||||||
|
const fields = {
|
||||||
|
name: "",
|
||||||
|
icon: null,
|
||||||
|
};
|
||||||
const full = new Dialog(["tabs", [
|
const full = new Dialog(["tabs", [
|
||||||
["Join using invite", [
|
["Join using invite", [
|
||||||
"vdiv",
|
"vdiv",
|
||||||
|
@ -509,12 +513,41 @@ class Localuser {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
]],
|
]],
|
||||||
["Create Server", [
|
["Create Guild",
|
||||||
"text", "Not currently implemented, sorry"
|
["vdiv",
|
||||||
]]
|
["title", "Create a guild"],
|
||||||
|
["fileupload", "Icon:", function (event) {
|
||||||
|
const reader = new FileReader();
|
||||||
|
const target = event.target;
|
||||||
|
reader.readAsDataURL(target.files[0]);
|
||||||
|
reader.onload = () => {
|
||||||
|
fields.icon = reader.result;
|
||||||
|
};
|
||||||
|
}],
|
||||||
|
["textbox", "Name:", "", function (event) {
|
||||||
|
const target = event.target;
|
||||||
|
fields.name = target.value;
|
||||||
|
}],
|
||||||
|
["button", "", "submit", () => {
|
||||||
|
this.makeGuild(fields).then(_ => {
|
||||||
|
if (_.message) {
|
||||||
|
alert(_.errors.name._errors[0].message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
full.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}]]]
|
||||||
]]);
|
]]);
|
||||||
full.show();
|
full.show();
|
||||||
}
|
}
|
||||||
|
async makeGuild(fields) {
|
||||||
|
return await (await fetch(this.info.api + "/guilds", {
|
||||||
|
method: "POST",
|
||||||
|
headers: this.headers,
|
||||||
|
body: JSON.stringify(fields),
|
||||||
|
})).json();
|
||||||
|
}
|
||||||
async guildDiscovery() {
|
async guildDiscovery() {
|
||||||
const content = document.createElement("div");
|
const content = document.createElement("div");
|
||||||
content.classList.add("guildy");
|
content.classList.add("guildy");
|
||||||
|
|
|
@ -1005,7 +1005,7 @@ class Channel{
|
||||||
body:JSON.stringify({
|
body:JSON.stringify({
|
||||||
allow:"0",
|
allow:"0",
|
||||||
deny:"0",
|
deny:"0",
|
||||||
id:role.snowflake,
|
id:role.id,
|
||||||
type:0
|
type:0
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -487,7 +487,10 @@ class Localuser{
|
||||||
createGuild(){
|
createGuild(){
|
||||||
let inviteurl="";
|
let inviteurl="";
|
||||||
const error=document.createElement("span");
|
const error=document.createElement("span");
|
||||||
|
const fields:{name:string,icon:string}={
|
||||||
|
name:"",
|
||||||
|
icon:null,
|
||||||
|
}
|
||||||
const full=new Dialog(["tabs",[
|
const full=new Dialog(["tabs",[
|
||||||
["Join using invite",[
|
["Join using invite",[
|
||||||
"vdiv",
|
"vdiv",
|
||||||
|
@ -522,12 +525,41 @@ class Localuser{
|
||||||
]
|
]
|
||||||
|
|
||||||
]],
|
]],
|
||||||
["Create Server",[
|
["Create Guild",
|
||||||
"text","Not currently implemented, sorry"
|
["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();
|
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() {
|
async guildDiscovery() {
|
||||||
const content=document.createElement("div");
|
const content=document.createElement("div");
|
||||||
content.classList.add("guildy");
|
content.classList.add("guildy");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue