typing out a lot of the JSON
This commit is contained in:
parent
514f81ee8b
commit
58b79be7f2
19 changed files with 359 additions and 44 deletions
|
@ -5,6 +5,7 @@ import { Contextmenu } from "./contextmenu.js";
|
||||||
import { Fullscreen } from "./fullscreen.js";
|
import { Fullscreen } from "./fullscreen.js";
|
||||||
import { Permissions } from "./permissions.js";
|
import { Permissions } from "./permissions.js";
|
||||||
import { Settings, RoleList } from "./settings.js";
|
import { Settings, RoleList } from "./settings.js";
|
||||||
|
import { Role } from "./role.js";
|
||||||
import { InfiniteScroller } from "./infiniteScroller.js";
|
import { InfiniteScroller } from "./infiniteScroller.js";
|
||||||
import { SnowFlake } from "./snowflake.js";
|
import { SnowFlake } from "./snowflake.js";
|
||||||
class Channel {
|
class Channel {
|
||||||
|
@ -125,7 +126,7 @@ class Channel {
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
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([SnowFlake.getSnowFlakeFromID(thing.id, Role), this.permission_overwrites.get(thing.id)]);
|
||||||
}
|
}
|
||||||
this.topic = json.topic;
|
this.topic = json.topic;
|
||||||
this.nsfw = json.nsfw;
|
this.nsfw = json.nsfw;
|
||||||
|
@ -566,7 +567,7 @@ 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.id !== json.id) {
|
||||||
build.push(thing);
|
build.push(thing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -659,7 +660,7 @@ class Channel {
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
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([SnowFlake.getSnowFlakeFromID(thing.id, Role), this.permission_overwrites.get(thing.id)]);
|
||||||
}
|
}
|
||||||
this.topic = json.topic;
|
this.topic = json.topic;
|
||||||
this.nsfw = json.nsfw;
|
this.nsfw = json.nsfw;
|
||||||
|
|
|
@ -41,7 +41,7 @@ class Direct extends Guild {
|
||||||
return Number(-result);
|
return Number(-result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
giveMember(member) {
|
giveMember(_member) {
|
||||||
console.error("not a real guild, can't give member object");
|
console.error("not a real guild, can't give member object");
|
||||||
}
|
}
|
||||||
getRole(ID) {
|
getRole(ID) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ 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;
|
||||||
|
|
1
.dist/jsontypes.js
Normal file
1
.dist/jsontypes.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export {};
|
|
@ -114,7 +114,7 @@ class Localuser {
|
||||||
"capabilities": 16381,
|
"capabilities": 16381,
|
||||||
"properties": {
|
"properties": {
|
||||||
"browser": "Jank Client",
|
"browser": "Jank Client",
|
||||||
"client_build_number": 0,
|
"client_build_number": 0, //might update this eventually lol
|
||||||
"release_channel": "Custom",
|
"release_channel": "Custom",
|
||||||
"browser_user_agent": navigator.userAgent
|
"browser_user_agent": navigator.userAgent
|
||||||
},
|
},
|
||||||
|
@ -262,7 +262,7 @@ class Localuser {
|
||||||
delChannel(json) {
|
delChannel(json) {
|
||||||
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.id) {
|
||||||
this.loadGuild(json.guild_id);
|
this.loadGuild(json.guild_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,13 @@ class Member {
|
||||||
let membery = memberjson;
|
let membery = memberjson;
|
||||||
this.roles = [];
|
this.roles = [];
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (memberjson.guild_member) {
|
if (memberjson["guild_member"]) {
|
||||||
|
memberjson = memberjson;
|
||||||
membery = memberjson.guild_member;
|
membery = memberjson.guild_member;
|
||||||
this.user = memberjson.user;
|
this.user = new User(memberjson.user, this.localuser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
membery = membery;
|
||||||
for (const thing of Object.keys(membery)) {
|
for (const thing of Object.keys(membery)) {
|
||||||
if (thing === "guild") {
|
if (thing === "guild") {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -22,6 +22,7 @@ class Message {
|
||||||
static del;
|
static del;
|
||||||
static resolve;
|
static resolve;
|
||||||
div;
|
div;
|
||||||
|
member;
|
||||||
get id() {
|
get id() {
|
||||||
return this.snowflake.id;
|
return this.snowflake.id;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +62,7 @@ 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 = [];
|
||||||
|
@ -77,6 +79,10 @@ class Message {
|
||||||
this.snowflake = new SnowFlake(messagejson.id, this);
|
this.snowflake = new SnowFlake(messagejson.id, this);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (thing === "member") {
|
||||||
|
this.member = new Member(messagejson.member, this.guild);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
this[thing] = messagejson[thing];
|
this[thing] = messagejson[thing];
|
||||||
}
|
}
|
||||||
for (const thing in this.embeds) {
|
for (const thing in this.embeds) {
|
||||||
|
@ -87,6 +93,11 @@ class Message {
|
||||||
for (const thing in this.mentions) {
|
for (const thing in this.mentions) {
|
||||||
this.mentions[thing] = new User(this.mentions[thing], this.localuser);
|
this.mentions[thing] = new User(this.mentions[thing], this.localuser);
|
||||||
}
|
}
|
||||||
|
if (!this.member && this.guild.id !== "@me") {
|
||||||
|
this.author.resolvemember(this.guild).then(_ => {
|
||||||
|
this.member = _;
|
||||||
|
});
|
||||||
|
}
|
||||||
if (this.mentions.length || this.mention_roles.length) { //currently mention_roles isn't implemented on the spacebar servers
|
if (this.mentions.length || this.mention_roles.length) { //currently mention_roles isn't implemented on the spacebar servers
|
||||||
console.log(this.mentions, this.mention_roles);
|
console.log(this.mentions, this.mention_roles);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ class User {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async resolvemember(guild) {
|
async resolvemember(guild) {
|
||||||
await Member.resolve(this, guild);
|
return await Member.resolve(this, guild);
|
||||||
}
|
}
|
||||||
buildpfp() {
|
buildpfp() {
|
||||||
const pfp = document.createElement('img');
|
const pfp = document.createElement('img');
|
||||||
|
|
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -9,7 +9,7 @@
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "latest"
|
"express": "^4.19.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.7.0",
|
"@eslint/js": "^9.7.0",
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { Settings, RoleList } from "./settings.js";
|
||||||
import { Role } from "./role.js";
|
import { Role } from "./role.js";
|
||||||
import {InfiniteScroller} from "./infiniteScroller.js";
|
import {InfiniteScroller} from "./infiniteScroller.js";
|
||||||
import { SnowFlake } from "./snowflake.js";
|
import { SnowFlake } from "./snowflake.js";
|
||||||
|
import { channeljson, readyjson } from "./jsontypes.js";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface NotificationOptions {
|
interface NotificationOptions {
|
||||||
|
@ -119,12 +120,11 @@ class Channel{
|
||||||
this.readbottom.bind(this)
|
this.readbottom.bind(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
constructor(json,owner:Guild){
|
constructor(json:channeljson|-1,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;
|
||||||
|
@ -141,7 +141,7 @@ class Channel{
|
||||||
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([SnowFlake.getSnowFlakeFromID(thing.id,Role),this.permission_overwrites.get(thing.id)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.topic=json.topic;
|
this.topic=json.topic;
|
||||||
|
@ -163,7 +163,7 @@ class Channel{
|
||||||
get info(){
|
get info(){
|
||||||
return this.owner.info;
|
return this.owner.info;
|
||||||
}
|
}
|
||||||
readStateInfo(json){
|
readStateInfo(json:readyjson["d"]["read_state"]["entries"][0]){
|
||||||
this.lastreadmessageid=SnowFlake.getSnowFlakeFromID(json.last_message_id,Message);
|
this.lastreadmessageid=SnowFlake.getSnowFlakeFromID(json.last_message_id,Message);
|
||||||
this.mentions=json.mention_count;
|
this.mentions=json.mention_count;
|
||||||
this.mentions??=0;
|
this.mentions??=0;
|
||||||
|
@ -572,10 +572,10 @@ class Channel{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delChannel(json){
|
delChannel(json:channeljson){
|
||||||
const build=[];
|
const build=[];
|
||||||
for(const thing of this.children){
|
for(const thing of this.children){
|
||||||
if(thing.snowflake!==json.id){
|
if(thing.id!==json.id){
|
||||||
build.push(thing)
|
build.push(thing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -649,7 +649,7 @@ class Channel{
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
updateChannel(json){
|
updateChannel(json:channeljson){
|
||||||
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);
|
||||||
|
@ -661,7 +661,7 @@ class Channel{
|
||||||
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([SnowFlake.getSnowFlakeFromID(thing.id,Role),this.permission_overwrites.get(thing.id)]);
|
||||||
}
|
}
|
||||||
this.topic=json.topic;
|
this.topic=json.topic;
|
||||||
this.nsfw=json.nsfw;
|
this.nsfw=json.nsfw;
|
||||||
|
|
|
@ -5,9 +5,10 @@ import { Localuser } from "./localuser.js";
|
||||||
import {User} from "./user.js";
|
import {User} from "./user.js";
|
||||||
import { Member } from "./member.js";
|
import { Member } from "./member.js";
|
||||||
import { SnowFlake } from "./snowflake.js";
|
import { SnowFlake } from "./snowflake.js";
|
||||||
|
import { dirrectjson, memberjson } from "./jsontypes.js";
|
||||||
|
|
||||||
class Direct extends Guild{
|
class Direct extends Guild{
|
||||||
constructor(json,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);
|
console.log(json);
|
||||||
|
@ -44,13 +45,13 @@ class Direct extends Guild{
|
||||||
return Number(-result);
|
return Number(-result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
giveMember(member){
|
giveMember(_member:memberjson){
|
||||||
console.error("not a real guild, can't give member object")
|
console.error("not a real guild, can't give member object")
|
||||||
}
|
}
|
||||||
getRole(ID){
|
getRole(ID:string){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
hasRole(r){
|
hasRole(r:string){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
isAdmin(){
|
isAdmin(){
|
||||||
|
@ -64,7 +65,7 @@ class Direct extends Guild{
|
||||||
}
|
}
|
||||||
class Group extends Channel{
|
class Group extends Channel{
|
||||||
user:User;
|
user:User;
|
||||||
constructor(json,owner:Direct){
|
constructor(json:dirrectjson,owner:Direct){
|
||||||
super(-1,owner);
|
super(-1,owner);
|
||||||
this.owner=owner;
|
this.owner=owner;
|
||||||
this.headers=this.guild.headers;
|
this.headers=this.guild.headers;
|
||||||
|
|
|
@ -7,6 +7,7 @@ class Embed{
|
||||||
owner:Message;
|
owner:Message;
|
||||||
json;
|
json;
|
||||||
constructor(json, owner:Message){
|
constructor(json, 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;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import {Member} from "./member.js";
|
||||||
import {Settings,RoleList} from "./settings.js";
|
import {Settings,RoleList} from "./settings.js";
|
||||||
import {Permissions} from "./permissions.js";
|
import {Permissions} from "./permissions.js";
|
||||||
import { SnowFlake } from "./snowflake.js";
|
import { SnowFlake } from "./snowflake.js";
|
||||||
|
import { channeljson, guildjson } from "./jsontypes.js";
|
||||||
class Guild{
|
class Guild{
|
||||||
owner:Localuser;
|
owner:Localuser;
|
||||||
headers:Localuser["headers"];
|
headers:Localuser["headers"];
|
||||||
|
@ -79,7 +80,7 @@ class Guild{
|
||||||
s1.options.push(new RoleList(permlist,this,this.updateRolePermissions.bind(this)));
|
s1.options.push(new RoleList(permlist,this,this.updateRolePermissions.bind(this)));
|
||||||
settings.show();
|
settings.show();
|
||||||
}
|
}
|
||||||
constructor(json,owner:Localuser,member){
|
constructor(json:guildjson|-1,owner:Localuser,member){
|
||||||
if(json===-1){
|
if(json===-1){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -404,7 +405,7 @@ class Guild{
|
||||||
loadGuild(){
|
loadGuild(){
|
||||||
this.localuser.loadGuild(this.id);
|
this.localuser.loadGuild(this.id);
|
||||||
}
|
}
|
||||||
updateChannel(json){
|
updateChannel(json:channeljson){
|
||||||
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){
|
||||||
|
@ -417,7 +418,7 @@ class Guild{
|
||||||
}
|
}
|
||||||
this.printServers();
|
this.printServers();
|
||||||
}
|
}
|
||||||
createChannelpac(json){
|
createChannelpac(json:channeljson){
|
||||||
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);
|
||||||
|
@ -470,7 +471,7 @@ class Guild{
|
||||||
]);
|
]);
|
||||||
channelselect.show();
|
channelselect.show();
|
||||||
}
|
}
|
||||||
delChannel(json){
|
delChannel(json:channeljson){
|
||||||
const channel=this.channelids[json.id];
|
const channel=this.channelids[json.id];
|
||||||
delete this.channelids[json.id];
|
delete this.channelids[json.id];
|
||||||
|
|
||||||
|
|
279
webpage/jsontypes.ts
Normal file
279
webpage/jsontypes.ts
Normal file
|
@ -0,0 +1,279 @@
|
||||||
|
type readyjson={
|
||||||
|
op:number;
|
||||||
|
t:string;
|
||||||
|
s:number;
|
||||||
|
d:{
|
||||||
|
v:number;
|
||||||
|
user:mainuserjson;
|
||||||
|
user_settings:{
|
||||||
|
index: number,
|
||||||
|
afk_timeout: number,
|
||||||
|
allow_accessibility_detection: boolean,
|
||||||
|
animate_emoji: boolean,
|
||||||
|
animate_stickers: number,
|
||||||
|
contact_sync_enabled: boolean,
|
||||||
|
convert_emoticons: boolean,
|
||||||
|
custom_status: string,
|
||||||
|
default_guilds_restricted: boolean,
|
||||||
|
detect_platform_accounts: boolean,
|
||||||
|
developer_mode: boolean,
|
||||||
|
disable_games_tab: boolean,
|
||||||
|
enable_tts_command: boolean,
|
||||||
|
explicit_content_filter: 0,
|
||||||
|
friend_discovery_flags: 0,
|
||||||
|
friend_source_flags: {
|
||||||
|
all: boolean
|
||||||
|
},//might be missing things here
|
||||||
|
gateway_connected: boolean,
|
||||||
|
gif_auto_play: boolean,
|
||||||
|
guild_folders: [],//need an example of this not empty
|
||||||
|
guild_positions: [],//need an example of this not empty
|
||||||
|
inline_attachment_media: boolean,
|
||||||
|
inline_embed_media: boolean,
|
||||||
|
locale: string,
|
||||||
|
message_display_compact: boolean,
|
||||||
|
native_phone_integration_enabled: boolean,
|
||||||
|
render_embeds: boolean,
|
||||||
|
render_reactions: boolean,
|
||||||
|
restricted_guilds: [],//need an example of this not empty
|
||||||
|
show_current_game: boolean,
|
||||||
|
status: string,
|
||||||
|
stream_notifications_enabled: boolean,
|
||||||
|
theme: string,
|
||||||
|
timezone_offset: number,
|
||||||
|
view_nsfw_guilds: boolean
|
||||||
|
};
|
||||||
|
guilds:guildjson[];
|
||||||
|
relationships:any[];
|
||||||
|
read_state:{
|
||||||
|
entries:{
|
||||||
|
id: string,
|
||||||
|
channel_id: string,
|
||||||
|
last_message_id: string,
|
||||||
|
last_pin_timestamp: string,
|
||||||
|
mention_count: number //in theory, the server doesn't actually send this as far as I'm aware
|
||||||
|
}[],
|
||||||
|
partial: boolean,
|
||||||
|
version: number
|
||||||
|
};
|
||||||
|
user_guild_settings:{
|
||||||
|
entries:{
|
||||||
|
channel_overrides: unknown[],//will have to find example
|
||||||
|
message_notifications: number,
|
||||||
|
flags: number,
|
||||||
|
hide_muted_channels: boolean,
|
||||||
|
mobile_push: boolean,
|
||||||
|
mute_config: null,
|
||||||
|
mute_scheduled_events: boolean,
|
||||||
|
muted: boolean,
|
||||||
|
notify_highlights: number,
|
||||||
|
suppress_everyone: boolean,
|
||||||
|
suppress_roles: boolean,
|
||||||
|
version: number,
|
||||||
|
guild_id: string
|
||||||
|
}[],
|
||||||
|
partial: boolean,
|
||||||
|
version: number
|
||||||
|
};
|
||||||
|
private_channels:dirrectjson[];
|
||||||
|
session_id:string;
|
||||||
|
country_code:string;
|
||||||
|
users:userjson[];
|
||||||
|
merged_members:memberjson[];
|
||||||
|
sessions:{
|
||||||
|
active: boolean,
|
||||||
|
activities: [],//will need to find example of this
|
||||||
|
client_info: {
|
||||||
|
version: number
|
||||||
|
},
|
||||||
|
session_id: string,
|
||||||
|
status: string
|
||||||
|
}[];
|
||||||
|
resume_gateway_url:string;
|
||||||
|
consents:{
|
||||||
|
personalization: {
|
||||||
|
consented: boolean
|
||||||
|
}
|
||||||
|
};
|
||||||
|
experiments: [],//not sure if I need to do this :P
|
||||||
|
guild_join_requests: [],//need to get examples
|
||||||
|
connected_accounts: [],//need to get examples
|
||||||
|
guild_experiments: [],//need to get examples
|
||||||
|
geo_ordered_rtc_regions: [],//need to get examples
|
||||||
|
api_code_version: number,
|
||||||
|
friend_suggestion_count: number,
|
||||||
|
analytics_token: string,
|
||||||
|
tutorial: boolean,
|
||||||
|
session_type: string,
|
||||||
|
auth_session_id_hash: string,
|
||||||
|
notification_settings: {
|
||||||
|
flags: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type mainuserjson= userjson & {
|
||||||
|
flags: number,
|
||||||
|
mfa_enabled?: boolean,
|
||||||
|
email?: string,
|
||||||
|
phone?: string,
|
||||||
|
verified: boolean,
|
||||||
|
nsfw_allowed: boolean,
|
||||||
|
premium: boolean,
|
||||||
|
purchased_flags: number,
|
||||||
|
premium_usage_flags: number,
|
||||||
|
disabled: boolean
|
||||||
|
}
|
||||||
|
type userjson={
|
||||||
|
username: string,
|
||||||
|
discriminator: string,
|
||||||
|
id: string,
|
||||||
|
public_flags: number,
|
||||||
|
avatar: string,
|
||||||
|
accent_color: string,
|
||||||
|
banner: string,
|
||||||
|
bio: string,
|
||||||
|
bot: boolean,
|
||||||
|
premium_since: string,
|
||||||
|
premium_type: number,
|
||||||
|
theme_colors: string,
|
||||||
|
pronouns: string,
|
||||||
|
badge_ids: string,
|
||||||
|
}
|
||||||
|
type memberjson= {
|
||||||
|
index?:number,
|
||||||
|
id: string,
|
||||||
|
user: userjson,
|
||||||
|
guild_id: string,
|
||||||
|
guild: {
|
||||||
|
id: string
|
||||||
|
},
|
||||||
|
nick: string,
|
||||||
|
roles: string[],
|
||||||
|
joined_at: string,
|
||||||
|
premium_since: string,
|
||||||
|
deaf: boolean,
|
||||||
|
mute: boolean,
|
||||||
|
pending: boolean,
|
||||||
|
last_message_id: boolean
|
||||||
|
}
|
||||||
|
type guildjson={
|
||||||
|
application_command_counts: {[key:string]:number},
|
||||||
|
channels: channeljson[],
|
||||||
|
data_mode: string,
|
||||||
|
emojis: [],
|
||||||
|
guild_scheduled_events: [],
|
||||||
|
id: string,
|
||||||
|
large: boolean,
|
||||||
|
lazy: boolean,
|
||||||
|
member_count: number,
|
||||||
|
premium_subscription_count: number,
|
||||||
|
properties: {
|
||||||
|
name: string,
|
||||||
|
description: string,
|
||||||
|
icon: string,
|
||||||
|
splash: string,
|
||||||
|
banner: string,
|
||||||
|
features: string[],
|
||||||
|
preferred_locale: string,
|
||||||
|
owner_id: string,
|
||||||
|
application_id: string,
|
||||||
|
afk_channel_id: string,
|
||||||
|
afk_timeout: number,
|
||||||
|
system_channel_id: string,
|
||||||
|
verification_level: number,
|
||||||
|
explicit_content_filter: number,
|
||||||
|
default_message_notifications: number,
|
||||||
|
mfa_level: number,
|
||||||
|
vanity_url_code: number,
|
||||||
|
premium_tier: number,
|
||||||
|
premium_progress_bar_enabled: boolean,
|
||||||
|
system_channel_flags: number,
|
||||||
|
discovery_splash: string,
|
||||||
|
rules_channel_id: string,
|
||||||
|
public_updates_channel_id: string,
|
||||||
|
max_video_channel_users: number,
|
||||||
|
max_members: number,
|
||||||
|
nsfw_level: number,
|
||||||
|
hub_type: null,
|
||||||
|
home_header: null,
|
||||||
|
id: string,
|
||||||
|
latest_onboarding_question_id: string,
|
||||||
|
max_stage_video_channel_users: number,
|
||||||
|
nsfw: boolean,
|
||||||
|
safety_alerts_channel_id: string
|
||||||
|
},
|
||||||
|
roles: rolesjson[],
|
||||||
|
stage_instances: [],
|
||||||
|
stickers: [],
|
||||||
|
threads: [],
|
||||||
|
version: string,
|
||||||
|
guild_hashes: {},
|
||||||
|
joined_at: string
|
||||||
|
}
|
||||||
|
type channeljson={
|
||||||
|
id: string,
|
||||||
|
created_at: string,
|
||||||
|
name: string,
|
||||||
|
icon: string,
|
||||||
|
type: number,
|
||||||
|
last_message_id: string,
|
||||||
|
guild_id: string,
|
||||||
|
parent_id: string,
|
||||||
|
last_pin_timestamp: string,
|
||||||
|
default_auto_archive_duration: number,
|
||||||
|
permission_overwrites: {
|
||||||
|
id:string,
|
||||||
|
allow:string,
|
||||||
|
deny:string,
|
||||||
|
}[],
|
||||||
|
video_quality_mode: null,
|
||||||
|
nsfw: boolean,
|
||||||
|
topic: string,
|
||||||
|
retention_policy_id: string,
|
||||||
|
flags: number,
|
||||||
|
default_thread_rate_limit_per_user: number,
|
||||||
|
position: number
|
||||||
|
}
|
||||||
|
type rolesjson={
|
||||||
|
id: string,
|
||||||
|
guild_id: string,
|
||||||
|
color: number,
|
||||||
|
hoist: boolean,
|
||||||
|
managed: boolean,
|
||||||
|
mentionable: boolean,
|
||||||
|
name: string,
|
||||||
|
permissions: string,
|
||||||
|
position: number,
|
||||||
|
icon: string,
|
||||||
|
unicode_emoji: string,
|
||||||
|
flags: number
|
||||||
|
}
|
||||||
|
type dirrectjson={
|
||||||
|
id: string,
|
||||||
|
flags: number,
|
||||||
|
last_message_id: string,
|
||||||
|
type: number,
|
||||||
|
recipients: userjson[],
|
||||||
|
is_spam: boolean
|
||||||
|
}
|
||||||
|
type messagejson={
|
||||||
|
id: string,
|
||||||
|
channel_id: string,
|
||||||
|
guild_id: string,
|
||||||
|
author: userjson,
|
||||||
|
member?: memberjson,
|
||||||
|
content: string,
|
||||||
|
timestamp: string,
|
||||||
|
edited_timestamp: string,
|
||||||
|
tts: boolean,
|
||||||
|
mention_everyone: boolean,
|
||||||
|
mentions: [],
|
||||||
|
mention_roles: [],
|
||||||
|
attachments: [],
|
||||||
|
embeds: [],
|
||||||
|
reactions: [],
|
||||||
|
nonce: string,
|
||||||
|
pinned: boolean,
|
||||||
|
type: number
|
||||||
|
}
|
||||||
|
export {readyjson,dirrectjson,channeljson,guildjson,rolesjson,userjson,memberjson,mainuserjson,messagejson};
|
|
@ -7,6 +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";
|
||||||
|
|
||||||
const wsCodesRetry=new Set([4000,4003,4005,4007,4008,4009]);
|
const wsCodesRetry=new Set([4000,4003,4005,4007,4008,4009]);
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ class Localuser{
|
||||||
usersettings:Fullscreen;
|
usersettings:Fullscreen;
|
||||||
userConnections:Fullscreen;
|
userConnections:Fullscreen;
|
||||||
devPortal:Fullscreen;
|
devPortal:Fullscreen;
|
||||||
ready;
|
ready:readyjson;
|
||||||
guilds:Guild[];
|
guilds:Guild[];
|
||||||
guildids:Map<string,Guild>;
|
guildids:Map<string,Guild>;
|
||||||
user:User;
|
user:User;
|
||||||
|
@ -42,7 +43,7 @@ class Localuser{
|
||||||
this.info=this.serverurls;
|
this.info=this.serverurls;
|
||||||
this.headers={"Content-type": "application/json; charset=UTF-8",Authorization:this.userinfo.token};
|
this.headers={"Content-type": "application/json; charset=UTF-8",Authorization:this.userinfo.token};
|
||||||
}
|
}
|
||||||
gottenReady(ready):void{
|
gottenReady(ready:readyjson):void{
|
||||||
this.usersettings=null;
|
this.usersettings=null;
|
||||||
this.initialized=true;
|
this.initialized=true;
|
||||||
this.ready=ready;
|
this.ready=ready;
|
||||||
|
@ -119,7 +120,7 @@ class Localuser{
|
||||||
"capabilities": 16381,
|
"capabilities": 16381,
|
||||||
"properties": {
|
"properties": {
|
||||||
"browser": "Jank Client",
|
"browser": "Jank Client",
|
||||||
"client_build_number": 0,
|
"client_build_number": 0,//might update this eventually lol
|
||||||
"release_channel": "Custom",
|
"release_channel": "Custom",
|
||||||
"browser_user_agent": navigator.userAgent
|
"browser_user_agent": navigator.userAgent
|
||||||
},
|
},
|
||||||
|
@ -154,7 +155,7 @@ class Localuser{
|
||||||
SnowFlake.getSnowFlakeFromID(temp.d.id,Message).getObject().deleteEvent();
|
SnowFlake.getSnowFlakeFromID(temp.d.id,Message).getObject().deleteEvent();
|
||||||
break;
|
break;
|
||||||
case "READY":
|
case "READY":
|
||||||
this.gottenReady(temp);
|
this.gottenReady(temp as readyjson);
|
||||||
this.genusersettings();
|
this.genusersettings();
|
||||||
returny();
|
returny();
|
||||||
break;
|
break;
|
||||||
|
@ -258,24 +259,24 @@ class Localuser{
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
updateChannel(json):void{
|
updateChannel(json:channeljson):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:channeljson):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:channeljson):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.id){
|
||||||
this.loadGuild(json.guild_id);
|
this.loadGuild(json.guild_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {Role} from "./role.js";
|
||||||
import {Guild} from "./guild.js";
|
import {Guild} from "./guild.js";
|
||||||
import { Contextmenu } from "./contextmenu.js";
|
import { Contextmenu } from "./contextmenu.js";
|
||||||
import { SnowFlake } from "./snowflake.js";
|
import { SnowFlake } from "./snowflake.js";
|
||||||
|
import { memberjson, userjson } from "./jsontypes.js";
|
||||||
|
|
||||||
class Member{
|
class Member{
|
||||||
static already={};
|
static already={};
|
||||||
|
@ -23,17 +24,19 @@ class Member{
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
constructor(memberjson,owner:Guild,error=false){
|
constructor(memberjson:memberjson|User|{guild_member:memberjson,user:userjson},owner:Guild,error=false){
|
||||||
this.error=error;
|
this.error=error;
|
||||||
this.owner=owner;
|
this.owner=owner;
|
||||||
let membery=memberjson;
|
let membery=memberjson;
|
||||||
this.roles=[];
|
this.roles=[];
|
||||||
if(!error){
|
if(!error){
|
||||||
if(memberjson.guild_member){
|
if(memberjson["guild_member"]){
|
||||||
|
memberjson=memberjson as {guild_member:memberjson,user:userjson};
|
||||||
membery=memberjson.guild_member;
|
membery=memberjson.guild_member;
|
||||||
this.user=memberjson.user;
|
this.user=new User(memberjson.user,this.localuser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
membery=membery as User|memberjson;
|
||||||
for(const thing of Object.keys(membery)){
|
for(const thing of Object.keys(membery)){
|
||||||
if(thing==="guild"){continue}
|
if(thing==="guild"){continue}
|
||||||
if(thing==="owner"){continue}
|
if(thing==="owner"){continue}
|
||||||
|
@ -61,7 +64,7 @@ class Member{
|
||||||
get info(){
|
get info(){
|
||||||
return this.owner.info;
|
return this.owner.info;
|
||||||
}
|
}
|
||||||
static async resolve(unkown:User|object|string,guild:Guild):Promise<Member>{
|
static async resolve(unkown:User|memberjson|string,guild:Guild):Promise<Member>{
|
||||||
if(!(guild instanceof Guild)){
|
if(!(guild instanceof Guild)){
|
||||||
console.error(guild)
|
console.error(guild)
|
||||||
}
|
}
|
||||||
|
@ -73,7 +76,7 @@ class Member{
|
||||||
}else if(typeof unkown===typeof ""){
|
}else if(typeof unkown===typeof ""){
|
||||||
id=new SnowFlake(unkown as string,undefined);
|
id=new SnowFlake(unkown as string,undefined);
|
||||||
}else{
|
}else{
|
||||||
return new Member(unkown,guild);
|
return new Member(unkown as User|memberjson,guild);
|
||||||
}
|
}
|
||||||
if(guild.id==="@me"){return null}
|
if(guild.id==="@me"){return null}
|
||||||
if(!Member.already[guild.id]){
|
if(!Member.already[guild.id]){
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {Localuser} from "./localuser.js";
|
||||||
import { Role } from "./role.js";
|
import { Role } from "./role.js";
|
||||||
import {File} from "./file.js";
|
import {File} from "./file.js";
|
||||||
import { SnowFlake } from "./snowflake.js";
|
import { SnowFlake } from "./snowflake.js";
|
||||||
|
import { messagejson } from "./jsontypes.js";
|
||||||
|
|
||||||
class Message{
|
class Message{
|
||||||
static contextmenu=new Contextmenu("message menu");
|
static contextmenu=new Contextmenu("message menu");
|
||||||
|
@ -26,6 +27,7 @@ class Message{
|
||||||
static del:Promise<void>;
|
static del:Promise<void>;
|
||||||
static resolve:Function;
|
static resolve:Function;
|
||||||
div:HTMLDivElement;
|
div:HTMLDivElement;
|
||||||
|
member:Member;
|
||||||
get id(){
|
get id(){
|
||||||
return this.snowflake.id;
|
return this.snowflake.id;
|
||||||
}
|
}
|
||||||
|
@ -59,13 +61,14 @@ class Message{
|
||||||
this.delete();
|
this.delete();
|
||||||
},null,_=>{return _.canDelete()})
|
},null,_=>{return _.canDelete()})
|
||||||
}
|
}
|
||||||
constructor(messagejson,owner:Channel){
|
constructor(messagejson:messagejson,owner:Channel){
|
||||||
this.owner=owner;
|
this.owner=owner;
|
||||||
this.headers=this.owner.headers;
|
this.headers=this.owner.headers;
|
||||||
this.giveData(messagejson);
|
this.giveData(messagejson);
|
||||||
|
|
||||||
}
|
}
|
||||||
giveData(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=[];
|
||||||
|
@ -79,9 +82,13 @@ class Message{
|
||||||
}else if(thing ==="id"){
|
}else if(thing ==="id"){
|
||||||
this.snowflake=new SnowFlake(messagejson.id,this);
|
this.snowflake=new SnowFlake(messagejson.id,this);
|
||||||
continue;
|
continue;
|
||||||
|
}else if(thing==="member"){
|
||||||
|
this.member=new Member(messagejson.member,this.guild);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
this[thing]=messagejson[thing];
|
this[thing]=messagejson[thing];
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const thing in this.embeds){
|
for(const thing in this.embeds){
|
||||||
console.log(thing,this.embeds)
|
console.log(thing,this.embeds)
|
||||||
this.embeds[thing]=new Embed(this.embeds[thing],this);
|
this.embeds[thing]=new Embed(this.embeds[thing],this);
|
||||||
|
@ -90,6 +97,11 @@ class Message{
|
||||||
for(const thing in this.mentions){
|
for(const thing in this.mentions){
|
||||||
this.mentions[thing]=new User(this.mentions[thing],this.localuser);
|
this.mentions[thing]=new User(this.mentions[thing],this.localuser);
|
||||||
}
|
}
|
||||||
|
if(!this.member&&this.guild.id!=="@me"){
|
||||||
|
this.author.resolvemember(this.guild).then(_=>{
|
||||||
|
this.member=_;
|
||||||
|
})
|
||||||
|
}
|
||||||
if(this.mentions.length||this.mention_roles.length){//currently mention_roles isn't implemented on the spacebar servers
|
if(this.mentions.length||this.mention_roles.length){//currently mention_roles isn't implemented on the spacebar servers
|
||||||
console.log(this.mentions,this.mention_roles)
|
console.log(this.mentions,this.mention_roles)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {Permissions} from "./permissions.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 { rolesjson } from "./jsontypes.js";
|
||||||
class Role{
|
class Role{
|
||||||
permissions:Permissions;
|
permissions:Permissions;
|
||||||
owner:Guild;
|
owner:Guild;
|
||||||
|
@ -18,7 +19,7 @@ class Role{
|
||||||
get id(){
|
get id(){
|
||||||
return this.snowflake.id;
|
return this.snowflake.id;
|
||||||
}
|
}
|
||||||
constructor(json, owner:Guild){
|
constructor(json:rolesjson, 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)){
|
||||||
|
|
|
@ -69,7 +69,7 @@ class User{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async resolvemember(guild:Guild){
|
async resolvemember(guild:Guild){
|
||||||
await Member.resolve(this,guild);
|
return await Member.resolve(this,guild);
|
||||||
}
|
}
|
||||||
buildpfp(){
|
buildpfp(){
|
||||||
const pfp=document.createElement('img');
|
const pfp=document.createElement('img');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue