JSON -> json
This commit is contained in:
parent
72ddec2fa0
commit
883430f038
5 changed files with 62 additions and 62 deletions
|
@ -119,36 +119,36 @@ class Channel{
|
||||||
this.readbottom.bind(this)
|
this.readbottom.bind(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
constructor(JSON,owner:Guild){
|
constructor(json,owner:Guild){
|
||||||
|
|
||||||
if(JSON===-1){
|
if(json===-1){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.editing;
|
this.editing;
|
||||||
this.type=JSON.type;
|
this.type=json.type;
|
||||||
this.owner=owner;
|
this.owner=owner;
|
||||||
this.headers=this.owner.headers;
|
this.headers=this.owner.headers;
|
||||||
this.name=JSON.name;
|
this.name=json.name;
|
||||||
this.snowflake=new SnowFlake(JSON.id,this);
|
this.snowflake=new SnowFlake(json.id,this);
|
||||||
this.parent_id=new SnowFlake(JSON.parent_id,undefined);
|
this.parent_id=new SnowFlake(json.parent_id,undefined);
|
||||||
this.parent=null;
|
this.parent=null;
|
||||||
this.children=[];
|
this.children=[];
|
||||||
this.guild_id=JSON.guild_id;
|
this.guild_id=json.guild_id;
|
||||||
this.messageids=new Map();
|
this.messageids=new Map();
|
||||||
this.permission_overwrites=new Map();
|
this.permission_overwrites=new Map();
|
||||||
this.permission_overwritesar=[];
|
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;};
|
if(thing.id==="1182819038095799904"||thing.id==="1182820803700625444"){continue;};
|
||||||
this.permission_overwrites.set(thing.id,new Permissions(thing.allow,thing.deny));
|
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.permission_overwritesar.push([thing.id,this.permission_overwrites.get(thing.id)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.topic=JSON.topic;
|
this.topic=json.topic;
|
||||||
this.nsfw=JSON.nsfw;
|
this.nsfw=json.nsfw;
|
||||||
this.position=JSON.position;
|
this.position=json.position;
|
||||||
this.lastreadmessageid=null;
|
this.lastreadmessageid=null;
|
||||||
this.lastmessageid=SnowFlake.getSnowFlakeFromID(JSON.last_message_id,Message);
|
this.lastmessageid=SnowFlake.getSnowFlakeFromID(json.last_message_id,Message);
|
||||||
this.setUpInfiniteScroller();
|
this.setUpInfiniteScroller();
|
||||||
}
|
}
|
||||||
isAdmin(){
|
isAdmin(){
|
||||||
|
@ -572,10 +572,10 @@ class Channel{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delChannel(JSON){
|
delChannel(json){
|
||||||
const build=[];
|
const build=[];
|
||||||
for(const thing of this.children){
|
for(const thing of this.children){
|
||||||
if(thing.snowflake!==JSON.id){
|
if(thing.snowflake!==json.id){
|
||||||
build.push(thing)
|
build.push(thing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -649,22 +649,22 @@ class Channel{
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
updateChannel(JSON){
|
updateChannel(json){
|
||||||
this.type=JSON.type;
|
this.type=json.type;
|
||||||
this.name=JSON.name;
|
this.name=json.name;
|
||||||
this.parent_id=new SnowFlake(JSON.parent_id,undefined);
|
this.parent_id=new SnowFlake(json.parent_id,undefined);
|
||||||
this.parent=null;
|
this.parent=null;
|
||||||
this.children=[];
|
this.children=[];
|
||||||
this.guild_id=JSON.guild_id;
|
this.guild_id=json.guild_id;
|
||||||
this.messageids=new Map();
|
this.messageids=new Map();
|
||||||
this.permission_overwrites=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;};
|
if(thing.id==="1182819038095799904"||thing.id==="1182820803700625444"){continue;};
|
||||||
this.permission_overwrites.set(thing.id,new Permissions(thing.allow,thing.deny));
|
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.permission_overwritesar.push([thing.id,this.permission_overwrites.get(thing.id)]);
|
||||||
}
|
}
|
||||||
this.topic=JSON.topic;
|
this.topic=json.topic;
|
||||||
this.nsfw=JSON.nsfw;
|
this.nsfw=json.nsfw;
|
||||||
}
|
}
|
||||||
typingstart(){
|
typingstart(){
|
||||||
if(this.typing>new Date().getTime()){
|
if(this.typing>new Date().getTime()){
|
||||||
|
|
|
@ -7,10 +7,10 @@ import { Member } from "./member.js";
|
||||||
import { SnowFlake } from "./snowflake.js";
|
import { SnowFlake } from "./snowflake.js";
|
||||||
|
|
||||||
class Direct extends Guild{
|
class Direct extends Guild{
|
||||||
constructor(JSON,owner:Localuser){
|
constructor(json,owner:Localuser){
|
||||||
super(-1,owner,null);
|
super(-1,owner,null);
|
||||||
this.message_notifications=0;
|
this.message_notifications=0;
|
||||||
console.log(JSON);
|
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")
|
||||||
|
@ -24,16 +24,16 @@ class Direct extends Guild{
|
||||||
this.roleids=new Map();
|
this.roleids=new Map();
|
||||||
this.prevchannel=undefined;
|
this.prevchannel=undefined;
|
||||||
this.properties.name="Direct Messages";
|
this.properties.name="Direct Messages";
|
||||||
for(const thing of JSON){
|
for(const thing of json){
|
||||||
const temp=new Group(thing,this);
|
const temp=new Group(thing,this);
|
||||||
this.channels.push(temp);
|
this.channels.push(temp);
|
||||||
this.channelids[temp.id]=temp;
|
this.channelids[temp.id]=temp;
|
||||||
}
|
}
|
||||||
this.headchannels=this.channels;
|
this.headchannels=this.channels;
|
||||||
}
|
}
|
||||||
createChannelpac(JSON){
|
createChannelpac(json){
|
||||||
const thischannel=new Group(JSON,this);
|
const thischannel=new Group(json,this);
|
||||||
this.channelids[JSON.id]=thischannel;
|
this.channelids[json.id]=thischannel;
|
||||||
this.channels.push(thischannel);
|
this.channels.push(thischannel);
|
||||||
this.calculateReorder();
|
this.calculateReorder();
|
||||||
this.printServers();
|
this.printServers();
|
||||||
|
@ -64,25 +64,25 @@ class Direct extends Guild{
|
||||||
}
|
}
|
||||||
class Group extends Channel{
|
class Group extends Channel{
|
||||||
user:User;
|
user:User;
|
||||||
constructor(JSON,owner:Direct){
|
constructor(json,owner:Direct){
|
||||||
super(-1,owner);
|
super(-1,owner);
|
||||||
this.owner=owner;
|
this.owner=owner;
|
||||||
this.headers=this.guild.headers;
|
this.headers=this.guild.headers;
|
||||||
this.name=JSON.recipients[0]?.username;
|
this.name=json.recipients[0]?.username;
|
||||||
if(JSON.recipients[0]){
|
if(json.recipients[0]){
|
||||||
this.user=new User(JSON.recipients[0],this.localuser);
|
this.user=new User(json.recipients[0],this.localuser);
|
||||||
}else{
|
}else{
|
||||||
this.user=this.localuser.user;
|
this.user=this.localuser.user;
|
||||||
}
|
}
|
||||||
this.name??=this.localuser.user.username;
|
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_id=null;
|
||||||
this.parent=null;
|
this.parent=null;
|
||||||
this.children=[];
|
this.children=[];
|
||||||
this.guild_id="@me";
|
this.guild_id="@me";
|
||||||
this.messageids=new Map();
|
this.messageids=new Map();
|
||||||
this.permission_overwrites=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.lastmessageid??=new SnowFlake("0",undefined);
|
||||||
this.mentions=0;
|
this.mentions=0;
|
||||||
this.setUpInfiniteScroller();
|
this.setUpInfiniteScroller();
|
||||||
|
|
|
@ -404,8 +404,8 @@ class Guild{
|
||||||
loadGuild(){
|
loadGuild(){
|
||||||
this.localuser.loadGuild(this.id);
|
this.localuser.loadGuild(this.id);
|
||||||
}
|
}
|
||||||
updateChannel(JSON){
|
updateChannel(json){
|
||||||
SnowFlake.getSnowFlakeFromID(JSON.id,Channel).getObject().updateChannel(JSON);
|
SnowFlake.getSnowFlakeFromID(json.id,Channel).getObject().updateChannel(json);
|
||||||
this.headchannels=[];
|
this.headchannels=[];
|
||||||
for(const thing of this.channels){
|
for(const thing of this.channels){
|
||||||
thing.children=[];
|
thing.children=[];
|
||||||
|
@ -417,9 +417,9 @@ class Guild{
|
||||||
}
|
}
|
||||||
this.printServers();
|
this.printServers();
|
||||||
}
|
}
|
||||||
createChannelpac(JSON){
|
createChannelpac(json){
|
||||||
const thischannel=new Channel(JSON,this);
|
const thischannel=new Channel(json,this);
|
||||||
this.channelids[JSON.id]=thischannel;
|
this.channelids[json.id]=thischannel;
|
||||||
this.channels.push(thischannel);
|
this.channels.push(thischannel);
|
||||||
thischannel.resolveparent(this);
|
thischannel.resolveparent(this);
|
||||||
if(!thischannel.parent){
|
if(!thischannel.parent){
|
||||||
|
@ -470,9 +470,9 @@ class Guild{
|
||||||
]);
|
]);
|
||||||
channelselect.show();
|
channelselect.show();
|
||||||
}
|
}
|
||||||
delChannel(JSON){
|
delChannel(json){
|
||||||
const channel=this.channelids[JSON.id];
|
const channel=this.channelids[json.id];
|
||||||
delete this.channelids[JSON.id];
|
delete this.channelids[json.id];
|
||||||
|
|
||||||
this.channels.splice(this.channels.indexOf(channel),1);
|
this.channels.splice(this.channels.indexOf(channel),1);
|
||||||
const indexy=this.headchannels.indexOf(channel);
|
const indexy=this.headchannels.indexOf(channel);
|
||||||
|
@ -489,7 +489,7 @@ class Guild{
|
||||||
}else{
|
}else{
|
||||||
console.log("fail");
|
console.log("fail");
|
||||||
if(thing.parent){
|
if(thing.parent){
|
||||||
thing.parent.delChannel(JSON);
|
thing.parent.delChannel(json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,25 +261,25 @@ class Localuser{
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
updateChannel(JSON):void{
|
updateChannel(json):void{
|
||||||
SnowFlake.getSnowFlakeFromID(JSON.guild_id,Guild).getObject().updateChannel(JSON);
|
SnowFlake.getSnowFlakeFromID(json.guild_id,Guild).getObject().updateChannel(json);
|
||||||
if(JSON.guild_id===this.lookingguild.id){
|
if(json.guild_id===this.lookingguild.id){
|
||||||
this.loadGuild(JSON.guild_id);
|
this.loadGuild(json.guild_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
createChannel(JSON):void{
|
createChannel(json):void{
|
||||||
JSON.guild_id??="@me";
|
json.guild_id??="@me";
|
||||||
SnowFlake.getSnowFlakeFromID(JSON.guild_id,Guild).getObject().createChannelpac(JSON);
|
SnowFlake.getSnowFlakeFromID(json.guild_id,Guild).getObject().createChannelpac(json);
|
||||||
if(JSON.guild_id===this.lookingguild.id){
|
if(json.guild_id===this.lookingguild.id){
|
||||||
this.loadGuild(JSON.guild_id);
|
this.loadGuild(json.guild_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delChannel(JSON):void{
|
delChannel(json):void{
|
||||||
JSON.guild_id??="@me";
|
json.guild_id??="@me";
|
||||||
this.guildids.get(JSON.guild_id).delChannel(JSON);
|
this.guildids.get(json.guild_id).delChannel(json);
|
||||||
|
|
||||||
if(JSON.guild_id===this.lookingguild.snowflake){
|
if(json.guild_id===this.lookingguild.snowflake){
|
||||||
this.loadGuild(JSON.guild_id);
|
this.loadGuild(json.guild_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
init():void{
|
init():void{
|
||||||
|
|
|
@ -18,17 +18,17 @@ class Role{
|
||||||
get id(){
|
get id(){
|
||||||
return this.snowflake.id;
|
return this.snowflake.id;
|
||||||
}
|
}
|
||||||
constructor(JSON, owner:Guild){
|
constructor(json, owner:Guild){
|
||||||
this.headers=owner.headers;
|
this.headers=owner.headers;
|
||||||
this.info=owner.info;
|
this.info=owner.info;
|
||||||
for(const thing of Object.keys(JSON)){
|
for(const thing of Object.keys(json)){
|
||||||
if(thing==="id"){
|
if(thing==="id"){
|
||||||
this.snowflake=new SnowFlake(JSON.id,this);
|
this.snowflake=new SnowFlake(json.id,this);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this[thing]=JSON[thing];
|
this[thing]=json[thing];
|
||||||
}
|
}
|
||||||
this.permissions=new Permissions(JSON.permissions);
|
this.permissions=new Permissions(json.permissions);
|
||||||
this.owner=owner;
|
this.owner=owner;
|
||||||
}
|
}
|
||||||
get guild():Guild{
|
get guild():Guild{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue