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

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

View file

@ -476,6 +476,10 @@ class Localuser {
createGuild() {
let inviteurl = "";
const error = document.createElement("span");
const fields = {
name: "",
icon: null,
};
const full = new Dialog(["tabs", [
["Join using invite", [
"vdiv",
@ -509,12 +513,41 @@ class Localuser {
}
]
]],
["Create Server", [
"text", "Not currently implemented, sorry"
]]
["Create Guild",
["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();
}
async makeGuild(fields) {
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");