general changes and reducing logs

This commit is contained in:
MathMan05 2024-07-27 12:51:42 -05:00
parent 0d757b7d4e
commit 7a745a5286
16 changed files with 146 additions and 78 deletions

View file

@ -7,7 +7,6 @@ class Direct extends Guild {
constructor(json, owner) { constructor(json, owner) {
super(-1, owner, null); super(-1, owner, null);
this.message_notifications = 0; this.message_notifications = 0;
console.log(json);
this.owner = owner; this.owner = owner;
if (!this.localuser) { if (!this.localuser) {
console.error("Owner was not included, please fix"); console.error("Owner was not included, please fix");
@ -169,13 +168,11 @@ class Group extends Channel {
const noti = document.createElement("div"); const noti = document.createElement("div");
noti.classList.add("unread", "notiunread", "pinged"); noti.classList.add("unread", "notiunread", "pinged");
noti.textContent = "" + this.mentions; noti.textContent = "" + this.mentions;
console.log(this.mentions);
div["noti"] = noti; div["noti"] = noti;
div.append(noti); div.append(noti);
const buildpfp = this.user.buildpfp(); const buildpfp = this.user.buildpfp();
div["all"] = this; div["all"] = this;
buildpfp.classList.add("mentioned"); buildpfp.classList.add("mentioned");
console.log(this);
div.append(buildpfp); div.append(buildpfp);
sentdms.append(div); sentdms.append(div);
div.onclick = _ => { div.onclick = _ => {

View file

@ -5,7 +5,6 @@ class Embed {
owner; owner;
json; json;
constructor(json, owner) { constructor(json, owner) {
console.log(json);
this.type = this.getType(json); this.type = this.getType(json);
this.owner = owner; this.owner = owner;
this.json = json; this.json = json;
@ -41,7 +40,6 @@ class Embed {
return this.guild.localuser; return this.guild.localuser;
} }
generateRich() { generateRich() {
console.log(this.json);
const div = document.createElement("div"); const div = document.createElement("div");
if (this.json.color) { if (this.json.color) {
div.style.backgroundColor = "#" + this.json.color.toString(16); div.style.backgroundColor = "#" + this.json.color.toString(16);

View file

@ -10,7 +10,6 @@ class File {
url; url;
size; size;
constructor(fileJSON, owner) { constructor(fileJSON, owner) {
console.log(fileJSON);
this.owner = owner; this.owner = owner;
this.id = fileJSON.id; this.id = fileJSON.id;
this.filename = fileJSON.filename; this.filename = fileJSON.filename;

View file

@ -288,7 +288,6 @@ class Localuser {
if (!guild) { if (!guild) {
guild = this.guildids.get("@me"); guild = this.guildids.get("@me");
} }
console.log(this.guildids, id, guild);
if (this.lookingguild) { if (this.lookingguild) {
this.lookingguild.html.classList.remove("serveropen"); this.lookingguild.html.classList.remove("serveropen");
} }
@ -345,7 +344,6 @@ class Localuser {
div.classList.add("home", "servericon"); div.classList.add("home", "servericon");
serverlist.appendChild(div); serverlist.appendChild(div);
div.onclick = _ => { div.onclick = _ => {
console.log("clicked :3");
this.createGuild(); this.createGuild();
}; };
const guildDiscoveryContainer = document.createElement("div"); const guildDiscoveryContainer = document.createElement("div");
@ -356,7 +354,6 @@ class Localuser {
this.guildDiscovery(); this.guildDiscovery();
}); });
} }
console.log("test");
this.unreads(); this.unreads();
} }
createGuild() { createGuild() {
@ -369,7 +366,6 @@ class Localuser {
"Invite Link/Code", "Invite Link/Code",
"", "",
function () { function () {
console.log(this);
inviteurl = this.value; inviteurl = this.value;
} }
], ],
@ -389,7 +385,6 @@ class Localuser {
method: "POST", method: "POST",
headers: this.headers, headers: this.headers,
}).then(r => r.json()).then(_ => { }).then(r => r.json()).then(_ => {
console.log(_);
if (_.message) { if (_.message) {
error.textContent = _.message; error.textContent = _.message;
} }
@ -463,13 +458,11 @@ class Localuser {
this.unreads(); this.unreads();
} }
unreads() { unreads() {
console.log(this.guildhtml);
for (const thing of this.guilds) { for (const thing of this.guilds) {
if (thing.id === "@me") { if (thing.id === "@me") {
continue; continue;
} }
const html = this.guildhtml.get(thing.id); const html = this.guildhtml.get(thing.id);
console.log(html);
thing.unreads(html); thing.unreads(html);
} }
} }
@ -506,7 +499,6 @@ class Localuser {
updatepfp(file) { updatepfp(file) {
var reader = new FileReader(); var reader = new FileReader();
reader.readAsDataURL(file); reader.readAsDataURL(file);
console.log(this.headers);
reader.onload = () => { reader.onload = () => {
fetch(this.info.api.toString() + "/users/@me", { fetch(this.info.api.toString() + "/users/@me", {
method: "PATCH", method: "PATCH",
@ -515,7 +507,6 @@ class Localuser {
avatar: reader.result, avatar: reader.result,
}) })
}); });
console.log(reader.result);
}; };
} }
updatepronouns(pronouns) { updatepronouns(pronouns) {
@ -559,7 +550,6 @@ class Localuser {
else { else {
build += " is typing"; build += " is typing";
} }
console.log(typingtext.classList);
if (showing) { if (showing) {
typingtext.classList.remove("hidden"); typingtext.classList.remove("hidden");
document.getElementById("typingtext").textContent = build; document.getElementById("typingtext").textContent = build;
@ -573,7 +563,7 @@ class Localuser {
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 = this.user.clone();
function regen() { function regen() {
hypotheticalProfile.textContent = ""; hypotheticalProfile.textContent = "";
const hypoprofile = hypouser.buildprofile(-1, -1); const hypoprofile = hypouser.buildprofile(-1, -1);

View file

@ -54,12 +54,11 @@ class Member {
this.user = memberjson; this.user = memberjson;
} }
else { else {
console.log(this.user, memberjson);
if (SnowFlake.getSnowFlakeFromID(this?.id, User)) { if (SnowFlake.getSnowFlakeFromID(this?.id, User)) {
this.user = SnowFlake.getSnowFlakeFromID(this.id, User).getObject(); this.user = SnowFlake.getSnowFlakeFromID(this.id, User).getObject();
return; return;
} }
this.user = new User(this.user, owner.localuser); this.user = new User(membery.user, owner.localuser);
} }
} }
get guild() { get guild() {

View file

@ -62,7 +62,6 @@ class Message {
this.giveData(messagejson); this.giveData(messagejson);
} }
giveData(messagejson) { giveData(messagejson) {
console.log(messagejson);
for (const thing of Object.keys(messagejson)) { for (const thing of Object.keys(messagejson)) {
if (thing === "attachments") { if (thing === "attachments") {
this.attachments = []; this.attachments = [];
@ -83,15 +82,19 @@ class Message {
this.member = new Member(messagejson.member, this.guild); this.member = new Member(messagejson.member, this.guild);
continue; continue;
} }
else if (thing === "embeds") {
this.embeds = [];
for (const thing in messagejson.embeds) {
console.log(thing, messagejson.embeds);
this.embeds[thing] = new Embed(messagejson.embeds[thing], this);
}
continue;
}
this[thing] = messagejson[thing]; this[thing] = messagejson[thing];
} }
for (const thing in this.embeds) { this.author = new User(messagejson.author, this.localuser);
console.log(thing, this.embeds); for (const thing in messagejson.mentions) {
this.embeds[thing] = new Embed(this.embeds[thing], this); this.mentions[thing] = new User(messagejson.mentions[thing], this.localuser);
}
this.author = new User(this.author, this.localuser);
for (const thing in this.mentions) {
this.mentions[thing] = new User(this.mentions[thing], this.localuser);
} }
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(_ => {
@ -311,6 +314,7 @@ class Message {
messagedwrap.appendChild(attach); messagedwrap.appendChild(attach);
} }
if (this.embeds.length) { if (this.embeds.length) {
console.log(this.embeds);
const embeds = document.createElement("div"); const embeds = document.createElement("div");
embeds.classList.add("flexltr"); embeds.classList.add("flexltr");
for (const thing of this.embeds) { for (const thing of this.embeds) {

View file

@ -14,6 +14,31 @@ class User {
discriminator; discriminator;
pronouns; pronouns;
bot; bot;
public_flags;
accent_color;
banner;
premium_since;
premium_type;
theme_colors;
badge_ids;
clone() {
return new User({
username: this.username,
id: this.id + "#clone",
public_flags: this.public_flags,
discriminator: this.discriminator,
avatar: this.avatar,
accent_color: this.accent_color,
banner: this.banner,
bio: this.bio.rawString,
premium_since: this.premium_since,
premium_type: this.premium_type,
bot: this.bot,
theme_colors: this.theme_colors,
pronouns: this.pronouns,
badge_ids: this.badge_ids
}, this.owner);
}
get id() { get id() {
return this.snowflake.id; return this.snowflake.id;
} }
@ -29,13 +54,13 @@ class User {
}); });
}); });
} }
static checkuser(userjson, owner) { static checkuser(user, owner) {
if (User.userids[userjson.id]) { if (User.userids[user.id]) {
return User.userids[userjson.id]; return User.userids[user.id];
} }
else { else {
const tempuser = new User(userjson, owner, true); const tempuser = new User(user, owner, true);
User.userids[userjson.id] = tempuser; User.userids[user.id] = tempuser;
return tempuser; return tempuser;
} }
} }

View file

@ -11,7 +11,6 @@ class Direct extends Guild{
constructor(json:dirrectjson[],owner:Localuser){ constructor(json:dirrectjson[],owner:Localuser){
super(-1,owner,null); super(-1,owner,null);
this.message_notifications=0; this.message_notifications=0;
console.log(json);
this.owner=owner; this.owner=owner;
if(!this.localuser){ if(!this.localuser){
console.error("Owner was not included, please fix") console.error("Owner was not included, please fix")
@ -167,13 +166,11 @@ class Group extends Channel{
const noti=document.createElement("div"); const noti=document.createElement("div");
noti.classList.add("unread","notiunread","pinged"); noti.classList.add("unread","notiunread","pinged");
noti.textContent=""+this.mentions; noti.textContent=""+this.mentions;
console.log(this.mentions)
div["noti"]=noti; div["noti"]=noti;
div.append(noti) div.append(noti)
const buildpfp=this.user.buildpfp(); const buildpfp=this.user.buildpfp();
div["all"]=this; div["all"]=this;
buildpfp.classList.add("mentioned"); buildpfp.classList.add("mentioned");
console.log(this);
div.append(buildpfp) div.append(buildpfp)
sentdms.append(div); sentdms.append(div);
div.onclick=_=>{ div.onclick=_=>{

View file

@ -1,18 +1,18 @@
import {Fullscreen} from "./fullscreen.js"; import {Fullscreen} from "./fullscreen.js";
import {Message} from "./message.js"; import {Message} from "./message.js";
import {MarkDown} from "./markdown.js"; import {MarkDown} from "./markdown.js";
import { embedjson } from "./jsontypes.js";
class Embed{ class Embed{
type:string; type:string;
owner:Message; owner:Message;
json; json:embedjson;
constructor(json, owner:Message){ constructor(json:embedjson, owner:Message){
console.log(json);
this.type=this.getType(json); this.type=this.getType(json);
this.owner=owner; this.owner=owner;
this.json=json; this.json=json;
} }
getType(json){ getType(json:embedjson){
return json.type||"rich"; return json.type||"rich";
} }
generateHTML(){ generateHTML(){
@ -43,7 +43,6 @@ class Embed{
return this.guild.localuser; return this.guild.localuser;
} }
generateRich(){ generateRich(){
console.log(this.json)
const div=document.createElement("div"); const div=document.createElement("div");
if(this.json.color){ if(this.json.color){
div.style.backgroundColor="#"+this.json.color.toString(16); div.style.backgroundColor="#"+this.json.color.toString(16);

View file

@ -1,6 +1,7 @@
import { Message } from "./message.js"; import { Message } from "./message.js";
import { Fullscreen } from "./fullscreen.js"; import { Fullscreen } from "./fullscreen.js";
type filejson= {id:string,filename:string,content_type:string,width:number,height:number,proxy_url:string|undefined,url:string,size:number}; import { filejson } from "./jsontypes.js";
class File{ class File{
owner:Message; owner:Message;
id:string; id:string;
@ -12,7 +13,6 @@ class File{
url:string; url:string;
size:number; size:number;
constructor(fileJSON:filejson,owner:Message){ constructor(fileJSON:filejson,owner:Message){
console.log(fileJSON);
this.owner=owner; this.owner=owner;
this.id=fileJSON.id; this.id=fileJSON.id;
this.filename=fileJSON.filename; this.filename=fileJSON.filename;

View file

@ -267,13 +267,54 @@ type messagejson={
edited_timestamp: string, edited_timestamp: string,
tts: boolean, tts: boolean,
mention_everyone: boolean, mention_everyone: boolean,
mentions: [], mentions: [], //need examples to fix
mention_roles: [], mention_roles: [], //need examples to fix
attachments: [], attachments: filejson[],
embeds: [], embeds: embedjson[],
reactions: [], reactions: [], //ToDo
nonce: string, nonce: string,
pinned: boolean, pinned: boolean,
type: number type: number
} }
export {readyjson,dirrectjson,channeljson,guildjson,rolesjson,userjson,memberjson,mainuserjson,messagejson}; type filejson={
id:string,
filename:string,
content_type:string,
width:number,
height:number,
proxy_url:string|undefined,
url:string,
size:number
};
type embedjson={
type:string|null,
color?:number,
author:{
icon_url?:string,
name?:string,
url?:string,
title?:string,
},
title?:string,
url?:string,
description?:string,
fields?:{
name:string,
value:string,
inline:boolean,
}[],
footer?:{
icon_url?:string,
text?:string,
thumbnail?:string,
},
timestamp?:string,
thumbnail:{
proxy_url:string,
url:string,
},
provider:{
name:string,
}
}
export {readyjson,dirrectjson,channeljson,guildjson,rolesjson,userjson,memberjson,mainuserjson,messagejson,filejson,embedjson};

View file

@ -7,7 +7,7 @@ import {Fullscreen} from "./fullscreen.js";
import {setTheme, Specialuser} from "./login.js"; import {setTheme, Specialuser} from "./login.js";
import { SnowFlake } from "./snowflake.js"; import { SnowFlake } from "./snowflake.js";
import { Message } from "./message.js"; import { Message } from "./message.js";
import { channeljson, readyjson } from "./jsontypes.js"; import { channeljson, readyjson, userjson } from "./jsontypes.js";
const wsCodesRetry=new Set([4000,4003,4005,4007,4008,4009]); const wsCodesRetry=new Set([4000,4003,4005,4007,4008,4009]);
@ -303,7 +303,6 @@ class Localuser{
if(!guild){ if(!guild){
guild=this.guildids.get("@me"); guild=this.guildids.get("@me");
} }
console.log(this.guildids,id,guild);
if(this.lookingguild){ if(this.lookingguild){
this.lookingguild.html.classList.remove("serveropen"); this.lookingguild.html.classList.remove("serveropen");
} }
@ -364,7 +363,6 @@ class Localuser{
div.classList.add("home","servericon") div.classList.add("home","servericon")
serverlist.appendChild(div) serverlist.appendChild(div)
div.onclick=_=>{ div.onclick=_=>{
console.log("clicked :3")
this.createGuild(); this.createGuild();
} }
@ -377,7 +375,6 @@ class Localuser{
}); });
} }
console.log("test");
this.unreads(); this.unreads();
} }
createGuild(){ createGuild(){
@ -391,7 +388,6 @@ class Localuser{
"Invite Link/Code", "Invite Link/Code",
"", "",
function(){ function(){
console.log(this)
inviteurl=this.value; inviteurl=this.value;
} }
], ],
@ -411,7 +407,6 @@ class Localuser{
method:"POST", method:"POST",
headers:this.headers, headers:this.headers,
}).then(r=>r.json()).then(_=>{ }).then(r=>r.json()).then(_=>{
console.log(_);
if(_.message){ if(_.message){
error.textContent=_.message; error.textContent=_.message;
} }
@ -493,11 +488,9 @@ class Localuser{
this.unreads(); this.unreads();
} }
unreads():void{ unreads():void{
console.log(this.guildhtml)
for(const thing of this.guilds){ for(const thing of this.guilds){
if(thing.id==="@me"){continue;} if(thing.id==="@me"){continue;}
const html=this.guildhtml.get(thing.id); const html=this.guildhtml.get(thing.id);
console.log(html);
thing.unreads(html); thing.unreads(html);
} }
} }
@ -533,7 +526,6 @@ class Localuser{
updatepfp(file:Blob):void{ updatepfp(file:Blob):void{
var reader = new FileReader(); var reader = new FileReader();
reader.readAsDataURL(file); reader.readAsDataURL(file);
console.log(this.headers);
reader.onload = ()=>{ reader.onload = ()=>{
fetch(this.info.api.toString()+"/users/@me",{ fetch(this.info.api.toString()+"/users/@me",{
method:"PATCH", method:"PATCH",
@ -542,7 +534,6 @@ class Localuser{
avatar:reader.result, avatar:reader.result,
}) })
}); });
console.log(reader.result);
}; };
} }
@ -586,7 +577,6 @@ class Localuser{
}else{ }else{
build+=" is typing"; build+=" is typing";
} }
console.log(typingtext.classList);
if(showing){ if(showing){
typingtext.classList.remove("hidden"); typingtext.classList.remove("hidden");
document.getElementById("typingtext").textContent=build; document.getElementById("typingtext").textContent=build;
@ -599,7 +589,7 @@ class Localuser{
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=this.user.clone();
function regen(){ function regen(){
hypotheticalProfile.textContent=""; hypotheticalProfile.textContent="";
const hypoprofile=hypouser.buildprofile(-1,-1); const hypoprofile=hypouser.buildprofile(-1,-1);

View file

@ -52,12 +52,11 @@ class Member{
if(error){ if(error){
this.user=memberjson as User; this.user=memberjson as User;
}else{ }else{
console.log(this.user,memberjson);
if(SnowFlake.getSnowFlakeFromID(this?.id,User)){ if(SnowFlake.getSnowFlakeFromID(this?.id,User)){
this.user=SnowFlake.getSnowFlakeFromID(this.id,User).getObject(); this.user=SnowFlake.getSnowFlakeFromID(this.id,User).getObject();
return; return;
} }
this.user=new User(this.user,owner.localuser); this.user=new User((membery as memberjson).user,owner.localuser);
} }
} }
get guild(){ get guild(){

View file

@ -68,7 +68,6 @@ class Message{
} }
giveData(messagejson:messagejson){ giveData(messagejson:messagejson){
console.log(messagejson);
for(const thing of Object.keys(messagejson)){ for(const thing of Object.keys(messagejson)){
if(thing==="attachments"){ if(thing==="attachments"){
this.attachments=[]; this.attachments=[];
@ -85,17 +84,21 @@ class Message{
}else if(thing==="member"){ }else if(thing==="member"){
this.member=new Member(messagejson.member,this.guild); this.member=new Member(messagejson.member,this.guild);
continue; continue;
}else if(thing ==="embeds"){
this.embeds=[];
for(const thing in messagejson.embeds){
console.log(thing,messagejson.embeds)
this.embeds[thing]=new Embed(messagejson.embeds[thing],this);
}
continue;
} }
this[thing]=messagejson[thing]; this[thing]=messagejson[thing];
} }
for(const thing in this.embeds){
console.log(thing,this.embeds) this.author=new User(messagejson.author,this.localuser);
this.embeds[thing]=new Embed(this.embeds[thing],this); for(const thing in messagejson.mentions){
} this.mentions[thing]=new User(messagejson.mentions[thing],this.localuser);
this.author=new User(this.author,this.localuser);
for(const thing in this.mentions){
this.mentions[thing]=new User(this.mentions[thing],this.localuser);
} }
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(_=>{
@ -316,6 +319,7 @@ class Message{
messagedwrap.appendChild(attach) messagedwrap.appendChild(attach)
} }
if(this.embeds.length){ if(this.embeds.length){
console.log(this.embeds);
const embeds = document.createElement("div") const embeds = document.createElement("div")
embeds.classList.add("flexltr"); embeds.classList.add("flexltr");
for(const thing of this.embeds){ for(const thing of this.embeds){

View file

@ -83,7 +83,7 @@ th {
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: column; flex-direction: column;
max-height: 20in; max-height: 20in;
padding: .02in .2in 0 .1in; padding: .02in .1in 0 .1in;
flex-shrink: 0; flex-shrink: 0;
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;

View file

@ -5,6 +5,7 @@ import {Contextmenu} from "./contextmenu.js";
import {Localuser} from "./localuser.js"; import {Localuser} from "./localuser.js";
import {Guild} from "./guild.js"; import {Guild} from "./guild.js";
import { SnowFlake } from "./snowflake.js"; import { SnowFlake } from "./snowflake.js";
import { userjson } from "./jsontypes.js";
class User{ class User{
static userids={}; static userids={};
@ -17,6 +18,31 @@ class User{
discriminator:string; discriminator:string;
pronouns:string; pronouns:string;
bot:boolean; bot:boolean;
public_flags: number;
accent_color: string;
banner: string;
premium_since: string;
premium_type: number;
theme_colors: string;
badge_ids: string;
clone(){
return new User({
username:this.username,
id:this.id+"#clone",
public_flags:this.public_flags,
discriminator:this.discriminator,
avatar:this.avatar,
accent_color:this.accent_color,
banner:this.banner,
bio:this.bio.rawString,
premium_since:this.premium_since,
premium_type:this.premium_type,
bot:this.bot,
theme_colors:this.theme_colors,
pronouns:this.pronouns,
badge_ids:this.badge_ids
},this.owner)
}
get id(){ get id(){
return this.snowflake.id; return this.snowflake.id;
} }
@ -33,12 +59,12 @@ class User{
}); });
}) })
} }
static checkuser(userjson,owner:Localuser){ static checkuser(user:User|userjson,owner:Localuser):User{
if(User.userids[userjson.id]){ if(User.userids[user.id]){
return User.userids[userjson.id]; return User.userids[user.id];
}else{ }else{
const tempuser=new User(userjson,owner,true) const tempuser=new User(user as userjson,owner,true)
User.userids[userjson.id]=tempuser; User.userids[user.id]=tempuser;
return tempuser; return tempuser;
} }
} }
@ -48,7 +74,7 @@ class User{
get localuser(){ get localuser(){
return this.owner; return this.owner;
} }
constructor(userjson,owner:Localuser,dontclone=false){ constructor(userjson:userjson,owner:Localuser,dontclone=false){
this.owner=owner; this.owner=owner;
if(!owner){console.error("missing localuser")} if(!owner){console.error("missing localuser")}
if(dontclone){ if(dontclone){
@ -78,7 +104,7 @@ class User{
pfp.classList.add("userid:"+this.id); pfp.classList.add("userid:"+this.id);
return pfp; return pfp;
} }
userupdate(json){ userupdate(json:userjson){
if(json.avatar!==this.avatar){ if(json.avatar!==this.avatar){
console.log console.log
this.changepfp(json.avatar); this.changepfp(json.avatar);