fix JS files

This commit is contained in:
MathMan05 2024-07-01 13:52:17 -05:00
parent 3c0c7e6f4f
commit c2a77af323
12 changed files with 130 additions and 116 deletions

View file

@ -37,12 +37,12 @@ class Voice {
this.updateWave(); this.updateWave();
} }
updateWave() { updateWave() {
const func = this.waveFucnion(); const func = this.waveFunction();
for (let i = 0; i < this.buffer.length; i++) { for (let i = 0; i < this.buffer.length; i++) {
this.buffer[i] = func(i / this.audioCtx.sampleRate, this.freq); this.buffer[i] = func(i / this.audioCtx.sampleRate, this.freq);
} }
} }
waveFucnion() { waveFunction() {
if (typeof this.wave === 'function') { if (typeof this.wave === 'function') {
return this.wave; return this.wave;
} }
@ -127,12 +127,12 @@ class Voice {
} }
static setNotificationSound(sound) { static setNotificationSound(sound) {
let userinfos = getBulkInfo(); let userinfos = getBulkInfo();
userinfos.preferances.notisound = sound; userinfos.preferences.notisound = sound;
localStorage.setItem("userinfos", JSON.stringify(userinfos)); localStorage.setItem("userinfos", JSON.stringify(userinfos));
} }
static getNotificationSound() { static getNotificationSound() {
let userinfos = getBulkInfo(); let userinfos = getBulkInfo();
return userinfos.preferances.notisound; return userinfos.preferences.notisound;
} }
} }
export { Voice as Voice }; export { Voice as Voice };

View file

