Merge pull request #37 from DEVTomatoCake/jank/fix-JSON-json

JSON -> json
This commit is contained in:
MathMan05 2024-07-25 11:24:46 -05:00 committed by GitHub
commit 90a234df18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 62 additions and 62 deletions

View file

@ -119,36 +119,36 @@ class Channel{
this.readbottom.bind(this)
);
}
constructor(JSON,owner:Guild){
constructor(json,owner:Guild){
if(JSON===-1){
if(json===-1){
return;
}
this.editing;
this.type=JSON.type;
this.type=json.type;
this.owner=owner;
this.headers=this.owner.headers;
this.name=JSON.name;
this.snowflake=new SnowFlake(JSON.id,this);
this.parent_id=new SnowFlake(JSON.parent_id,undefined);
this.name=json.name;
this.snowflake=new SnowFlake(json.id,this);
this.parent_id=new SnowFlake(json.parent_id,undefined);
this.parent=null;
this.children=[];
this.guild_id=JSON.guild_id;
this.guild_id=json.guild_id;
this.messageids=new Map();
this.permission_overwrites=new Map();
this.permission_overwritesar=[];
for(const thing of JSON.permission_overwrites){
for(const thing of json.permission_overwrites){
if(thing.id==="1182819038095799904"||thing.id==="1182820803700625444"){continue;};
this.permission_overwrites.set(thing.id,new Permissions(thing.allow,thing.deny));
this.permission_overwritesar.push([thing.id,this.permission_overwrites.get(thing.id)]);
}
this.topic=JSON.topic;
this.nsfw=JSON.nsfw;
this.position=JSON.position;
this.topic=json.topic;
this.nsfw=json.nsfw;
this.position=json.position;
this.lastreadmessageid=null;
this.lastmessageid=SnowFlake.getSnowFlakeFromID(JSON.last_message_id,Message);
this.lastmessageid=SnowFlake.getSnowFlakeFromID(json.last_message_id,Message);
this.setUpInfiniteScroller();
}
isAdmin(){
@ -572,10 +572,10 @@ class Channel{
}
}
}
delChannel(JSON){
delChannel(json){
const build=[];
for(const thing of this.children){
if(thing.snowflake!==JSON.id){
if(thing.snowflake!==json.id){
build.push(thing)
}
}
@ -649,22 +649,22 @@ class Channel{
}
return id;
}
updateChannel(JSON){
this.type=JSON.type;
this.name=JSON.name;
this.parent_id=new SnowFlake(JSON.parent_id,undefined);
updateChannel(json){
this.type=json.type;
this.name=json.name;
this.parent_id=new SnowFlake(json.parent_id,undefined);
this.parent=null;
this.children=[];
this.guild_id=JSON.guild_id;
this.guild_id=json.guild_id;
this.messageids=new Map();
this.permission_overwrites=new Map();
for(const thing of JSON.permission_overwrites){
for(const thing of json.permission_overwrites){
if(thing.id==="1182819038095799904"||thing.id==="1182820803700625444"){continue;};
this.permission_overwrites.set(thing.id,new Permissions(thing.allow,thing.deny));
this.permission_overwritesar.push([thing.id,this.permission_overwrites.get(thing.id)]);
}
this.topic=JSON.topic;
this.nsfw=JSON.nsfw;
this.topic=json.topic;
this.nsfw=json.nsfw;
}
typingstart(){
if(this.typing>new Date().getTime()){

View file

@ -7,10 +7,10 @@ import { Member } from "./member.js";
import { SnowFlake } from "./snowflake.js";
class Direct extends Guild{
constructor(JSON,owner:Localuser){
constructor(json,owner:Localuser){
super(-1,owner,null);
this.message_notifications=0;
console.log(JSON);
console.log(json);
this.owner=owner;
if(!this.localuser){
console.error("Owner was not included, please fix")
@ -24,16 +24,16 @@ class Direct extends Guild{
this.roleids=new Map();
this.prevchannel=undefined;
this.properties.name="Direct Messages";
for(const thing of JSON){
for(const thing of json){
const temp=new Group(thing,this);
this.channels.push(temp);
this.channelids[temp.id]=temp;
}
this.headchannels=this.channels;
}
createChannelpac(JSON){
const thischannel=new Group(JSON,this);
this.channelids[JSON.id]=thischannel;
createChannelpac(json){
const thischannel=new Group(json,this);
this.channelids[json.id]=thischannel;
this.channels.push(thischannel);
this.calculateReorder();
this.printServers();
@ -64,25 +64,25 @@ class Direct extends Guild{
}
class Group extends Channel{
user:User;
constructor(JSON,owner:Direct){
constructor(json,owner:Direct){
super(-1,owner);
this.owner=owner;
this.headers=this.guild.headers;
this.name=JSON.recipients[0]?.username;
if(JSON.recipients[0]){
this.user=new User(JSON.recipients[0],this.localuser);
this.name=json.recipients[0]?.username;
if(json.recipients[0]){
this.user=new User(json.recipients[0],this.localuser);
}else{
this.user=this.localuser.user;
}
this.name??=this.localuser.user.username;
this.snowflake=new SnowFlake(JSON.id,this);
this.snowflake=new SnowFlake(json.id,this);
this.parent_id=null;
this.parent=null;
this.children=[];
this.guild_id="@me";
this.messageids=new Map();
this.permission_overwrites=new Map();
this.lastmessageid=SnowFlake.getSnowFlakeFromID(JSON.last_message_id,Message);
this.lastmessageid=SnowFlake.getSnowFlakeFromID(json.last_message_id,Message);
this.lastmessageid??=new SnowFlake("0",undefined);
this.mentions=0;
this.setUpInfiniteScroller();

View file

@ -404,8 +404,8 @@ class Guild{
loadGuild(){
this.localuser.loadGuild(this.id);
}
updateChannel(JSON){
SnowFlake.getSnowFlakeFromID(JSON.id,Channel).getObject().updateChannel(JSON);
updateChannel(json){
SnowFlake.getSnowFlakeFromID(json.id,Channel).getObject().updateChannel(json);
this.headchannels=[];
for(const thing of this.channels){
thing.children=[];
@ -417,9 +417,9 @@ class Guild{
}
this.printServers();
}
createChannelpac(JSON){
const thischannel=new Channel(JSON,this);
this.channelids[JSON.id]=thischannel;
createChannelpac(json){
const thischannel=new Channel(json,this);
this.channelids[json.id]=thischannel;
this.channels.push(thischannel);
thischannel.resolveparent(this);
if(!thischannel.parent){
@ -470,9 +470,9 @@ class Guild{
]);
channelselect.show();
}
delChannel(JSON){
const channel=this.channelids[JSON.id];
delete this.channelids[JSON.id];
delChannel(json){
const channel=this.channelids[json.id];
delete this.channelids[json.id];
this.channels.splice(this.channels.indexOf(channel),1);
const indexy=this.headchannels.indexOf(channel);
@ -489,7 +489,7 @@ class Guild{
}else{
console.log("fail");
if(thing.parent){
thing.parent.delChannel(JSON);
thing.parent.delChannel(json);
}
}
}

View file

@ -261,25 +261,25 @@ class Localuser{
}
return undefined;
}
updateChannel(JSON):void{
SnowFlake.getSnowFlakeFromID(JSON.guild_id,Guild).getObject().updateChannel(JSON);
if(JSON.guild_id===this.lookingguild.id){
this.loadGuild(JSON.guild_id);
updateChannel(json):void{
SnowFlake.getSnowFlakeFromID(json.guild_id,Guild).getObject().updateChannel(json);
if(json.guild_id===this.lookingguild.id){
this.loadGuild(json.guild_id);
}
}
createChannel(JSON):void{
JSON.guild_id??="@me";
SnowFlake.getSnowFlakeFromID(JSON.guild_id,Guild).getObject().createChannelpac(JSON);
if(JSON.guild_id===this.lookingguild.id){
this.loadGuild(JSON.guild_id);
createChannel(json):void{
json.guild_id??="@me";
SnowFlake.getSnowFlakeFromID(json.guild_id,Guild).getObject().createChannelpac(json);
if(json.guild_id===this.lookingguild.id){
this.loadGuild(json.guild_id);
}
}
delChannel(JSON):void{
JSON.guild_id??="@me";
this.guildids.get(JSON.guild_id).delChannel(JSON);
delChannel(json):void{
json.guild_id??="@me";
this.guildids.get(json.guild_id).delChannel(json);
if(JSON.guild_id===this.lookingguild.snowflake){
this.loadGuild(JSON.guild_id);
if(json.guild_id===this.lookingguild.snowflake){
this.loadGuild(json.guild_id);
}
}
init():void{

View file

@ -18,17 +18,17 @@ class Role{
get id(){
return this.snowflake.id;
}
constructor(JSON, owner:Guild){
constructor(json, owner:Guild){
this.headers=owner.headers;
this.info=owner.info;
for(const thing of Object.keys(JSON)){
for(const thing of Object.keys(json)){
if(thing==="id"){
this.snowflake=new SnowFlake(JSON.id,this);
this.snowflake=new SnowFlake(json.id,this);
continue;
}
this[thing]=JSON[thing];
this[thing]=json[thing];
}
this.permissions=new Permissions(JSON.permissions);
this.permissions=new Permissions(json.permissions);
this.owner=owner;
}
get guild():Guild{