lint and merge

This commit is contained in:
MathMan05 2024-09-19 12:49:50 -05:00
parent 49f2234e81
commit e12b99c38b
34 changed files with 10323 additions and 10330 deletions

View file

@ -267,8 +267,8 @@ module.exports = [
parser: tsParser, parser: tsParser,
globals: global, globals: global,
}, },
files: ["webpage/*.ts"], files: ["src/*.ts","src/**/*.ts",],
ignores: ["!*.js", "!*.ts"], ignores: ["dist/", "node_modules/"],
plugins: { plugins: {
unicorn, unicorn,
sonarjs, sonarjs,

View file

@ -37,6 +37,6 @@
"gulp-copy": "^5.0.0", "gulp-copy": "^5.0.0",
"gulp-typescript": "^6.0.0-alpha.1", "gulp-typescript": "^6.0.0-alpha.1",
"typescript": "^5.6.2", "typescript": "^5.6.2",
"typescript-eslint": "^7.18.0" "typescript-eslint": "^8.6.0"
} }
} }

View file

@ -4,10 +4,10 @@ import compression from "compression";
import express, { Request, Response }from"express"; import express, { Request, Response }from"express";
import fs from"node:fs"; import fs from"node:fs";
import fetch from"node-fetch"; import fetch from"node-fetch";
import path from "path"; import path from"node:path";
import{ observe, uptime }from"./stats.js"; import{ observe, uptime }from"./stats.js";
import{ getApiUrls, inviteResponse }from"./utils.js"; import{ getApiUrls, inviteResponse }from"./utils.js";
import { fileURLToPath } from "url"; import{ fileURLToPath }from"node:url";
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); const __dirname = path.dirname(__filename);

View file