@ -16,7 +16,7 @@ class Channel {
name; name;
id; id;
parent_id; parent_id;
parrent; parent;
children; children;
guild_id; guild_id;
messageids; messageids;
@ -80,7 +80,7 @@ class Channel {
this.name = JSON.name; this.name = JSON.name;
this.id = JSON.id; this.id = JSON.id;
this.parent_id = JSON.parent_id; this.parent_id = JSON.parent_id;
this.parrent = null; this.parent = null;
this.children = []; this.children = [];
this.guild_id = JSON.guild_id; this.guild_id = JSON.guild_id;
this.messageids = {}; this.messageids = {};
@ -131,12 +131,12 @@ class Channel {
} }
for (const thing of member.roles) { for (const thing of member.roles) {
if (this.permission_overwrites[thing.id]) { if (this.permission_overwrites[thing.id]) {
let perm = this.permission_overwrites[thing.id].getPermision(name); let perm = this.permission_overwrites[thing.id].getPermission(name);
if (perm) { if (perm) {
return perm === 1; return perm === 1;
} }
} }
if (thing.permissions.getPermision(name)) { if (thing.permissions.getPermission(name)) {
return true; return true;
} }
} }
@ -152,12 +152,12 @@ class Channel {
this.children.sort((a, b) => { return a.position - b.position; }); this.children.sort((a, b) => { return a.position - b.position; });
} }
resolveparent(guild) { resolveparent(guild) {
this.parrent = guild.channelids[this.parent_id]; this.parent = guild.channelids[this.parent_id];
this.parrent ??= null; this.parent ??= null;
if (this.parrent !== null) { if (this.parent !== null) {
this.parrent.children.push(this); this.parent.children.push(this);
} }
return this.parrent === null; return this.parent === null;
} }
calculateReorder() { calculateReorder() {
let position = -1; let position = -1;
@ -290,9 +290,9 @@ class Channel {
if (this.guild !== this.localuser.lookingguild) { if (this.guild !== this.localuser.lookingguild) {
return null; return null;
} }
else if (this.parrent) { else if (this.parent) {
for (const thing of search) { for (const thing of search) {
if (thing["all"] === this.parrent) { if (thing["all"] === this.parent) {
for (const thing2 of thing.children[1].children) { for (const thing2 of thing.children[1].children) {
if (thing2["all"] === this) { if (thing2["all"] === this) {
return thing2; return thing2;
@ -338,32 +338,32 @@ class Channel {
event.preventDefault(); event.preventDefault();
if (container) { if (container) {
that.move_id = this.id; that.move_id = this.id;
if (that.parrent) { if (that.parent) {
that.parrent.children.splice(that.parrent.children.indexOf(that), 1); that.parent.children.splice(that.parent.children.indexOf(that), 1);
} }
that.parrent = this; that.parent = this;
container.prepend(Channel.dragged[1]); container.prepend(Channel.dragged[1]);
this.children.unshift(that); this.children.unshift(that);
} }
else { else {
console.log(this, Channel.dragged); console.log(this, Channel.dragged);
that.move_id = this.parent_id; that.move_id = this.parent_id;
if (that.parrent) { if (that.parent) {
that.parrent.children.splice(that.parrent.children.indexOf(that), 1); that.parent.children.splice(that.parent.children.indexOf(that), 1);
} }
else { else {
this.guild.headchannels.splice(this.guild.headchannels.indexOf(that), 1); this.guild.headchannels.splice(this.guild.headchannels.indexOf(that), 1);
} }
that.parrent = this.parrent; that.parent = this.parent;
if (that.parrent) { if (that.parent) {
const build = []; const build = [];
for (let i = 0; i < that.parrent.children.length; i++) { for (let i = 0; i < that.parent.children.length; i++) {
build.push(that.parrent.children[i]); build.push(that.parent.children[i]);
if (that.parrent.children[i] === this) { if (that.parent.children[i] === this) {
build.push(that); build.push(that);
} }
} }
that.parrent.children = build; that.parent.children = build;
} }
else { else {
const build = []; const build = [];
@ -383,7 +383,7 @@ class Channel {
} }
createChannel(name, type) { createChannel(name, type) {
fetch(this.info.api.toString() + "/guilds/" + this.guild.id + "/channels", { fetch(this.info.api.toString() + "/guilds/" + this.guild.id + "/channels", {
method: "Post", method: "POST",
headers: this.headers, headers: this.headers,
body: JSON.stringify({ body: JSON.stringify({
name: name, name: name,
@ -506,14 +506,13 @@ class Channel {
} }
; ;
const j = await fetch(this.info.api.toString() + "/channels/" + this.id + "/messages?limit=100", { const j = await fetch(this.info.api.toString() + "/channels/" + this.id + "/messages?limit=100", {
method: 'GET',
headers: this.headers, headers: this.headers,
}); });
const responce = await j.json(); const response = await j.json();
if (responce.length !== 100) { if (response.length !== 100) {
this.allthewayup = true; this.allthewayup = true;
} }
for (const thing of responce) { for (const thing of response) {
const messager = new Message(thing, this); const messager = new Message(thing, this);
if (this.messageids[messager.id] === undefined) { if (this.messageids[messager.id] === undefined) {
this.messageids[messager.id] = messager; this.messageids[messager.id] = messager;
@ -536,25 +535,24 @@ class Channel {
} }
const out = this; const out = this;
await fetch(this.info.api.toString() + "/channels/" + this.id + "/messages?before=" + this.messages[this.messages.length - 1].id + "&limit=100", { await fetch(this.info.api.toString() + "/channels/" + this.id + "/messages?before=" + this.messages[this.messages.length - 1].id + "&limit=100", {
method: "GET",
headers: this.headers headers: this.headers
}).then((j) => { return j.json(); }).then(responce => { }).then((j) => { return j.json(); }).then(response => {
//messages.innerHTML = ''; //messages.innerHTML = '';
//responce.reverse() //response.reverse()
let next; let next;
if (responce.length === 0) { if (response.length === 0) {
out.allthewayup = true; out.allthewayup = true;
} }
for (const i in responce) { for (const i in response) {
let messager; let messager;
if (!next) { if (!next) {
messager = new Message(responce[i], this); messager = new Message(response[i], this);
} }
else { else {
messager = next; messager = next;
} }
if (responce[+i + 1] !== undefined) { if (response[+i + 1] !== undefined) {
next = new Message(responce[+i + 1], this); next = new Message(response[+i + 1], this);
} }
else { else {
next = undefined; next = undefined;
@ -589,7 +587,7 @@ class Channel {
this.type = JSON.type; this.type = JSON.type;
this.name = JSON.name; this.name = JSON.name;
this.parent_id = JSON.parent_id; this.parent_id = JSON.parent_id;
this.parrent = null; this.parent = null;
this.children = []; this.children = [];
this.guild_id = JSON.guild_id; this.guild_id = JSON.guild_id;
this.messageids = {}; this.messageids = {};
@ -771,15 +769,15 @@ class Channel {
this.permission_overwritesar.push([role.id, perm]); this.permission_overwritesar.push([role.id, perm]);
} }
async updateRolePermissions(id, perms) { async updateRolePermissions(id, perms) {
const permision = this.permission_overwrites[id]; const permission = this.permission_overwrites[id];
permision.allow = perms.allow; permission.allow = perms.allow;
permision.deny = perms.deny; permission.deny = perms.deny;
await fetch(this.info.api.toString() + "/channels/" + this.id + "/permissions/" + id, { await fetch(this.info.api.toString() + "/channels/" + this.id + "/permissions/" + id, {
method: "PUT", method: "PUT",
headers: this.headers, headers: this.headers,
body: JSON.stringify({ body: JSON.stringify({
allow: permision.allow.toString(), allow: permission.allow.toString(),
deny: permision.deny.toString(), deny: permission.deny.toString(),
id: id, id: id,
type: 0 type: 0
}) })

View file

@ -19,7 +19,7 @@ class Direct extends Guild {
this.roles = []; this.roles = [];
this.roleids = {}; this.roleids = {};
this.prevchannel = undefined; this.prevchannel = undefined;
this.properties.name = "Dirrect Messages"; this.properties.name = "Direct Messages";
for (const thing of JSON) { for (const thing of JSON) {
const temp = new Group(thing, this); const temp = new Group(thing, this);
this.channels.push(temp); this.channels.push(temp);
@ -75,7 +75,7 @@ class Group extends Channel {
this.name ??= this.localuser.user.username; this.name ??= this.localuser.user.username;
this.id = JSON.id; this.id = JSON.id;
this.parent_id = null; this.parent_id = null;
this.parrent = null; this.parent = null;
this.children = []; this.children = [];
this.guild_id = "@me"; this.guild_id = "@me";
this.messageids = {}; this.messageids = {};

View file

@ -166,10 +166,10 @@ class Embed {
const div = document.createElement("div"); const div = document.createElement("div");
div.classList.add("embed"); div.classList.add("embed");
if (this.json.provider) { if (this.json.provider) {
const providor = document.createElement("p"); const provider = document.createElement("p");
providor.classList.add("provider"); provider.classList.add("provider");
providor.textContent = this.json.provider.name; provider.textContent = this.json.provider.name;
div.append(providor); div.append(provider);
} }
const a = document.createElement("a"); const a = document.createElement("a");
a.href = this.json.url; a.href = this.json.url;

View file

@ -417,7 +417,7 @@ class Guild {
this.channelids[JSON.id] = thischannel; this.channelids[JSON.id] = thischannel;
this.channels.push(thischannel); this.channels.push(thischannel);
thischannel.resolveparent(this); thischannel.resolveparent(this);
if (!thischannel.parrent) { if (!thischannel.parent) {
this.headchannels.push(thischannel); this.headchannels.push(thischannel);
} }
this.calculateReorder(); this.calculateReorder();
@ -479,8 +479,8 @@ class Guild {
build.push(thing) build.push(thing)
}else{ }else{
console.log("fail"); console.log("fail");
if(thing.parrent){ if(thing.parent){
thing.parrent.delChannel(JSON); thing.parent.delChannel(JSON);
} }
} }
} }
@ -490,7 +490,7 @@ class Guild {
} }
createChannel(name, type) { createChannel(name, type) {
fetch(this.info.api.toString() + "/guilds/" + this.id + "/channels", { fetch(this.info.api.toString() + "/guilds/" + this.id + "/channels", {
method: "Post", method: "POST",
headers: this.headers, headers: this.headers,
body: JSON.stringify({ name: name, type: type }) body: JSON.stringify({ name: name, type: type })
}); });

View file

@ -5,6 +5,7 @@ import { User } from "./user.js";
import { markdown } from "./markdown.js"; import { markdown } from "./markdown.js";
import { Fullscreen } from "./fullscreen.js"; import { Fullscreen } from "./fullscreen.js";
import { setTheme } from "./login.js"; import { setTheme } from "./login.js";
const wsCodesRetry = new Set([4000, 4003, 4005, 4007, 4008, 4009]);
class Localuser { class Localuser {
packets; packets;
token; token;
@ -25,6 +26,8 @@ class Localuser {
ws; ws;
typing; typing;
wsinterval; wsinterval;
connectionSucceed = 0;
errorBackoff = 0;
constructor(userinfo) { constructor(userinfo) {
this.packets = 1; this.packets = 1;
this.token = userinfo.token; this.token = userinfo.token;
@ -162,7 +165,7 @@ class Localuser {
break; break;
case "TYPING_START": case "TYPING_START":
if (this.initialized) { if (this.initialized) {
this.typeingStart(temp); this.typingStart(temp);
} }
break; break;
case "USER_UPDATE": case "USER_UPDATE":
@ -202,13 +205,15 @@ class Localuser {
const guildy = new Guild(temp.d, this, this.user); const guildy = new Guild(temp.d, this, this.user);
this.guilds.push(guildy); this.guilds.push(guildy);
this.guildids[guildy.id] = guildy; this.guildids[guildy.id] = guildy;
document.getElementById("servers").insertBefore(guildy.generateGuildIcon(), document.getElementById("bottomseperator")); document.getElementById("servers").insertBefore(guildy.generateGuildIcon(), document.getElementById("bottomseparator"));
} }
} }
} }
else if (temp.op === 10) { else if (temp.op === 10) {
console.log("heartbeat down"); console.log("heartbeat down");
this.wsinterval = setInterval(_ => { this.wsinterval = setInterval(_ => {
if (this.connectionSucceed === 0)
this.connectionSucceed = Date.now();
this.ws.send(JSON.stringify({ op: 1, d: this.packets })); this.ws.send(JSON.stringify({ op: 1, d: this.packets }));
}, temp.d.heartbeat_interval); }, temp.d.heartbeat_interval);
this.packets = 1; this.packets = 1;
@ -221,22 +226,33 @@ class Localuser {
console.error(error); console.error(error);
} }
}); });
this.ws.addEventListener('close', (event) => { this.ws.addEventListener("close", event => {
clearInterval(this.wsinterval); console.log("WebSocket closed with code " + event.code);
console.log('WebSocket closed'); if (this.wsinterval)
console.warn(event); clearInterval(this.wsinterval);
if (event.code !== 4000) { this.unload();
this.unload(); document.getElementById("loading").classList.remove("doneloading");
document.getElementById("loading").classList.remove("doneloading"); document.getElementById("loading").classList.add("loading");
document.getElementById("loading").classList.add("loading"); if (((event.code > 1000 && event.code < 1016) || wsCodesRetry.has(event.code))) {
this.initwebsocket().then(_ => { if (this.connectionSucceed !== 0 && Date.now() > this.connectionSucceed + 20000)
this.loaduser(); this.errorBackoff = 0;
this.init(); else
document.getElementById("loading").classList.add("doneloading"); this.errorBackoff++;
document.getElementById("loading").classList.remove("loading"); this.connectionSucceed = 0;
console.log("done loading"); document.getElementById("load-desc").innerHTML = "Unable to connect to the Spacebar server, retrying in <b>" + Math.round(0.2 + (this.errorBackoff * 2.8)) + "</b> seconds...";
}); setTimeout(() => {
document.getElementById("load-desc").textContent = "Retrying...";
this.initwebsocket().then(() => {
this.loaduser();
this.init();
document.getElementById("loading").classList.add("doneloading");
document.getElementById("loading").classList.remove("loading");
console.log("done loading");
});
}, 200 + (this.errorBackoff * 2800));
} }
else
document.getElementById("load-desc").textContent = "Unable to connect to the Spacebar server. Please try logging out and back in.";
}); });
await promise; await promise;
return; return;
@ -340,7 +356,7 @@ class Localuser {
const br = document.createElement("hr"); const br = document.createElement("hr");
br.classList.add("lightbr"); br.classList.add("lightbr");
serverlist.appendChild(br); serverlist.appendChild(br);
br.id = "bottomseperator"; br.id = "bottomseparator";
const div = document.createElement("div"); const div = document.createElement("div");
div.textContent = "+"; div.textContent = "+";
div.classList.add("addserver", "servericon"); div.classList.add("addserver", "servericon");
@ -410,7 +426,7 @@ class Localuser {
thing.unreads(this.guildhtml[thing.id]); thing.unreads(this.guildhtml[thing.id]);
} }
} }
typeingStart(typing) { typingStart(typing) {
if (this.channelfocus.id === typing.d.channel_id) { if (this.channelfocus.id === typing.d.channel_id) {
const memb = typing.d.member; const memb = typing.d.member;
let name; let name;
@ -506,15 +522,15 @@ class Localuser {
} }
} }
genusersettings() { genusersettings() {
const hypothetcialprofie = document.createElement("div"); const hypotheticalProfile = document.createElement("div");
let file = null; let file = null;
let newprouns = null; let newprouns = null;
let newbio = null; let newbio = null;
let hypouser = new User(this.user, this, true); let hypouser = new User(this.user, this, true);
function regen() { function regen() {
hypothetcialprofie.textContent = ""; hypotheticalProfile.textContent = "";
const hypoprofile = hypouser.buildprofile(-1, -1); const hypoprofile = hypouser.buildprofile(-1, -1);
hypothetcialprofie.appendChild(hypoprofile); hypotheticalProfile.appendChild(hypoprofile);
} }
regen(); regen();
this.usersettings = new Fullscreen(["hdiv", this.usersettings = new Fullscreen(["hdiv",
@ -560,7 +576,7 @@ class Localuser {
}, Voice.sounds.indexOf(Voice.getNotificationSound())] }, Voice.sounds.indexOf(Voice.getNotificationSound())]
], ],
["vdiv", ["vdiv",
["html", hypothetcialprofie] ["html", hypotheticalProfile]
] ]
], _ => { }, function () { ], _ => { }, function () {
console.log(this); console.log(this);

View file

@ -25,9 +25,9 @@ function setDefaults() {
localStorage.setItem("userinfos", JSON.stringify({ localStorage.setItem("userinfos", JSON.stringify({
currentuser: null, currentuser: null,
users: {}, users: {},
preferances: { preferences: {
theme: "Dark", theme: "Dark",
notifcations: false, notifications: false,
notisound: "three", notisound: "three",
}, },
})); }));
@ -36,15 +36,15 @@ function setDefaults() {
if (userinfos.users === undefined) { if (userinfos.users === undefined) {
userinfos.users = {}; userinfos.users = {};
} }
if (userinfos.preferances === undefined) { if (userinfos.preferences === undefined) {
userinfos.preferances = { userinfos.preferences = {
theme: "Dark", theme: "Dark",
notifcations: false, notifications: false,
notisound: "three", notisound: "three",
}; };
} }
if (userinfos.preferances && (userinfos.preferances.notisound === undefined)) { if (userinfos.preferences && (userinfos.preferences.notisound === undefined)) {
userinfos.preferances.notisound = "three"; userinfos.preferences.notisound = "three";
} }
localStorage.setItem("userinfos", JSON.stringify(userinfos)); localStorage.setItem("userinfos", JSON.stringify(userinfos));
} }
@ -160,7 +160,7 @@ async function login(username, password) {
try { try {
const info = JSON.parse(localStorage.getItem("instanceinfo")); const info = JSON.parse(localStorage.getItem("instanceinfo"));
const url = new URL(info.login); const url = new URL(info.login);
return await fetch(url.origin + '/api/auth/login', options).then(responce => responce.json()) return await fetch(url.origin + '/api/auth/login', options).then(response => response.json())
.then((response) => { .then((response) => {
console.log(response, response.message); console.log(response, response.message);
if ("Invalid Form Body" === response.message) { if ("Invalid Form Body" === response.message) {

View file

@ -298,15 +298,15 @@ function markdown(text, { keep = false, stdsize = false } = {}) {
if (find === count) { if (find === count) {
appendcurrent(); appendcurrent();
i = j; i = j;
const underscores = "~~"; const tildes = "~~";
if (count === 2) { if (count === 2) {
const s = document.createElement("s"); const s = document.createElement("s");
if (keep) { if (keep) {
s.append(underscores); s.append(tildes);
} }
s.appendChild(markdown(build, { keep: keep, stdsize: stdsize })); s.appendChild(markdown(build, { keep: keep, stdsize: stdsize }));
if (keep) { if (keep) {
s.append(underscores); s.append(tildes);
} }
span.appendChild(s); span.appendChild(s);
} }
@ -333,17 +333,17 @@ function markdown(text, { keep = false, stdsize = false } = {}) {
if (find === count) { if (find === count) {
appendcurrent(); appendcurrent();
i = j; i = j;
const underscores = "||"; const pipes = "||";
if (count === 2) { if (count === 2) {
const j = document.createElement("j"); const j = document.createElement("j");
if (keep) { if (keep) {
j.append(underscores); j.append(pipes);
} }
j.appendChild(markdown(build, { keep: keep, stdsize: stdsize })); j.appendChild(markdown(build, { keep: keep, stdsize: stdsize }));
j.classList.add("spoiler"); j.classList.add("spoiler");
j.onclick = markdown.unspoil; j.onclick = markdown.unspoil;
if (keep) { if (keep) {
j.append(underscores); j.append(pipes);
} }
span.appendChild(j); span.appendChild(j);
} }

View file

@ -127,7 +127,7 @@ class Member {
} }
isAdmin() { isAdmin() {
for (const role of this.roles) { for (const role of this.roles) {
if (role.permissions.getPermision("ADMINISTRATOR")) { if (role.permissions.getPermission("ADMINISTRATOR")) {
return true; return true;
} }
} }

View file

@ -258,11 +258,11 @@ class Message {
build.appendChild(text); build.appendChild(text);
if (this.attachments.length) { if (this.attachments.length) {
console.log(this.attachments); console.log(this.attachments);
const attatch = document.createElement("tr"); const attach = document.createElement("tr");
for (const thing of this.attachments) { for (const thing of this.attachments) {
attatch.appendChild(thing.getHTML()); attach.appendChild(thing.getHTML());
} }
messagedwrap.appendChild(attatch); messagedwrap.appendChild(attach);
} }
if (this.embeds.length) { if (this.embeds.length) {
const embeds = document.createElement("tr"); const embeds = document.createElement("tr");

View file

@ -8,10 +8,10 @@ class Permissions {
this.allow = BigInt(allow); this.allow = BigInt(allow);
this.deny = BigInt(deny); this.deny = BigInt(deny);
} }
getPermisionbit(b, big) { getPermissionbit(b, big) {
return Boolean((big >> BigInt(b)) & 1n); return Boolean((big >> BigInt(b)) & 1n);
} }
setPermisionbit(b, state, big) { setPermissionbit(b, state, big) {
const bit = 1n << BigInt(b); const bit = 1n << BigInt(b);
return (big & ~bit) | (BigInt(state) << BigInt(b)); //thanks to geotale for this code :3 return (big & ~bit) | (BigInt(state) << BigInt(b)); //thanks to geotale for this code :3
} }
@ -233,30 +233,30 @@ class Permissions {
i++; i++;
} }
} }
getPermision(name) { getPermission(name) {
if (this.getPermisionbit(Permissions.map[name], this.allow)) { if (this.getPermissionbit(Permissions.map[name], this.allow)) {
return 1; return 1;
} }
else if (this.getPermisionbit(Permissions.map[name], this.deny)) { else if (this.getPermissionbit(Permissions.map[name], this.deny)) {
return -1; return -1;
} }
else { else {
return 0; return 0;
} }
} }
setPermision(name, setto) { setPermission(name, setto) {
const bit = Permissions.map[name]; const bit = Permissions.map[name];
if (setto === 0) { if (setto === 0) {
this.deny = this.setPermisionbit(bit, false, this.deny); this.deny = this.setPermissionbit(bit, false, this.deny);
this.allow = this.setPermisionbit(bit, false, this.allow); this.allow = this.setPermissionbit(bit, false, this.allow);
} }
else if (setto === 1) { else if (setto === 1) {
this.deny = this.setPermisionbit(bit, false, this.deny); this.deny = this.setPermissionbit(bit, false, this.deny);
this.allow = this.setPermisionbit(bit, true, this.allow); this.allow = this.setPermissionbit(bit, true, this.allow);
} }
else if (setto === -1) { else if (setto === -1) {
this.deny = this.setPermisionbit(bit, true, this.deny); this.deny = this.setPermissionbit(bit, true, this.deny);
this.allow = this.setPermisionbit(bit, false, this.allow); this.allow = this.setPermissionbit(bit, false, this.allow);
} }
else { else {
console.error("invalid number entered:" + setto); console.error("invalid number entered:" + setto);

View file

@ -62,7 +62,7 @@ class Buttons {
} }
save() { } save() { }
} }
class PermisionToggle { class PermissionToggle {
rolejson; rolejson;
permissions; permissions;
owner; owner;
@ -87,7 +87,7 @@ class PermisionToggle {
generateCheckbox() { generateCheckbox() {
const div = document.createElement("div"); const div = document.createElement("div");
div.classList.add("tritoggle"); div.classList.add("tritoggle");
const state = this.permissions.getPermision(this.rolejson.name); const state = this.permissions.getPermission(this.rolejson.name);
const on = document.createElement("input"); const on = document.createElement("input");
on.type = "radio"; on.type = "radio";
on.name = this.rolejson.name; on.name = this.rolejson.name;
@ -97,7 +97,7 @@ class PermisionToggle {
} }
; ;
on.onclick = _ => { on.onclick = _ => {
this.permissions.setPermision(this.rolejson.name, 1); this.permissions.setPermission(this.rolejson.name, 1);
this.owner.changed(); this.owner.changed();
}; };
const no = document.createElement("input"); const no = document.createElement("input");
@ -109,7 +109,7 @@ class PermisionToggle {
} }
; ;
no.onclick = _ => { no.onclick = _ => {
this.permissions.setPermision(this.rolejson.name, 0); this.permissions.setPermission(this.rolejson.name, 0);
this.owner.changed(); this.owner.changed();
}; };
if (this.permissions.hasDeny) { if (this.permissions.hasDeny) {
@ -122,7 +122,7 @@ class PermisionToggle {
} }
; ;
off.onclick = _ => { off.onclick = _ => {
this.permissions.setPermision(this.rolejson.name, -1); this.permissions.setPermission(this.rolejson.name, -1);
this.owner.changed(); this.owner.changed();
}; };
} }
@ -151,7 +151,7 @@ class RoleList extends Buttons {
this.permission = new Permissions("0"); this.permission = new Permissions("0");
} }
for (const thing of Permissions.info) { for (const thing of Permissions.info) {
options.addPermisionToggle(thing, this.permission); // options.addPermissionToggle(thing, this.permission); //
} }
for (const i of permissions) { for (const i of permissions) {
this.buttons.push([guild.getRole(i[0]).name, i[0]]); // this.buttons.push([guild.getRole(i[0]).name, i[0]]); //
@ -181,8 +181,8 @@ class Options {
this.options = []; this.options = [];
this.owner = owner; this.owner = owner;
} }
addPermisionToggle(roleJSON, permissions) { addPermissionToggle(roleJSON, permissions) {
this.options.push(new PermisionToggle(roleJSON, permissions, this)); this.options.push(new PermissionToggle(roleJSON, permissions, this));
} }
generateHTML() { generateHTML() {
const div = document.createElement("div"); const div = document.createElement("div");