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

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

View file

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

View file

@ -1,6 +1,7 @@
import { Message } from "./message.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{
owner:Message;
id:string;
@ -12,7 +13,6 @@ class File{
url:string;
size:number;
constructor(fileJSON:filejson,owner:Message){
console.log(fileJSON);
this.owner=owner;
this.id=fileJSON.id;
this.filename=fileJSON.filename;

View file

@ -267,13 +267,54 @@ type messagejson={
edited_timestamp: string,
tts: boolean,
mention_everyone: boolean,
mentions: [],
mention_roles: [],
attachments: [],
embeds: [],
reactions: [],
mentions: [], //need examples to fix
mention_roles: [], //need examples to fix
attachments: filejson[],
embeds: embedjson[],
reactions: [], //ToDo
nonce: string,
pinned: boolean,
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 { SnowFlake } from "./snowflake.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]);
@ -303,7 +303,6 @@ class Localuser{
if(!guild){
guild=this.guildids.get("@me");
}
console.log(this.guildids,id,guild);
if(this.lookingguild){
this.lookingguild.html.classList.remove("serveropen");
}
@ -364,7 +363,6 @@ class Localuser{
div.classList.add("home","servericon")
serverlist.appendChild(div)
div.onclick=_=>{
console.log("clicked :3")
this.createGuild();
}
@ -377,7 +375,6 @@ class Localuser{
});
}
console.log("test");
this.unreads();
}
createGuild(){
@ -391,7 +388,6 @@ class Localuser{
"Invite Link/Code",
"",
function(){
console.log(this)
inviteurl=this.value;
}
],
@ -411,7 +407,6 @@ class Localuser{
method:"POST",
headers:this.headers,
}).then(r=>r.json()).then(_=>{
console.log(_);
if(_.message){
error.textContent=_.message;
}
@ -493,11 +488,9 @@ class Localuser{
this.unreads();
}
unreads():void{
console.log(this.guildhtml)
for(const thing of this.guilds){
if(thing.id==="@me"){continue;}
const html=this.guildhtml.get(thing.id);
console.log(html);
thing.unreads(html);
}
}
@ -533,7 +526,6 @@ class Localuser{
updatepfp(file:Blob):void{
var reader = new FileReader();
reader.readAsDataURL(file);
console.log(this.headers);
reader.onload = ()=>{
fetch(this.info.api.toString()+"/users/@me",{
method:"PATCH",
@ -542,7 +534,6 @@ class Localuser{
avatar:reader.result,
})
});
console.log(reader.result);
};
}
@ -586,7 +577,6 @@ class Localuser{
}else{
build+=" is typing";
}
console.log(typingtext.classList);
if(showing){
typingtext.classList.remove("hidden");
document.getElementById("typingtext").textContent=build;
@ -599,7 +589,7 @@ class Localuser{
let file=null;
let newprouns=null;
let newbio=null;
let hypouser=new User(this.user,this,true);
let hypouser=this.user.clone();
function regen(){
hypotheticalProfile.textContent="";
const hypoprofile=hypouser.buildprofile(-1,-1);

View file

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

View file

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

View file

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

View file

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