@ -1,8 +1,8 @@
import fs from"node:fs"; import fs from"node:fs";
import path from "path"; import path from"node:path";
import fetch from"node-fetch"; import fetch from"node-fetch";
import{ getApiUrls }from"./utils.js"; import{ getApiUrls }from"./utils.js";
import { fileURLToPath } from "url"; import{ fileURLToPath }from"node:url";
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); const __dirname = path.dirname(__filename);
@ -28,7 +28,7 @@ interface Instance {
}; };
} }
let uptimeObject: UptimeObject = loadUptimeObject(); const uptimeObject: UptimeObject = loadUptimeObject();
export{ uptimeObject as uptime }; export{ uptimeObject as uptime };
function loadUptimeObject(): UptimeObject{ function loadUptimeObject(): UptimeObject{
@ -48,7 +48,7 @@ function saveUptimeObject(): void {
fs.writeFile( fs.writeFile(
path.join(__dirname, "..", "uptime.json"), path.join(__dirname, "..", "uptime.json"),
JSON.stringify(uptimeObject), JSON.stringify(uptimeObject),
(error) => { error=>{
if(error){ if(error){
console.error("Error saving uptime.json:", error); console.error("Error saving uptime.json:", error);
} }
@ -67,8 +67,7 @@ removeUndefinedKey();
export async function observe(instances: Instance[]): Promise<void>{ export async function observe(instances: Instance[]): Promise<void>{
const activeInstances = new Set<string>(); const activeInstances = new Set<string>();
const instancePromises = instances.map((instance) => const instancePromises = instances.map(instance=>resolveInstance(instance, activeInstances)
resolveInstance(instance, activeInstances)
); );
await Promise.allSettled(instancePromises); await Promise.allSettled(instancePromises);
updateInactiveInstances(activeInstances); updateInactiveInstances(activeInstances);

View file

@ -26,7 +26,7 @@ export async function getApiUrls(url: string): Promise<ApiUrls | null> {
} }
try{ try{
const info: ApiUrls = await fetch(`${url}.well-known/spacebar`).then( const info: ApiUrls = await fetch(`${url}.well-known/spacebar`).then(
(res) => res.json() as Promise<ApiUrls> res=>res.json() as Promise<ApiUrls>
); );
const api = info.api; const api = info.api;
const apiUrl = new URL(api); const apiUrl = new URL(api);
@ -34,7 +34,7 @@ export async function getApiUrls(url: string): Promise<ApiUrls | null> {
`${api}${ `${api}${
apiUrl.pathname.includes("api") ? "" : "api" apiUrl.pathname.includes("api") ? "" : "api"
}/policies/instance/domains` }/policies/instance/domains`
).then((res) => res.json()); ).then(res=>res.json());
return{ return{
api: policies.apiEndpoint, api: policies.apiEndpoint,
gateway: policies.gateway, gateway: policies.gateway,
@ -76,7 +76,7 @@ export async function getApiUrls(url: string): Promise<ApiUrls | null> {
} }
const invite = await fetch(`${urls.api}/invites/${code}`).then( const invite = await fetch(`${urls.api}/invites/${code}`).then(
(res) => res.json() as Promise<Invite> res=>res.json() as Promise<Invite>
); );
const title = invite.guild.name; const title = invite.guild.name;
const description = invite.inviter const description = invite.inviter

View file

@ -97,13 +97,13 @@ switch (noise) {
case"three": { case"three": {
const voicy = new Voice("sin", 800); const voicy = new Voice("sin", 800);
voicy.play(); voicy.play();
setTimeout((_) => { setTimeout(_=>{
voicy.freq = 1000; voicy.freq = 1000;
}, 50); }, 50);
setTimeout((_) => { setTimeout(_=>{
voicy.freq = 1300; voicy.freq = 1300;
}, 100); }, 100);
setTimeout((_) => { setTimeout(_=>{
voicy.stop(); voicy.stop();
}, 150); }, 150);
break; break;
@ -113,7 +113,7 @@ const voicy = new Voice((t: number, freq: number) => {
return Math.sin((t + 2) ** Math.cos(t * 4) * Math.PI * 2 * freq); return Math.sin((t + 2) ** Math.cos(t * 4) * Math.PI * 2 * freq);
}, 700); }, 700);
voicy.play(); voicy.play();
setTimeout((_) => { setTimeout(_=>{
voicy.stop(); voicy.stop();
}, 150); }, 150);
break; break;
@ -121,13 +121,13 @@ break;
case"square": { case"square": {
const voicy = new Voice("square", 600, 0.4); const voicy = new Voice("square", 600, 0.4);
voicy.play(); voicy.play();
setTimeout((_) => { setTimeout(_=>{
voicy.freq = 800; voicy.freq = 800;
}, 50); }, 50);
setTimeout((_) => { setTimeout(_=>{
voicy.freq = 1000; voicy.freq = 1000;
}, 100); }, 100);
setTimeout((_) => { setTimeout(_=>{
voicy.stop(); voicy.stop();
}, 150); }, 150);
break; break;
@ -135,13 +135,13 @@ break;
case"beep": { case"beep": {
const voicy = new Voice("sin", 800); const voicy = new Voice("sin", 800);
voicy.play(); voicy.play();
setTimeout((_) => { setTimeout(_=>{
voicy.stop(); voicy.stop();
}, 50); }, 50);
setTimeout((_) => { setTimeout(_=>{
voicy.play(); voicy.play();
}, 100); }, 100);
setTimeout((_) => { setTimeout(_=>{
voicy.stop(); voicy.stop();
}, 150); }, 150);
break; break;

View file

@ -131,7 +131,7 @@ permission_overwrites!: Map<string, Permissions>;
const copy = document.createElement("span"); const copy = document.createElement("span");
copy.classList.add("copybutton", "svgtheme", "svg-copy"); copy.classList.add("copybutton", "svgtheme", "svg-copy");
copycontainer.append(copy); copycontainer.append(copy);
copycontainer.onclick = (_) => { copycontainer.onclick = _=>{
if(text.textContent){ if(text.textContent){
navigator.clipboard.writeText(text.textContent); navigator.clipboard.writeText(text.textContent);
} }
@ -150,8 +150,8 @@ permission_overwrites!: Map<string, Permissions>;
temporary: uses !== 0, temporary: uses !== 0,
}), }),
}) })
.then((_) => _.json()) .then(_=>_.json())
.then((json) => { .then(json=>{
const params = new URLSearchParams(""); const params = new URLSearchParams("");
params.set("instance", this.info.wellknown); params.set("instance", this.info.wellknown);
const encoded = params.toString(); const encoded = params.toString();
@ -177,7 +177,6 @@ permission_overwrites!: Map<string, Permissions>;
"Never", "Never",
], ],
function(e: Event){ function(e: Event){
expires = [1800, 3600, 21600, 43200, 86400, 604800, 2592000, 0,][(e.srcElement as HTMLSelectElement).selectedIndex]; expires = [1800, 3600, 21600, 43200, 86400, 604800, 2592000, 0,][(e.srcElement as HTMLSelectElement).selectedIndex];
update(); update();
@ -224,8 +223,8 @@ permission_overwrites!: Map<string, Permissions>;
sortPerms(){ sortPerms(){
this.permission_overwritesar.sort((a, b)=>{ this.permission_overwritesar.sort((a, b)=>{
return( return(
this.guild.roles.findIndex((_) => _ === a[0]) - this.guild.roles.indexOf(a[0]) -
this.guild.roles.findIndex((_) => _ === b[0]) this.guild.roles.indexOf(b[0])
); );
}); });
} }
@ -246,7 +245,7 @@ permission_overwrites!: Map<string, Permissions>;
await this.grabAfter(id); await this.grabAfter(id);
return this.idToNext.get(id); return this.idToNext.get(id);
}else{ }else{
return;
} }
} }
}, },
@ -366,7 +365,7 @@ permission_overwrites!: Map<string, Permissions>;
return false; return false;
} }
return( return(
!!this.lastmessageid && Boolean(this.lastmessageid) &&
(!this.lastreadmessageid || (!this.lastreadmessageid ||
SnowFlake.stringToUnixTime(this.lastmessageid) > SnowFlake.stringToUnixTime(this.lastmessageid) >
SnowFlake.stringToUnixTime(this.lastreadmessageid)) && SnowFlake.stringToUnixTime(this.lastreadmessageid)) &&
@ -378,7 +377,7 @@ permission_overwrites!: Map<string, Permissions>;
return true; return true;
} }
for(const thing of member.roles){ for(const thing of member.roles){
let premission = this.permission_overwrites.get(thing.id); const premission = this.permission_overwrites.get(thing.id);
if(premission){ if(premission){
const perm = premission.getPermission(name); const perm = premission.getPermission(name);
if(perm){ if(perm){
@ -396,7 +395,7 @@ permission_overwrites!: Map<string, Permissions>;
this.permission_overwritesar.length === 0 && this.permission_overwritesar.length === 0 &&
this.hasPermission("MANAGE_CHANNELS") this.hasPermission("MANAGE_CHANNELS")
){ ){
const role = this.guild.roles.find((_) => _.name === "@everyone"); const role = this.guild.roles.find(_=>_.name === "@everyone");
if(role){ if(role){
this.addRoleToPerms(role); this.addRoleToPerms(role);
} }
@ -467,9 +466,9 @@ permission_overwrites!: Map<string, Permissions>;
} }
} }
// @ts-ignore I dont wanna deal with this // @ts-ignore I dont wanna deal with this
div["all"] = this; div.all = this;
div.draggable = admin; div.draggable = admin;
div.addEventListener("dragstart", (e) => { div.addEventListener("dragstart", e=>{
Channel.dragged = [this, div]; Channel.dragged = [this, div];
e.stopImmediatePropagation(); e.stopImmediatePropagation();
}); });
@ -495,7 +494,7 @@ permission_overwrites!: Map<string, Permissions>;
addchannel.textContent = "+"; addchannel.textContent = "+";
addchannel.classList.add("addchannel"); addchannel.classList.add("addchannel");
caps.appendChild(addchannel); caps.appendChild(addchannel);
addchannel.onclick = (_) => { addchannel.onclick = _=>{
this.guild.createchannels(this.createChannel.bind(this)); this.guild.createchannels(this.createChannel.bind(this));
}; };
this.coatDropDiv(decdiv, childrendiv); this.coatDropDiv(decdiv, childrendiv);
@ -505,9 +504,9 @@ permission_overwrites!: Map<string, Permissions>;
decdiv.classList.add("channeleffects"); decdiv.classList.add("channeleffects");
decdiv.classList.add("channel"); decdiv.classList.add("channel");
Channel.contextmenu.bindContextmenu(decdiv, this, undefined); Channel.contextmenu.bindContextmenu(decdiv, this);
// @ts-ignore I dont wanna deal with this // @ts-ignore I dont wanna deal with this
decdiv["all"] = this; decdiv.all = this;
for(const channel of this.children){ for(const channel of this.children){
childrendiv.appendChild(channel.createguildHTML(admin)); childrendiv.appendChild(channel.createguildHTML(admin));
@ -541,12 +540,12 @@ permission_overwrites!: Map<string, Permissions>;
if(this.hasunreads){ if(this.hasunreads){
div.classList.add("cunread"); div.classList.add("cunread");
} }
Channel.contextmenu.bindContextmenu(div, this, undefined); Channel.contextmenu.bindContextmenu(div, this);
if(admin){ if(admin){
this.coatDropDiv(div); this.coatDropDiv(div);
} }
// @ts-ignore I dont wanna deal with this // @ts-ignore I dont wanna deal with this
div["all"] = this; div.all = this;
const myhtml = document.createElement("span"); const myhtml = document.createElement("span");
myhtml.textContent = this.name; myhtml.textContent = this.name;
if(this.type === 0){ if(this.type === 0){
@ -567,7 +566,7 @@ permission_overwrites!: Map<string, Permissions>;
console.log(this.type); console.log(this.type);
} }
div.appendChild(myhtml); div.appendChild(myhtml);
div.onclick = (_) => { div.onclick = _=>{
this.getHTML(); this.getHTML();
}; };
} }
@ -577,7 +576,7 @@ permission_overwrites!: Map<string, Permissions>;
if(this.html){ if(this.html){
return this.html.deref(); return this.html.deref();
}else{ }else{
return undefined;
} }
} }
readbottom(){ readbottom(){
@ -604,16 +603,16 @@ permission_overwrites!: Map<string, Permissions>;
} }
} }
coatDropDiv(div: HTMLDivElement, container: HTMLElement | boolean = false){ coatDropDiv(div: HTMLDivElement, container: HTMLElement | boolean = false){
div.addEventListener("dragenter", (event) => { div.addEventListener("dragenter", event=>{
console.log("enter"); console.log("enter");
event.preventDefault(); event.preventDefault();
}); });
div.addEventListener("dragover", (event) => { div.addEventListener("dragover", event=>{
event.preventDefault(); event.preventDefault();
}); });
div.addEventListener("drop", (event) => { div.addEventListener("drop", event=>{
const that = Channel.dragged[0]; const that = Channel.dragged[0];
if(!that)return; if(!that)return;
event.preventDefault(); event.preventDefault();
@ -764,7 +763,7 @@ permission_overwrites!: Map<string, Permissions>;
const span = document.createElement("span"); const span = document.createElement("span");
span.textContent = "Replying to " + this.replyingto.author.username; span.textContent = "Replying to " + this.replyingto.author.username;
const X = document.createElement("button"); const X = document.createElement("button");
X.onclick = (_) => { X.onclick = _=>{
if(this.replyingto?.div){ if(this.replyingto?.div){
this.replyingto.div.classList.remove("replying"); this.replyingto.div.classList.remove("replying");
} }
@ -977,10 +976,10 @@ permission_overwrites!: Map<string, Permissions>;
headers: this.headers, headers: this.headers,
} }
) )
.then((j) => { .then(j=>{
return j.json(); return j.json();
}) })
.then((response) => { .then(response=>{
let previd: string = id; let previd: string = id;
for(const i in response){ for(const i in response){
let messager: Message; let messager: Message;
@ -1018,7 +1017,7 @@ permission_overwrites!: Map<string, Permissions>;
headers: this.headers, headers: this.headers,
} }
) )
.then((j) => { .then(j=>{
return j.json(); return j.json();
}) })
.then((response: messagejson[])=>{ .then((response: messagejson[])=>{
@ -1115,7 +1114,7 @@ permission_overwrites!: Map<string, Permissions>;
} }
messages.append(await this.infinite.getDiv(id)); messages.append(await this.infinite.getDiv(id));
this.infinite.updatestuff(); this.infinite.updatestuff();
this.infinite.watchForChange().then(async (_) => { this.infinite.watchForChange().then(async _=>{
//await new Promise(resolve => setTimeout(resolve, 0)); //await new Promise(resolve => setTimeout(resolve, 0));
this.infinite.focus(id, false); //if someone could figure out how to make this work correctly without this, that's be great :P this.infinite.focus(id, false); //if someone could figure out how to make this work correctly without this, that's be great :P
loading.classList.remove("loading"); loading.classList.remove("loading");
@ -1353,7 +1352,7 @@ permission_overwrites!: Map<string, Permissions>;
icon: message.author.getpfpsrc(), icon: message.author.getpfpsrc(),
image: imgurl, image: imgurl,
}); });
notification.addEventListener("click", (_) => { notification.addEventListener("click", _=>{
window.focus(); window.focus();
this.getHTML(); this.getHTML();
}); });

View file

@ -12,7 +12,7 @@ class Contextmenu<x, y> {
div!: HTMLDivElement; div!: HTMLDivElement;
static setup(){ static setup(){
Contextmenu.currentmenu = ""; Contextmenu.currentmenu = "";
document.addEventListener("click", (event) => { document.addEventListener("click", event=>{
if(Contextmenu.currentmenu === ""){ if(Contextmenu.currentmenu === ""){
return; return;
} }
@ -30,8 +30,8 @@ class Contextmenu<x, y> {
text: string, text: string,
onclick: (this: x, arg: y, e: MouseEvent) => void, onclick: (this: x, arg: y, e: MouseEvent) => void,
img: null | string = null, img: null | string = null,
shown: (this: x, arg: y) => boolean = (_) => true, shown: (this: x, arg: y) => boolean = _=>true,
enabled: (this: x, arg: y) => boolean = (_) => true enabled: (this: x, arg: y) => boolean = _=>true
){ ){
this.buttons.push([text, onclick, img, shown, enabled, "button"]); this.buttons.push([text, onclick, img, shown, enabled, "button"]);
return{}; return{};
@ -40,8 +40,8 @@ class Contextmenu<x, y> {
text: string, text: string,
onclick: (this: x, arg: y, e: MouseEvent) => void, onclick: (this: x, arg: y, e: MouseEvent) => void,
img = null, img = null,
shown: (this: x, arg: y) => boolean = (_) => true, shown: (this: x, arg: y) => boolean = _=>true,
enabled: (this: x, arg: y) => boolean = (_) => true enabled: (this: x, arg: y) => boolean = _=>true
){ ){
this.buttons.push([text, onclick, img, shown, enabled, "submenu"]); this.buttons.push([text, onclick, img, shown, enabled, "submenu"]);
return{}; return{};

View file

@ -235,7 +235,7 @@ shown = html;
}else{ }else{
html.style.display = "none"; html.style.display = "none";
} }
button.addEventListener("click", (_) => { button.addEventListener("click", _=>{
if(shown){ if(shown){
shown.style.display = "none"; shown.style.display = "none";
} }
@ -261,7 +261,7 @@ this.background = document.createElement("div");
this.background.classList.add("background"); this.background.classList.add("background");
document.body.appendChild(this.background); document.body.appendChild(this.background);
document.body.appendChild(this.html); document.body.appendChild(this.html);
this.background.onclick = (_) => { this.background.onclick = _=>{
this.hide(); this.hide();
}; };
} }

View file

@ -150,15 +150,15 @@ static contextmenu = new Contextmenu<Group, undefined>("channel menu");
} }
createguildHTML(){ createguildHTML(){
const div = document.createElement("div"); const div = document.createElement("div");
Group.contextmenu.bindContextmenu(div, this, undefined); Group.contextmenu.bindContextmenu(div, this);
this.html = new WeakRef(div); this.html = new WeakRef(div);
div.classList.add("channeleffects"); div.classList.add("channeleffects");
const myhtml = document.createElement("span"); const myhtml = document.createElement("span");
myhtml.textContent = this.name; myhtml.textContent = this.name;
div.appendChild(this.user.buildpfp()); div.appendChild(this.user.buildpfp());
div.appendChild(myhtml); div.appendChild(myhtml);
(div as any)["myinfo"] = this; (div as any).myinfo = this;
div.onclick = (_) => { div.onclick = _=>{
this.getHTML(); this.getHTML();
}; };
@ -286,7 +286,7 @@ static contextmenu = new Contextmenu<Group, undefined>("channel menu");
buildpfp.classList.add("mentioned"); buildpfp.classList.add("mentioned");
div.append(buildpfp); div.append(buildpfp);
sentdms.append(div); sentdms.append(div);
div.onclick = (_) => { div.onclick = _=>{
this.guild.loadGuild(); this.guild.loadGuild();
this.getHTML(); this.getHTML();
}; };

View file

@ -312,22 +312,20 @@ h2.textContent = `You've been invited by ${json.inviter.username}`;
div.append(h2); div.append(h2);
const button = document.createElement("button"); const button = document.createElement("button");
button.textContent = "Accept"; button.textContent = "Accept";
if (this.localuser.info.api.startsWith(info.api)) { if(this.localuser.info.api.startsWith(info.api) && this.localuser.guildids.has(guild.id)){
if (this.localuser.guildids.has(guild.id)) {
button.textContent = "Already joined"; button.textContent = "Already joined";
button.disabled = true; button.disabled = true;
} }
}
button.classList.add("acceptinvbutton"); button.classList.add("acceptinvbutton");
div.append(button); div.append(button);
button.onclick = (_) => { button.onclick = _=>{
if(this.localuser.info.api.startsWith(info.api)){ if(this.localuser.info.api.startsWith(info.api)){
fetch(this.localuser.info.api + "/invites/" + json.code, { fetch(this.localuser.info.api + "/invites/" + json.code, {
method: "POST", method: "POST",
headers: this.localuser.headers, headers: this.localuser.headers,
}) })
.then((r) => r.json()) .then(r=>r.json())
.then((_) => { .then(_=>{
if(_.message){ if(_.message){
alert(_.message); alert(_.message);
} }

View file

@ -18,7 +18,6 @@ class Emoji {
if(this.owner instanceof Guild){ if(this.owner instanceof Guild){
return this.owner; return this.owner;
} }
return;
} }
get localuser(){ get localuser(){
if(this.owner instanceof Guild){ if(this.owner instanceof Guild){
@ -118,10 +117,10 @@ class Emoji {
} }
static grabEmoji(){ static grabEmoji(){
fetch("/emoji.bin") fetch("/emoji.bin")
.then((e) => { .then(e=>{
return e.arrayBuffer(); return e.arrayBuffer();
}) })
.then((e) => { .then(e=>{
Emoji.decodeEmojiList(e); Emoji.decodeEmojiList(e);
}); });
} }
@ -131,7 +130,7 @@ class Emoji {
localuser: Localuser localuser: Localuser
): Promise<Emoji | string>{ ): Promise<Emoji | string>{
let res: (r: Emoji | string) => void; let res: (r: Emoji | string) => void;
const promise: Promise<Emoji | string> = new Promise((r) => { const promise: Promise<Emoji | string> = new Promise(r=>{
res = r; res = r;
}); });
const menu = document.createElement("div"); const menu = document.createElement("div");
@ -150,8 +149,8 @@ class Emoji {
let isFirst = true; let isFirst = true;
localuser.guilds localuser.guilds
.filter((guild) => guild.id != "@me" && guild.emojis.length > 0) .filter(guild=>guild.id != "@me" && guild.emojis.length > 0)
.forEach((guild) => { .forEach(guild=>{
const select = document.createElement("div"); const select = document.createElement("div");
select.classList.add("emojiSelect"); select.classList.add("emojiSelect");
@ -172,7 +171,7 @@ class Emoji {
const div = document.createElement("span"); const div = document.createElement("span");
div.textContent = guild.properties.name div.textContent = guild.properties.name
.replace(/'s /g, " ") .replace(/'s /g, " ")
.replace(/\w+/g, (word) => word[0]) .replace(/\w+/g, word=>word[0])
.replace(/\s/g, ""); .replace(/\s/g, "");
select.append(div); select.append(div);
} }
@ -236,7 +235,7 @@ class Emoji {
emoji.classList.add("emojiSelect"); emoji.classList.add("emojiSelect");
emoji.textContent = emojit.emoji; emoji.textContent = emojit.emoji;
body.append(emoji); body.append(emoji);
emoji.onclick = (_) => { emoji.onclick = _=>{
res(emojit.emoji); res(emojit.emoji);
if(Contextmenu.currentmenu !== ""){ if(Contextmenu.currentmenu !== ""){
Contextmenu.currentmenu.remove(); Contextmenu.currentmenu.remove();

View file

@ -84,7 +84,7 @@ div.append(contained);
const controls = document.createElement("div"); const controls = document.createElement("div");
const garbage = document.createElement("button"); const garbage = document.createElement("button");
garbage.textContent = "🗑"; garbage.textContent = "🗑";
garbage.onclick = (_) => { garbage.onclick = _=>{
div.remove(); div.remove();
files.splice(files.indexOf(file), 1); files.splice(files.indexOf(file), 1);
}; };

View file

@ -72,10 +72,10 @@ roleids!: Map<string, Role>;
Guild.contextmenu.addbutton( Guild.contextmenu.addbutton(
"Create invite", "Create invite",
function (this: Guild) {}, (this: Guild)=>{},
null, null,
(_) => true, _=>true,
(_) => false _=>false
); );
Guild.contextmenu.addbutton("Settings", function(this: Guild){ Guild.contextmenu.addbutton("Settings", function(this: Guild){
this.generateSettings(); this.generateSettings();
@ -95,7 +95,7 @@ roleids!: Map<string, Role>;
const settings = new Settings("Settings for " + this.properties.name); const settings = new Settings("Settings for " + this.properties.name);
{ {
const overview = settings.addButton("Overview"); const overview = settings.addButton("Overview");
const form = overview.addForm("", (_) => {}, { const form = overview.addForm("", _=>{}, {
headers: this.headers, headers: this.headers,
traditionalSubmit: true, traditionalSubmit: true,
fetchURL: this.info.api + "/guilds/" + this.id, fetchURL: this.info.api + "/guilds/" + this.id,
@ -153,7 +153,7 @@ roleids!: Map<string, Role>;
this.roleids.set(roleh.id, roleh); this.roleids.set(roleh.id, roleh);
} }
if(member instanceof User){ if(member instanceof User){
Member.resolveMember(member, this).then((_) => { Member.resolveMember(member, this).then(_=>{
if(_){ if(_){
this.member = _; this.member = _;
}else{ }else{
@ -161,7 +161,7 @@ roleids!: Map<string, Role>;
} }
}); });
}else{ }else{
Member.new(member, this).then((_) => { Member.new(member, this).then(_=>{
if(_){ if(_){
this.member = _; this.member = _;
} }
@ -248,7 +248,7 @@ roleids!: Map<string, Role>;
"", "",
"Yes, I'm sure", "Yes, I'm sure",
(_: any)=>{ (_: any)=>{
this.leave().then((_) => { this.leave().then(_=>{
full.hide(); full.hide();
}); });
}, },
@ -377,7 +377,7 @@ roleids!: Map<string, Role>;
guild.loadGuild(); guild.loadGuild();
guild.loadChannel(); guild.loadChannel();
}; };
Guild.contextmenu.bindContextmenu(img, guild, undefined); Guild.contextmenu.bindContextmenu(img, guild);
} }
}else{ }else{
const div = document.createElement("div"); const div = document.createElement("div");
@ -389,7 +389,7 @@ roleids!: Map<string, Role>;
} }
const build = name const build = name
.replace(/'s /g, " ") .replace(/'s /g, " ")
.replace(/\w+/g, (word) => word[0]) .replace(/\w+/g, word=>word[0])
.replace(/\s/g, ""); .replace(/\s/g, "");
div.textContent = build; div.textContent = build;
div.classList.add("blankserver", "servericon"); div.classList.add("blankserver", "servericon");
@ -399,7 +399,7 @@ roleids!: Map<string, Role>;
guild.loadGuild(); guild.loadGuild();
guild.loadChannel(); guild.loadChannel();
}; };
Guild.contextmenu.bindContextmenu(div, guild, undefined); Guild.contextmenu.bindContextmenu(div, guild);
} }
} }
return divy; return divy;
@ -434,7 +434,7 @@ roleids!: Map<string, Role>;
if(confirmname !== this.properties.name){ if(confirmname !== this.properties.name){
return; return;
} }
this.delete().then((_) => { this.delete().then(_=>{
full.hide(); full.hide();
}); });
}, },

View file

@ -3,7 +3,7 @@ console.log(mobile);
const serverbox = document.getElementById("instancebox") as HTMLDivElement; const serverbox = document.getElementById("instancebox") as HTMLDivElement;
fetch("/instances.json") fetch("/instances.json")
.then((_) => _.json()) .then(_=>_.json())
.then( .then(
( (
json: { json: {
@ -75,7 +75,7 @@ stats.append(span);
statbox.append(stats); statbox.append(stats);
} }
div.append(statbox); div.append(statbox);
div.onclick = (_) => { div.onclick = _=>{
if(instance.online){ if(instance.online){
window.location.href = window.location.href =
"/register.html?instance=" + encodeURI(instance.name); "/register.html?instance=" + encodeURI(instance.name);

View file

@ -7,8 +7,8 @@ import { File } from "./file.js";
(async ()=>{ (async ()=>{
async function waitForLoad(): Promise<void>{ async function waitForLoad(): Promise<void>{
return new Promise((resolve) => { return new Promise(resolve=>{
document.addEventListener("DOMContentLoaded", (_) => resolve()); document.addEventListener("DOMContentLoaded", _=>resolve());
}); });
} }
@ -88,7 +88,7 @@ async function waitForLoad(): Promise<void> {
} }
const userInfoElement = document.getElementById("userinfo") as HTMLDivElement; const userInfoElement = document.getElementById("userinfo") as HTMLDivElement;
userInfoElement.addEventListener("click", (event) => { userInfoElement.addEventListener("click", event=>{
event.stopImmediatePropagation(); event.stopImmediatePropagation();
showAccountSwitcher(); showAccountSwitcher();
}); });
@ -96,7 +96,7 @@ async function waitForLoad(): Promise<void> {
const switchAccountsElement = document.getElementById( const switchAccountsElement = document.getElementById(
"switchaccounts" "switchaccounts"
) as HTMLDivElement; ) as HTMLDivElement;
switchAccountsElement.addEventListener("click", (event) => { switchAccountsElement.addEventListener("click", event=>{
event.stopImmediatePropagation(); event.stopImmediatePropagation();
showAccountSwitcher(); showAccountSwitcher();
}); });
@ -204,7 +204,7 @@ async function waitForLoad(): Promise<void> {
const markdown = new MarkDown("", thisUser); const markdown = new MarkDown("", thisUser);
typebox.markdown = markdown; typebox.markdown = markdown;
typebox.addEventListener("keyup", handleEnter); typebox.addEventListener("keyup", handleEnter);
typebox.addEventListener("keydown", (event) => { typebox.addEventListener("keydown", event=>{
if(event.key === "Enter" && !event.shiftKey) event.preventDefault(); if(event.key === "Enter" && !event.shiftKey) event.preventDefault();
}); });
markdown.giveBox(typebox); markdown.giveBox(typebox);

View file

@ -235,7 +235,7 @@ offset: number
this.watchtime = false; this.watchtime = false;
} }
this.changePromise = new Promise<boolean>(async (res) => { this.changePromise = new Promise<boolean>(async res=>{
try{ try{
if(!this.div){ if(!this.div){
res(false); res(false);
@ -281,9 +281,9 @@ offset: number
behavior: "smooth", behavior: "smooth",
block: "center", block: "center",
}); });
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise(resolve=>setTimeout(resolve, 1000));
element.classList.remove("jumped"); element.classList.remove("jumped");
await new Promise((resolve) => setTimeout(resolve, 100)); await new Promise(resolve=>setTimeout(resolve, 100));
element.classList.add("jumped"); element.classList.add("jumped");
}else{ }else{
element.scrollIntoView(); element.scrollIntoView();
@ -296,7 +296,7 @@ offset: number
await this.firstElement(id); await this.firstElement(id);
this.updatestuff(); this.updatestuff();
await this.watchForChange(); await this.watchForChange();
await new Promise((resolve) => setTimeout(resolve, 100)); await new Promise(resolve=>setTimeout(resolve, 100));
await this.focus(id, true); await this.focus(id, true);
} }
} }

View file

@ -50,8 +50,8 @@ let guildinfo: any;
fetch(`${urls!.api}/invites/${code}`, { fetch(`${urls!.api}/invites/${code}`, {
method: "GET", method: "GET",
}) })
.then((response) => response.json()) .then(response=>response.json())
.then((json) => { .then(json=>{
const guildjson = json.guild; const guildjson = json.guild;
guildinfo = guildjson; guildinfo = guildjson;
document.getElementById("invitename")!.textContent = guildjson.name; document.getElementById("invitename")!.textContent = guildjson.name;

View file

@ -164,9 +164,9 @@ class Localuser {
r = ds.readable.getReader(); r = ds.readable.getReader();
arr = new Uint8Array(); arr = new Uint8Array();
} }
const promise = new Promise<void>((res) => { const promise = new Promise<void>(res=>{
returny = res; returny = res;
ws.addEventListener("open", (_event) => { ws.addEventListener("open", _event=>{
console.log("WebSocket connected"); console.log("WebSocket connected");
ws.send( ws.send(
JSON.stringify({ JSON.stringify({
@ -211,11 +211,11 @@ class Localuser {
} }
}); });
let order = new Promise<void>((res) => res()); let order = new Promise<void>(res=>res());
ws.addEventListener("message", async (event) => { ws.addEventListener("message", async event=>{
const temp2 = order; const temp2 = order;
order = new Promise<void>(async (res) => { order = new Promise<void>(async res=>{
await temp2; await temp2;
let temp: { op: number; t: string }; let temp: { op: number; t: string };
try{ try{
@ -257,7 +257,7 @@ class Localuser {
}); });
}); });
ws.addEventListener("close", async (event) => { ws.addEventListener("close", async event=>{
this.ws = undefined; this.ws = undefined;
console.log("WebSocket closed with code " + event.code); console.log("WebSocket closed with code " + event.code);
@ -604,7 +604,7 @@ class Localuser {
div.classList.add("home", "servericon"); div.classList.add("home", "servericon");
home.classList.add("svgtheme", "svgicon", "svg-home"); home.classList.add("svgtheme", "svgicon", "svg-home");
home["all"] = this.guildids.get("@me"); home.all = this.guildids.get("@me");
(this.guildids.get("@me") as Guild).html = outdiv; (this.guildids.get("@me") as Guild).html = outdiv;
const unread = document.createElement("div"); const unread = document.createElement("div");
unread.classList.add("unread"); unread.classList.add("unread");
@ -615,8 +615,8 @@ class Localuser {
outdiv.classList.add("servernoti"); outdiv.classList.add("servernoti");
serverlist.append(outdiv); serverlist.append(outdiv);
home.onclick = function(){ home.onclick = function(){
this["all"].loadGuild(); this.all.loadGuild();
this["all"].loadChannel(); this.all.loadChannel();
}; };
const sentdms = document.createElement("div"); const sentdms = document.createElement("div");
sentdms.classList.add("sentdms"); sentdms.classList.add("sentdms");
@ -644,7 +644,7 @@ class Localuser {
div.textContent = "+"; div.textContent = "+";
div.classList.add("home", "servericon"); div.classList.add("home", "servericon");
serverlist.appendChild(div); serverlist.appendChild(div);
div.onclick = (_) => { div.onclick = _=>{
this.createGuild(); this.createGuild();
}; };
const guilddsdiv = document.createElement("div"); const guilddsdiv = document.createElement("div");
@ -702,8 +702,8 @@ class Localuser {
method: "POST", method: "POST",
headers: this.headers, headers: this.headers,
}) })
.then((r) => r.json()) .then(r=>r.json())
.then((_) => { .then(_=>{
if(_.message){ if(_.message){
error.textContent = _.message; error.textContent = _.message;
} }
@ -744,7 +744,7 @@ class Localuser {
"", "",
"submit", "submit",
()=>{ ()=>{
this.makeGuild(fields).then((_) => { this.makeGuild(fields).then(_=>{
if(_.message){ if(_.message){
alert(_.errors.name._errors[0].message); alert(_.errors.name._errors[0].message);
}else{ }else{
@ -934,14 +934,14 @@ class Localuser {
const finput = settingsLeft.addFileInput( const finput = settingsLeft.addFileInput(
"Upload pfp:", "Upload pfp:",
(_) => { _=>{
if(file){ if(file){
this.updatepfp(file); this.updatepfp(file);
} }
}, },
{ clear: true } { clear: true }
); );
finput.watchForChange((_) => { finput.watchForChange(_=>{
if(!_){ if(!_){
file = null; file = null;
hypouser.avatar = null; hypouser.avatar = null;
@ -960,14 +960,14 @@ class Localuser {
let bfile: undefined | File | null; let bfile: undefined | File | null;
const binput = settingsLeft.addFileInput( const binput = settingsLeft.addFileInput(
"Upload banner:", "Upload banner:",
(_) => { _=>{
if(bfile !== undefined){ if(bfile !== undefined){
this.updatebanner(bfile); this.updatebanner(bfile);
} }
}, },
{ clear: true } { clear: true }
); );
binput.watchForChange((_) => { binput.watchForChange(_=>{
if(!_){ if(!_){
bfile = null; bfile = null;
hypouser.banner = undefined; hypouser.banner = undefined;
@ -986,7 +986,7 @@ class Localuser {
let changed = false; let changed = false;
const pronounbox = settingsLeft.addTextInput( const pronounbox = settingsLeft.addTextInput(
"Pronouns", "Pronouns",
(_) => { _=>{
if(newpronouns || newbio || changed){ if(newpronouns || newbio || changed){
this.updateProfile({ this.updateProfile({
pronouns: newpronouns, pronouns: newpronouns,
@ -997,15 +997,15 @@ class Localuser {
}, },
{ initText: this.user.pronouns } { initText: this.user.pronouns }
); );
pronounbox.watchForChange((_) => { pronounbox.watchForChange(_=>{
hypouser.pronouns = _; hypouser.pronouns = _;
newpronouns = _; newpronouns = _;
regen(); regen();
}); });
const bioBox = settingsLeft.addMDInput("Bio:", (_) => {}, { const bioBox = settingsLeft.addMDInput("Bio:", _=>{}, {
initText: this.user.bio.rawString, initText: this.user.bio.rawString,
}); });
bioBox.watchForChange((_) => { bioBox.watchForChange(_=>{
newbio = _; newbio = _;
hypouser.bio = new MarkDown(_, this); hypouser.bio = new MarkDown(_, this);
regen(); regen();
@ -1018,10 +1018,10 @@ class Localuser {
} }
const colorPicker = settingsLeft.addColorInput( const colorPicker = settingsLeft.addColorInput(
"Profile color", "Profile color",
(_) => {}, _=>{},
{ initColor: color } { initColor: color }
); );
colorPicker.watchForChange((_) => { colorPicker.watchForChange(_=>{
console.log(); console.log();
color = _; color = _;
hypouser.accent_color = Number.parseInt("0x" + _.substr(1), 16); hypouser.accent_color = Number.parseInt("0x" + _.substr(1), 16);
@ -1035,7 +1035,7 @@ class Localuser {
const themes = ["Dark", "WHITE", "Light"]; const themes = ["Dark", "WHITE", "Light"];
tas.addSelect( tas.addSelect(
"Theme:", "Theme:",
(_) => { _=>{
localStorage.setItem("theme", themes[_]); localStorage.setItem("theme", themes[_]);
setTheme(); setTheme();
}, },
@ -1052,13 +1052,13 @@ class Localuser {
tas tas
.addSelect( .addSelect(
"Notification sound:", "Notification sound:",
(_) => { _=>{
Voice.setNotificationSound(sounds[_]); Voice.setNotificationSound(sounds[_]);
}, },
sounds, sounds,
{ defaultIndex: sounds.indexOf(Voice.getNotificationSound()) } { defaultIndex: sounds.indexOf(Voice.getNotificationSound()) }
) )
.watchForChange((_) => { .watchForChange(_=>{
Voice.noises(sounds[_]); Voice.noises(sounds[_]);
}); });
} }
@ -1067,7 +1067,7 @@ class Localuser {
const userinfos = getBulkInfo(); const userinfos = getBulkInfo();
tas.addColorInput( tas.addColorInput(
"Accent color:", "Accent color:",
(_) => { _=>{
userinfos.accent_color = _; userinfos.accent_color = _;
localStorage.setItem("userinfos", JSON.stringify(userinfos)); localStorage.setItem("userinfos", JSON.stringify(userinfos));
document.documentElement.style.setProperty( document.documentElement.style.setProperty(
@ -1155,7 +1155,7 @@ class Localuser {
security.addButtonInput("", "Change discriminator", ()=>{ security.addButtonInput("", "Change discriminator", ()=>{
const form = security.addSubForm( const form = security.addSubForm(
"Change Discriminator", "Change Discriminator",
(_) => { _=>{
security.returnFromSub(); security.returnFromSub();
}, },
{ {
@ -1169,7 +1169,7 @@ class Localuser {
security.addButtonInput("", "Change email", ()=>{ security.addButtonInput("", "Change email", ()=>{
const form = security.addSubForm( const form = security.addSubForm(
"Change Email", "Change Email",
(_) => { _=>{
security.returnFromSub(); security.returnFromSub();
}, },
{ {
@ -1187,7 +1187,7 @@ class Localuser {
security.addButtonInput("", "Change username", ()=>{ security.addButtonInput("", "Change username", ()=>{
const form = security.addSubForm( const form = security.addSubForm(
"Change Username", "Change Username",
(_) => { _=>{
security.returnFromSub(); security.returnFromSub();
}, },
{ {
@ -1205,7 +1205,7 @@ class Localuser {
security.addButtonInput("", "Change password", ()=>{ security.addButtonInput("", "Change password", ()=>{
const form = security.addSubForm( const form = security.addSubForm(
"Change Password", "Change Password",
(_) => { _=>{
security.returnFromSub(); security.returnFromSub();
}, },
{ {
@ -1220,11 +1220,11 @@ class Localuser {
} }
let in1 = ""; let in1 = "";
let in2 = ""; let in2 = "";
form.addTextInput("New password:", "").watchForChange((text) => { form.addTextInput("New password:", "").watchForChange(text=>{
in1 = text; in1 = text;
}); });
const copy = form.addTextInput("New password again:", ""); const copy = form.addTextInput("New password again:", "");
copy.watchForChange((text) => { copy.watchForChange(text=>{
in2 = text; in2 = text;
}); });
form.setValue("new_password", ()=>{ form.setValue("new_password", ()=>{
@ -1246,11 +1246,11 @@ class Localuser {
fetch(this.info.api + "/connections", { fetch(this.info.api + "/connections", {
headers: this.headers, headers: this.headers,
}) })
.then((r) => r.json()) .then(r=>r.json())
.then((json) => { .then(json=>{
Object.keys(json) Object.keys(json)
.sort((key) => (json[key].enabled ? -1 : 1)) .sort(key=>(json[key].enabled ? -1 : 1))
.forEach((key) => { .forEach(key=>{
const connection = json[key]; const connection = json[key];
const container = document.createElement("div"); const container = document.createElement("div");
@ -1324,8 +1324,8 @@ class Localuser {
fetch(this.info.api + "/applications", { fetch(this.info.api + "/applications", {
headers: this.headers, headers: this.headers,
}) })
.then((r) => r.json()) .then(r=>r.json())
.then((json) => { .then(json=>{
json.forEach( json.forEach(
(application: { (application: {
cover_image: any; cover_image: any;
@ -1414,7 +1414,7 @@ class Localuser {
[ [
"fileupload", "fileupload",
"Application icon:", "Application icon:",
(event) => { event=>{
const reader = new FileReader(); const reader = new FileReader();
const files = (event.target as HTMLInputElement).files; const files = (event.target as HTMLInputElement).files;
if(files){ if(files){
@ -1566,7 +1566,7 @@ class Localuser {
[ [
"fileupload", "fileupload",
"Bot avatar:", "Bot avatar:",
(event) => { event=>{
const reader = new FileReader(); const reader = new FileReader();
const files = (event.target as HTMLInputElement).files; const files = (event.target as HTMLInputElement).files;
if(files){ if(files){
@ -1668,7 +1668,7 @@ class Localuser {
guildmap = new Map(); guildmap = new Map();
this.waitingmembers.set(guildid, guildmap); this.waitingmembers.set(guildid, guildmap);
} }
const promise: Promise<memberjson | undefined> = new Promise((res) => { const promise: Promise<memberjson | undefined> = new Promise(res=>{
guildmap.set(id, res); guildmap.set(id, res);
this.getmembers(); this.getmembers();
}); });
@ -1707,7 +1707,7 @@ class Localuser {
} }
} }
async getmembers(){ async getmembers(){
const promise = new Promise((res) => { const promise = new Promise(res=>{
setTimeout(res, 10); setTimeout(res, 10);
}); });
await promise; //allow for more to be sent at once :P await promise; //allow for more to be sent at once :P
@ -1729,7 +1729,7 @@ class Localuser {
return; return;
} }
const promise: Promise<[memberjson[], string[]]> = new Promise( const promise: Promise<[memberjson[], string[]]> = new Promise(
(res) => { res=>{
const nonce = "" + Math.floor(Math.random() * 100000000000); const nonce = "" + Math.floor(Math.random() * 100000000000);
this.noncemap.set(nonce, res); this.noncemap.set(nonce, res);
this.noncebuild.set(nonce, [[], [], []]); this.noncebuild.set(nonce, [[], [], []]);
@ -1769,7 +1769,7 @@ class Localuser {
value.delete(thing); value.delete(thing);
continue; continue;
} }
func(undefined); func();
value.delete(thing); value.delete(thing);
} }
} }

View file

@ -1,24 +1,24 @@
<body class="Dark-theme"> <body class="Dark-theme">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jank Client</title> <title>Jank Client</title>
<meta content="Jank Client" property="og:title" /> <meta content="Jank Client" property="og:title">
<meta <meta
content="A spacebar client that has DMs, replying and more" content="A spacebar client that has DMs, replying and more"
property="og:description" property="og:description"
/> >
<meta content="/logo.webp" property="og:image" /> <meta content="/logo.webp" property="og:image">
<meta content="#4b458c" data-react-helmet="true" name="theme-color" /> <meta content="#4b458c" data-react-helmet="true" name="theme-color">
<link href="/style.css" rel="stylesheet" /> <link href="/style.css" rel="stylesheet">
<link href="/themes.css" rel="stylesheet" id="lightcss" /> <link href="/themes.css" rel="stylesheet" id="lightcss">
</head> </head>
<div id="logindiv"> <div id="logindiv">
<h1>Login</h1> <h1>Login</h1>
<br /> <br >
<form id="form" submit="check(e)"> <form id="form" submit="check(e)">
<label for="instance"><b>Instance:</b></label <label for="instance"><b>Instance:</b></label
><br /> ><br >
<p id="verify"></p> <p id="verify"></p>
<input <input
type="search" type="search"
@ -29,27 +29,27 @@
value="" value=""
id="instancein" id="instancein"
required required
/><br /><br /> ><br ><br >
<label for="uname"><b>Email:</b></label <label for="uname"><b>Email:</b></label
><br /> ><br >
<input <input
type="text" type="text"
placeholder="Enter email address" placeholder="Enter email address"
name="uname" name="uname"
id="uname" id="uname"
required required
/><br /><br /> ><br ><br >
<label for="psw"><b>Password:</b></label <label for="psw"><b>Password:</b></label
><br /> ><br >
<input <input
type="password" type="password"
placeholder="Enter Password" placeholder="Enter Password"
name="psw" name="psw"
id="psw" id="psw"
required required
/><br /><br /><br /><br /> ><br ><br ><br ><br >
<p class="wrongred" id="wrong"></p> <p class="wrongred" id="wrong"></p>
<div id="h-captcha"></div> <div id="h-captcha"></div>

View file

@ -261,8 +261,7 @@ const stringURLMap = new Map<string, string>();
} }
let api: string; let api: string;
try{ try{
const info = await fetch(`${str}/.well-known/spacebar`).then((x) => const info = await fetch(`${str}/.well-known/spacebar`).then(x=>x.json()
x.json()
); );
api = info.api; api = info.api;
}catch{ }catch{
@ -274,7 +273,7 @@ const stringURLMap = new Map<string, string>();
`${api}${ `${api}${
url.pathname.includes("api") ? "" : "api" url.pathname.includes("api") ? "" : "api"
}/policies/instance/domains` }/policies/instance/domains`
).then((x) => x.json()); ).then(x=>x.json());
return{ return{
api: info.apiEndpoint, api: info.apiEndpoint,
gateway: info.gateway, gateway: info.gateway,
@ -349,7 +348,7 @@ const stringURLMap = new Map<string, string>();
if(instancein){ if(instancein){
console.log(instancein); console.log(instancein);
instancein.addEventListener("keydown", (_) => { instancein.addEventListener("keydown", _=>{
const verify = document.getElementById("verify"); const verify = document.getElementById("verify");
verify!.textContent = "Waiting to check Instance"; verify!.textContent = "Waiting to check Instance";
clearTimeout(timeout); clearTimeout(timeout);
@ -387,8 +386,8 @@ const stringURLMap = new Map<string, string>();
const info = JSON.parse(localStorage.getItem("instanceinfo")!); const info = JSON.parse(localStorage.getItem("instanceinfo")!);
const api = info.login + (info.login.startsWith("/") ? "/" : ""); const api = info.login + (info.login.startsWith("/") ? "/" : "");
return await fetch(api + "/auth/login", options) return await fetch(api + "/auth/login", options)
.then((response) => response.json()) .then(response=>response.json())
.then((response) => { .then(response=>{
console.log(response, response.message); console.log(response, response.message);
if(response.message === "Invalid Form Body"){ if(response.message === "Invalid Form Body"){
return response.errors.login._errors[0].message; return response.errors.login._errors[0].message;
@ -441,8 +440,8 @@ const stringURLMap = new Map<string, string>();
ticket: response.ticket, ticket: response.ticket,
}), }),
}) })
.then((r) => r.json()) .then(r=>r.json())
.then((response) => { .then(response=>{
if(response.message){ if(response.message){
alert(response.message); alert(response.message);
}else{ }else{
@ -568,7 +567,7 @@ const stringURLMap = new Map<string, string>();
} }
fetch("/instances.json") fetch("/instances.json")
.then((_) => _.json()) .then(_=>_.json())
.then( .then(
( (
json: { json: {

View file

@ -480,14 +480,14 @@ if (!keep) {
user.bind(mention, guild); user.bind(mention, guild);
} }
if(guild){ if(guild){
Member.resolveMember(user, guild).then((member) => { Member.resolveMember(user, guild).then(member=>{
if(member){ if(member){
mention.textContent = `@${member.name}`; mention.textContent = `@${member.name}`;
} }
}); });
} }
}else{ }else{
mention.textContent = `@unknown`; mention.textContent = "@unknown";
} }
break; break;
case"#": case"#":
@ -495,12 +495,12 @@ const channel = this.localuser.channelids.get(id);
if(channel){ if(channel){
mention.textContent = `#${channel.name}`; mention.textContent = `#${channel.name}`;
if(!keep){ if(!keep){
mention.onclick = (_) => { mention.onclick = _=>{
this.localuser.goToChannel(id); this.localuser.goToChannel(id);
}; };
} }
}else{ }else{
mention.textContent = `#unknown`; mention.textContent = "#unknown";
} }
break; break;
} }
@ -693,11 +693,11 @@ const parts = build
e.target.classList.add("unspoiled"); e.target.classList.add("unspoiled");
} }
giveBox(box: HTMLDivElement){ giveBox(box: HTMLDivElement){
box.onkeydown = (_) => { box.onkeydown = _=>{
//console.log(_); //console.log(_);
}; };
let prevcontent = ""; let prevcontent = "";
box.onkeyup = (_) => { box.onkeyup = _=>{
const content = MarkDown.gatherBoxText(box); const content = MarkDown.gatherBoxText(box);
if(content !== prevcontent){ if(content !== prevcontent){
prevcontent = content; prevcontent = content;
@ -705,7 +705,7 @@ const parts = build
this.boxupdate(box); this.boxupdate(box);
} }
}; };
box.onpaste = (_) => { box.onpaste = _=>{
if(!_.clipboardData)return; if(!_.clipboardData)return;
console.log(_.clipboardData.types); console.log(_.clipboardData.types);
const data = _.clipboardData.getData("text"); const data = _.clipboardData.getData("text");
@ -760,7 +760,7 @@ const parts = build
elm.target = "_blank"; elm.target = "_blank";
return; return;
} }
elm.onmouseup = (_) => { elm.onmouseup = _=>{
if(_.button === 2)return; if(_.button === 2)return;
console.log(":3"); console.log(":3");
function open(){ function open(){
@ -811,7 +811,7 @@ const parts = build
} }
}; };
}else{ }else{
throw Error(url + " is not a valid URL"); throw new Error(url + " is not a valid URL");
} }
} }
/* /*
@ -839,7 +839,7 @@ const parts = build
len--; len--;
} }
} }
len += +(text[text.length - 1] === "\n"); len += Number(text.at(-1) === "\n");
return function restore(){ return function restore(){
if(!selection)return; if(!selection)return;
@ -853,7 +853,7 @@ const parts = build
function getTextNodeAtPosition(root: Node, index: number){ function getTextNodeAtPosition(root: Node, index: number){
const NODE_TYPE = NodeFilter.SHOW_TEXT; const NODE_TYPE = NodeFilter.SHOW_TEXT;
const treeWalker = document.createTreeWalker(root, NODE_TYPE, (elem) => { const treeWalker = document.createTreeWalker(root, NODE_TYPE, elem=>{
if(!elem.textContent)return 0; if(!elem.textContent)return 0;
if(index > elem.textContent.length){ if(index > elem.textContent.length){
index -= elem.textContent.length; index -= elem.textContent.length;

View file

@ -91,10 +91,10 @@ owner: Guild
const maybe = user.members.get(guild); const maybe = user.members.get(guild);
if(!user.members.has(guild)){ if(!user.members.has(guild)){
const membpromise = guild.localuser.resolvemember(user.id, guild.id); const membpromise = guild.localuser.resolvemember(user.id, guild.id);
const promise = new Promise<Member | undefined>(async (res) => { const promise = new Promise<Member | undefined>(async res=>{
const membjson = await membpromise; const membjson = await membpromise;
if(membjson === undefined){ if(membjson === undefined){
return res(undefined); return res();
}else{ }else{
const member = new Member(membjson, guild); const member = new Member(membjson, guild);
const map = guild.localuser.presences; const map = guild.localuser.presences;

View file

@ -46,7 +46,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
member: Member | undefined; member: Member | undefined;
reactions!: messagejson["reactions"]; reactions!: messagejson["reactions"];
static setup(){ static setup(){
this.del = new Promise((_) => { this.del = new Promise(_=>{
this.resolve = _; this.resolve = _;
}); });
Message.setupcmenu(); Message.setupcmenu();
@ -64,7 +64,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
Message.contextmenu.addsubmenu( Message.contextmenu.addsubmenu(
"Add reaction", "Add reaction",
function(this: Message, _, e: MouseEvent){ function(this: Message, _, e: MouseEvent){
Emoji.emojiPicker(e.x, e.y, this.localuser).then((_) => { Emoji.emojiPicker(e.x, e.y, this.localuser).then(_=>{
this.reactionToggle(_); this.reactionToggle(_);
}); });
} }
@ -96,7 +96,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
document.getElementById("typebox") as HTMLDivElement & { document.getElementById("typebox") as HTMLDivElement & {
markdown: MarkDown; markdown: MarkDown;
} }
)["markdown"] as MarkDown; ).markdown as MarkDown;
markdown.txt = this.content.rawString.split(""); markdown.txt = this.content.rawString.split("");
markdown.boxupdate(document.getElementById("typebox") as HTMLDivElement); markdown.boxupdate(document.getElementById("typebox") as HTMLDivElement);
} }
@ -144,7 +144,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
}else if(thing === "id"){ }else if(thing === "id"){
continue; continue;
}else if(thing === "member"){ }else if(thing === "member"){
Member.new(messagejson.member as memberjson, this.guild).then((_) => { Member.new(messagejson.member as memberjson, this.guild).then(_=>{
this.member = _ as Member; this.member = _ as Member;
}); });
continue; continue;
@ -169,7 +169,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
); );
} }
if(!this.member && this.guild.id !== "@me"){ if(!this.member && this.guild.id !== "@me"){
this.author.resolvemember(this.guild).then((_) => { this.author.resolvemember(this.guild).then(_=>{
this.member = _; this.member = _;
}); });
} }
@ -223,7 +223,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
}else if(userd instanceof Member){ }else if(userd instanceof Member){
return this.mentions.includes(userd.user); return this.mentions.includes(userd.user);
}else{ }else{
return;
} }
} }
getimages(){ getimages(){
@ -341,7 +341,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
"You have this user blocked, click to hide these messages."; "You have this user blocked, click to hide these messages.";
div.append(span); div.append(span);
span.classList.add("blocked"); span.classList.add("blocked");
span.onclick = (_) => { span.onclick = _=>{
const scroll = this.channel.infinite.scrollTop; const scroll = this.channel.infinite.scrollTop;
let next: Message | undefined = this; let next: Message | undefined = this;
while(next?.author === this.author){ while(next?.author === this.author){
@ -377,7 +377,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
} }
span.textContent = `You have this user blocked, click to see the ${count} blocked messages.`; span.textContent = `You have this user blocked, click to see the ${count} blocked messages.`;
build.append(span); build.append(span);
span.onclick = (_) => { span.onclick = _=>{
const scroll = this.channel.infinite.scrollTop; const scroll = this.channel.infinite.scrollTop;
const func = this.channel.infinite.snapBottom(); const func = this.channel.infinite.snapBottom();
let next: Message | undefined = this; let next: Message | undefined = this;
@ -417,7 +417,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
line.classList.add("startreply"); line.classList.add("startreply");
replyline.classList.add("replyflex"); replyline.classList.add("replyflex");
// TODO: Fix this // TODO: Fix this
this.channel.getmessage(this.message_reference.id).then((message) => { this.channel.getmessage(this.message_reference.id).then(message=>{
if(message.author.relationshipType === 2){ if(message.author.relationshipType === 2){
username.textContent = "Blocked user"; username.textContent = "Blocked user";
return; return;
@ -429,7 +429,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
username.textContent = author.username; username.textContent = author.username;
author.bind(username, this.guild); author.bind(username, this.guild);
}); });
reply.onclick = (_) => { reply.onclick = _=>{
// TODO: FIX this // TODO: FIX this
this.channel.infinite.focus(this.message_reference.id); this.channel.infinite.focus(this.message_reference.id);
}; };
@ -457,7 +457,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
this.author.bind(pfp, this.guild, false); this.author.bind(pfp, this.guild, false);
pfpRow.appendChild(pfp); pfpRow.appendChild(pfp);
}else{ }else{
div["pfpparent"] = pfpparent; div.pfpparent = pfpparent;
} }
pfpRow.classList.add("pfprow"); pfpRow.classList.add("pfprow");
build.appendChild(pfpRow); build.appendChild(pfpRow);
@ -491,7 +491,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
div.classList.remove("topMessage"); div.classList.remove("topMessage");
} }
const messaged = this.content.makeHTML(); const messaged = this.content.makeHTML();
(div as any)["txt"] = messaged; (div as any).txt = messaged;
const messagedwrap = document.createElement("div"); const messagedwrap = document.createElement("div");
messagedwrap.classList.add("flexttb"); messagedwrap.classList.add("flexttb");
messagedwrap.appendChild(messaged); messagedwrap.appendChild(messaged);
@ -524,7 +524,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
build.appendChild(text); build.appendChild(text);
texttxt.classList.add("flexltr"); texttxt.classList.add("flexltr");
const messaged = document.createElement("span"); const messaged = document.createElement("span");
div["txt"] = messaged; div.txt = messaged;
messaged.textContent = "welcome: "; messaged.textContent = "welcome: ";
texttxt.appendChild(messaged); texttxt.appendChild(messaged);
@ -552,7 +552,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
bindButtonEvent(){ bindButtonEvent(){
if(this.div){ if(this.div){
let buttons: HTMLDivElement | undefined; let buttons: HTMLDivElement | undefined;
this.div.onmouseenter = (_) => { this.div.onmouseenter = _=>{
if(buttons){ if(buttons){
buttons.remove(); buttons.remove();
buttons = undefined; buttons = undefined;
@ -566,7 +566,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
reply.classList.add("svgtheme", "svg-reply", "svgicon"); reply.classList.add("svgtheme", "svg-reply", "svgicon");
container.append(reply); container.append(reply);
buttons.append(container); buttons.append(container);
container.onclick = (_) => { container.onclick = _=>{
this.channel.setReplying(this); this.channel.setReplying(this);
}; };
} }
@ -576,7 +576,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
edit.classList.add("svgtheme", "svg-edit", "svgicon"); edit.classList.add("svgtheme", "svg-edit", "svgicon");
container.append(edit); container.append(edit);
buttons.append(container); buttons.append(container);
container.onclick = (_) => { container.onclick = _=>{
this.setEdit(); this.setEdit();
}; };
} }
@ -586,7 +586,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
reply.classList.add("svgtheme", "svg-delete", "svgicon"); reply.classList.add("svgtheme", "svg-delete", "svgicon");
container.append(reply); container.append(reply);
buttons.append(container); buttons.append(container);
container.onclick = (_) => { container.onclick = _=>{
if(_.shiftKey){ if(_.shiftKey){
this.delete(); this.delete();
return; return;
@ -620,7 +620,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
} }
} }
}; };
this.div.onmouseleave = (_) => { this.div.onmouseleave = _=>{
if(buttons){ if(buttons){
buttons.remove(); buttons.remove();
buttons = undefined; buttons = undefined;
@ -659,7 +659,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
reaction.append(emoji); reaction.append(emoji);
reactdiv.append(reaction); reactdiv.append(reaction);
reaction.onclick = (_) => { reaction.onclick = _=>{
this.reactionToggle(thing.emoji.name); this.reactionToggle(thing.emoji.name);
}; };
} }
@ -742,8 +742,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
function formatTime(date: Date){ function formatTime(date: Date){
updateTimes(); updateTimes();
const datestring = date.toLocaleDateString(); const datestring = date.toLocaleDateString();
const formatTime = (date: Date) => const formatTime = (date: Date)=>date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
if(datestring === now){ if(datestring === now){
return`Today at ${formatTime(date)}`; return`Today at ${formatTime(date)}`;

View file

@ -136,7 +136,7 @@ const tosPage = data.instance.tosPage;
if(tosPage){ if(tosPage){
document.getElementById("TOSbox")!.innerHTML = document.getElementById("TOSbox")!.innerHTML =
'I agree to the <a href="" id="TOSa">Terms of Service</a>:'; "I agree to the <a href=\"\" id=\"TOSa\">Terms of Service</a>:";
TOSa = document.getElementById("TOSa") as HTMLAnchorElement; TOSa = document.getElementById("TOSa") as HTMLAnchorElement;
TOSa.href = tosPage; TOSa.href = tosPage;
}else{ }else{
@ -149,4 +149,4 @@ console.log(tosPage);
tosLogic(); tosLogic();
(checkInstance as any)["alt"] = tosLogic; (checkInstance as any).alt = tosLogic;

View file

@ -87,7 +87,7 @@ class PermissionToggle implements OptionsElement<number> {
if(state === 1){ if(state === 1){
on.checked = true; on.checked = true;
} }
on.onclick = (_) => { on.onclick = _=>{
this.permissions.setPermission(this.rolejson.name, 1); this.permissions.setPermission(this.rolejson.name, 1);
this.owner.changed(); this.owner.changed();
}; };
@ -99,7 +99,7 @@ class PermissionToggle implements OptionsElement<number> {
if(state === 0){ if(state === 0){
no.checked = true; no.checked = true;
} }
no.onclick = (_) => { no.onclick = _=>{
this.permissions.setPermission(this.rolejson.name, 0); this.permissions.setPermission(this.rolejson.name, 0);
this.owner.changed(); this.owner.changed();
}; };
@ -111,7 +111,7 @@ class PermissionToggle implements OptionsElement<number> {
if(state === -1){ if(state === -1){
off.checked = true; off.checked = true;
} }
off.onclick = (_) => { off.onclick = _=>{
this.permissions.setPermission(this.rolejson.name, -1); this.permissions.setPermission(this.rolejson.name, -1);
this.owner.changed(); this.owner.changed();
}; };
@ -160,12 +160,12 @@ class PermissionToggle implements OptionsElement<number> {
} }
handleString(str: string): HTMLElement{ handleString(str: string): HTMLElement{
this.curid = str; this.curid = str;
const arr = this.permissions.find((_) => _[0].id === str); const arr = this.permissions.find(_=>_[0].id === str);
if(arr){ if(arr){
const perm = arr[1]; const perm = arr[1];
this.permission.deny = perm.deny; this.permission.deny = perm.deny;
this.permission.allow = perm.allow; this.permission.allow = perm.allow;
const role = this.permissions.find((e) => e[0].id === str); const role = this.permissions.find(e=>e[0].id === str);
if(role){ if(role){
this.options.name = role[0].name; this.options.name = role[0].name;
this.options.haschanged = false; this.options.haschanged = false;

View file

@ -29,7 +29,7 @@ if (promise) {
lastcache = await promise.text(); lastcache = await promise.text();
} }
console.log(lastcache); console.log(lastcache);
fetch("/getupdates").then(async (data) => { fetch("/getupdates").then(async data=>{
const text = await data.clone().text(); const text = await data.clone().text();
console.log(text, lastcache); console.log(text, lastcache);
if(lastcache !== text){ if(lastcache !== text){

View file

@ -36,7 +36,7 @@ interface OptionsElement<x> {
const button = document.createElement("button"); const button = document.createElement("button");
button.classList.add("SettingsButton"); button.classList.add("SettingsButton");
button.textContent = thing[0]; button.textContent = thing[0];
button.onclick = (_) => { button.onclick = _=>{
this.generateHTMLArea(thing[1], htmlarea); this.generateHTMLArea(thing[1], htmlarea);
if(this.warndiv){ if(this.warndiv){
this.warndiv.remove(); this.warndiv.remove();
@ -118,7 +118,7 @@ interface OptionsElement<x> {
this.value = value; this.value = value;
} }
} }
onchange: (str: string) => void = (_) => {}; onchange: (str: string) => void = _=>{};
watchForChange(func: (str: string) => void){ watchForChange(func: (str: string) => void){
this.onchange = func; this.onchange = func;
} }
@ -196,7 +196,7 @@ interface OptionsElement<x> {
this.value = value; this.value = value;
} }
} }
onchange: (str: boolean) => void = (_) => {}; onchange: (str: boolean) => void = _=>{};
watchForChange(func: (str: boolean) => void){ watchForChange(func: (str: boolean) => void){
this.onchange = func; this.onchange = func;
} }
@ -282,7 +282,7 @@ interface OptionsElement<x> {
this.colorContent = value; this.colorContent = value;
} }
} }
onchange: (str: string) => void = (_) => {}; onchange: (str: string) => void = _=>{};
watchForChange(func: (str: string) => void){ watchForChange(func: (str: string) => void){
this.onchange = func; this.onchange = func;
} }
@ -341,7 +341,7 @@ interface OptionsElement<x> {
this.index = value; this.index = value;
} }
} }
onchange: (str: number) => void = (_) => {}; onchange: (str: number) => void = _=>{};
watchForChange(func: (str: number) => void){ watchForChange(func: (str: number) => void){
this.onchange = func; this.onchange = func;
} }
@ -388,7 +388,7 @@ interface OptionsElement<x> {
this.value = value; this.value = value;
} }
} }
onchange: (str: string) => void = (_) => {}; onchange: (str: string) => void = _=>{};
watchForChange(func: (str: string) => void){ watchForChange(func: (str: string) => void){
this.onchange = func; this.onchange = func;
} }
@ -427,7 +427,7 @@ interface OptionsElement<x> {
if(this.clear){ if(this.clear){
const button = document.createElement("button"); const button = document.createElement("button");
button.textContent = "Clear"; button.textContent = "Clear";
button.onclick = (_) => { button.onclick = _=>{
if(this.onchange){ if(this.onchange){
this.onchange(null); this.onchange(null);
} }
@ -761,7 +761,7 @@ interface OptionsElement<x> {
this.haschanged = true; this.haschanged = true;
this.owner.changed(div); this.owner.changed(div);
button.onclick = (_) => { button.onclick = _=>{
if(this.owner instanceof Buttons){ if(this.owner instanceof Buttons){
this.owner.save(); this.owner.save();
} }
@ -835,7 +835,7 @@ interface OptionsElement<x> {
selections: string[], selections: string[],
{ defaultIndex = 0, required = false } = {} { defaultIndex = 0, required = false } = {}
){ ){
const select = this.options.addSelect(label, (_) => {}, selections, { const select = this.options.addSelect(label, _=>{}, selections, {
defaultIndex, defaultIndex,
}); });
this.names.set(formName, select); this.names.set(formName, select);
@ -850,7 +850,7 @@ interface OptionsElement<x> {
formName: string, formName: string,
{ required = false, files = "one", clear = false } = {} { required = false, files = "one", clear = false } = {}
){ ){
const FI = this.options.addFileInput(label, (_) => {}, { clear }); const FI = this.options.addFileInput(label, _=>{}, { clear });
if(files !== "one" && files !== "multi") if(files !== "one" && files !== "multi")
throw new Error("files should equal one or multi"); throw new Error("files should equal one or multi");
this.fileOptions.set(FI, { files }); this.fileOptions.set(FI, { files });
@ -866,7 +866,7 @@ interface OptionsElement<x> {
formName: string, formName: string,
{ initText = "", required = false, password = false } = {} { initText = "", required = false, password = false } = {}
){ ){
const textInput = this.options.addTextInput(label, (_) => {}, { const textInput = this.options.addTextInput(label, _=>{}, {
initText, initText,
password, password,
}); });
@ -881,7 +881,7 @@ interface OptionsElement<x> {
formName: string, formName: string,
{ initColor = "", required = false } = {} { initColor = "", required = false } = {}
){ ){
const colorInput = this.options.addColorInput(label, (_) => {}, { const colorInput = this.options.addColorInput(label, _=>{}, {
initColor, initColor,
}); });
this.names.set(formName, colorInput); this.names.set(formName, colorInput);
@ -896,7 +896,7 @@ interface OptionsElement<x> {
formName: string, formName: string,
{ initText = "", required = false } = {} { initText = "", required = false } = {}
){ ){
const mdInput = this.options.addMDInput(label, (_) => {}, { initText }); const mdInput = this.options.addMDInput(label, _=>{}, { initText });
this.names.set(formName, mdInput); this.names.set(formName, mdInput);
if(required){ if(required){
this.required.add(mdInput); this.required.add(mdInput);
@ -909,7 +909,7 @@ interface OptionsElement<x> {
formName: string, formName: string,
{ initState = false, required = false } = {} { initState = false, required = false } = {}
){ ){
const box = this.options.addCheckboxInput(label, (_) => {}, { initState }); const box = this.options.addCheckboxInput(label, _=>{}, { initState });
this.names.set(formName, box); this.names.set(formName, box);
if(required){ if(required){
this.required.add(box); this.required.add(box);
@ -928,7 +928,7 @@ interface OptionsElement<x> {
div.classList.add("FormSettings"); div.classList.add("FormSettings");
if(!this.traditionalSubmit){ if(!this.traditionalSubmit){
const button = document.createElement("button"); const button = document.createElement("button");
button.onclick = (_) => { button.onclick = _=>{
this.submit(); this.submit();
}; };
button.textContent = this.submitText; button.textContent = this.submitText;
@ -987,7 +987,7 @@ interface OptionsElement<x> {
if(input.value){ if(input.value){
const reader = new FileReader(); const reader = new FileReader();
reader.readAsDataURL(input.value[0]); reader.readAsDataURL(input.value[0]);
const promise = new Promise<void>((res) => { const promise = new Promise<void>(res=>{
reader.onload = ()=>{ reader.onload = ()=>{
(build as any)[thing] = reader.result; (build as any)[thing] = reader.result;
res(); res();
@ -1008,8 +1008,8 @@ interface OptionsElement<x> {
body: JSON.stringify(build), body: JSON.stringify(build),
headers: this.headers, headers: this.headers,
}) })
.then((_) => _.json()) .then(_=>_.json())
.then((json) => { .then(json=>{
if(json.errors && this.errors(json.errors))return; if(json.errors && this.errors(json.errors))return;
this.onSubmit(json); this.onSubmit(json);
}); });
@ -1032,7 +1032,7 @@ interface OptionsElement<x> {
const ref = this.options.html.get(elm); const ref = this.options.html.get(elm);
if(ref && ref.deref()){ if(ref && ref.deref()){
const html = ref.deref() as HTMLDivElement; const html = ref.deref() as HTMLDivElement;
this.makeError(html, errors["errors"][error]._errors.message); this.makeError(html, errors.errors[error]._errors.message);
return true; return true;
} }
} }
@ -1062,7 +1062,7 @@ interface OptionsElement<x> {
element = div; element = div;
}else{ }else{
element.classList.remove("suberror"); element.classList.remove("suberror");
setTimeout((_) => { setTimeout(_=>{
element.classList.add("suberror"); element.classList.add("suberror");
}, 100); }, 100);
} }
@ -1096,7 +1096,7 @@ interface OptionsElement<x> {
exit.textContent = "✖"; exit.textContent = "✖";
exit.classList.add("exitsettings"); exit.classList.add("exitsettings");
background.append(exit); background.append(exit);
exit.onclick = (_) => { exit.onclick = _=>{
this.hide(); this.hide();
}; };
document.body.append(background); document.body.append(background);

View file

@ -103,8 +103,8 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
body: JSON.stringify({ recipients: [this.id] }), body: JSON.stringify({ recipients: [this.id] }),
headers: this.localuser.headers, headers: this.localuser.headers,
}) })
.then((res) => res.json()) .then(res=>res.json())
.then((json) => { .then(json=>{
this.localuser.goToChannel(json.id); this.localuser.goToChannel(json.id);
}); });
}); });
@ -140,11 +140,11 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
}); });
this.contextmenu.addbutton( this.contextmenu.addbutton(
"Kick member", "Kick member",
function (this: User, member: Member | undefined) { (this: User, member: Member | undefined)=>{
member?.kick(); member?.kick();
}, },
null, null,
(member) => { member=>{
if(!member)return false; if(!member)return false;
const us = member.guild.member; const us = member.guild.member;
if(member.id === us.id){ if(member.id === us.id){
@ -158,11 +158,11 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
); );
this.contextmenu.addbutton( this.contextmenu.addbutton(
"Ban member", "Ban member",
function (this: User, member: Member | undefined) { (this: User, member: Member | undefined)=>{
member?.ban(); member?.ban();
}, },
null, null,
(member) => { member=>{
if(!member)return false; if(!member)return false;
const us = member.guild.member; const us = member.guild.member;
if(member.id === us.id){ if(member.id === us.id){
@ -211,7 +211,7 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
{ {
headers: this.localuser.headers, headers: this.localuser.headers,
} }
).then((res) => res.json()); ).then(res=>res.json());
} }
async getBadge(id: string): Promise<any>{ async getBadge(id: string): Promise<any>{
@ -272,7 +272,7 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
bind(html: HTMLElement, guild: Guild | null = null, error = true): void{ bind(html: HTMLElement, guild: Guild | null = null, error = true): void{
if(guild && guild.id !== "@me"){ if(guild && guild.id !== "@me"){
Member.resolveMember(this, guild) Member.resolveMember(this, guild)
.then((member) => { .then(member=>{
User.contextmenu.bindContextmenu(html, this, member); User.contextmenu.bindContextmenu(html, this, member);
if(member === undefined && error){ if(member === undefined && error){
const errorSpan = document.createElement("span"); const errorSpan = document.createElement("span");
@ -285,7 +285,7 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
member.bind(html); member.bind(html);
} }
}) })
.catch((err) => { .catch(err=>{
console.log(err); console.log(err);
}); });
} }
@ -300,7 +300,7 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
const json = await fetch( const json = await fetch(
localuser.info.api.toString() + "/users/" + id + "/profile", localuser.info.api.toString() + "/users/" + id + "/profile",
{ headers: localuser.headers } { headers: localuser.headers }
).then((res) => res.json()); ).then(res=>res.json());
return new User(json, localuser); return new User(json, localuser);
} }
@ -309,7 +309,7 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
this.hypotheticalpfp = false; this.hypotheticalpfp = false;
const src = this.getpfpsrc(); const src = this.getpfpsrc();
Array.from(document.getElementsByClassName("userid:" + this.id)).forEach( Array.from(document.getElementsByClassName("userid:" + this.id)).forEach(
(element) => { element=>{
(element as HTMLImageElement).src = src; (element as HTMLImageElement).src = src;
} }
); );
@ -447,7 +447,7 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
const biohtml = this.bio.makeHTML(); const biohtml = this.bio.makeHTML();
userbody.appendChild(biohtml); userbody.appendChild(biohtml);
if(guild){ if(guild){
Member.resolveMember(this, guild).then((member) => { Member.resolveMember(this, guild).then(member=>{
if(!member)return; if(!member)return;
const roles = document.createElement("div"); const roles = document.createElement("div");
roles.classList.add("rolesbox"); roles.classList.add("rolesbox");