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 { Permissions } from "./permissions.js";
|
||||
import { Settings, RoleList } from "./settings.js";
|
||||
import { Role } from "./role.js";
|
||||
import { InfiniteScroller } from "./infiniteScroller.js";
|
||||
import { SnowFlake } from "./snowflake.js";
|
||||
class Channel {
|
||||
|
@ -125,7 +126,7 @@ class Channel {
|
|||
}
|
||||
;
|
||||
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.nsfw = json.nsfw;
|
||||
|
@ -566,7 +567,7 @@ class Channel {
|
|||
delChannel(json) {
|
||||
const build = [];
|
||||
for (const thing of this.children) {
|
||||
if (thing.snowflake !== json.id) {
|
||||
if (thing.id !== json.id) {
|
||||
build.push(thing);
|
||||
}
|
||||
}
|
||||
|
@ -659,7 +660,7 @@ class Channel {
|
|||
}
|
||||
;
|
||||
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.nsfw = json.nsfw;
|
||||
|
|
|
@ -41,7 +41,7 @@ class Direct extends Guild {
|
|||
return Number(-result);
|
||||
});
|
||||
}
|
||||
giveMember(member) {
|
||||
giveMember(_member) {
|
||||
console.error("not a real guild, can't give member object");
|
||||
}
|
||||
getRole(ID) {
|
||||
|
|
|
@ -5,6 +5,7 @@ class Embed {
|
|||
owner;
|
||||
json;
|
||||
constructor(json, owner) {
|
||||
console.log(json);
|
||||
this.type = this.getType(json);
|
||||
this.owner = owner;
|
||||
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,
|
||||
"properties": {
|
||||
"browser": "Jank Client",
|
||||
"client_build_number": 0,
|
||||
"client_build_number": 0, //might update this eventually lol
|
||||
"release_channel": "Custom",
|
||||
"browser_user_agent": navigator.userAgent
|
||||
},
|
||||
|
@ -262,7 +262,7 @@ class Localuser {
|
|||
delChannel(json) {
|
||||
json.guild_id ??= "@me";
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,11 +27,13 @@ class Member {
|
|||
let membery = memberjson;
|
||||
this.roles = [];
|
||||
if (!error) {
|
||||
if (memberjson.guild_member) {
|
||||
if (memberjson["guild_member"]) {
|
||||
memberjson = memberjson;
|
||||
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)) {
|
||||
if (thing === "guild") {
|
||||
continue;
|
||||
|
|
|
@ -22,6 +22,7 @@ class Message {
|
|||
static del;
|
||||
static resolve;
|
||||
div;
|
||||
member;
|
||||
get id() {
|
||||
return this.snowflake.id;
|
||||
}
|
||||
|
@ -61,6 +62,7 @@ class Message {
|
|||
this.giveData(messagejson);
|
||||
}
|
||||
giveData(messagejson) {
|
||||
console.log(messagejson);
|
||||
for (const thing of Object.keys(messagejson)) {
|
||||
if (thing === "attachments") {
|
||||
this.attachments = [];
|
||||
|
@ -77,6 +79,10 @@ class Message {
|
|||
this.snowflake = new SnowFlake(messagejson.id, this);
|
||||
continue;
|
||||
}
|
||||
else if (thing === "member") {
|
||||
this.member = new Member(messagejson.member, this.guild);
|
||||
continue;
|
||||
}
|
||||
this[thing] = messagejson[thing];
|
||||
}
|
||||
for (const thing in this.embeds) {
|
||||
|
@ -87,6 +93,11 @@ class Message {
|
|||
for (const thing in this.mentions) {
|
||||
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
|
||||
console.log(this.mentions, this.mention_roles);
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ class User {
|
|||
}
|
||||
}
|
||||
async resolvemember(guild) {
|
||||
await Member.resolve(this, guild);
|
||||
return await Member.resolve(this, guild);
|
||||
}
|
||||
buildpfp() {
|
||||
const pfp = document.createElement('img');
|
||||
|
|
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -9,7 +9,7 @@
|
|||
"version": "0.1.0",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"express": "latest"
|
||||
"express": "^4.19.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.7.0",
|
||||
|
|
|
@ -10,6 +10,7 @@ import { Settings, RoleList } from "./settings.js";
|
|||
import { Role } from "./role.js";
|
||||
import {InfiniteScroller} from "./infiniteScroller.js";
|
||||
import { SnowFlake } from "./snowflake.js";
|
||||
import { channeljson, readyjson } from "./jsontypes.js";
|
||||
|
||||
declare global {
|
||||
interface NotificationOptions {
|
||||
|
@ -119,12 +120,11 @@ class Channel{
|
|||
this.readbottom.bind(this)
|
||||
);
|
||||
}
|
||||
constructor(json,owner:Guild){
|
||||
constructor(json:channeljson|-1,owner:Guild){
|
||||
|
||||
if(json===-1){
|
||||
return;
|
||||
}
|
||||
|
||||
this.editing;
|
||||
this.type=json.type;
|
||||
this.owner=owner;
|
||||
|
@ -141,7 +141,7 @@ class Channel{
|
|||
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.permission_overwritesar.push([SnowFlake.getSnowFlakeFromID(thing.id,Role),this.permission_overwrites.get(thing.id)]);
|
||||
}
|
||||
|
||||
this.topic=json.topic;
|
||||
|
@ -163,7 +163,7 @@ class Channel{
|
|||
get 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.mentions=json.mention_count;
|
||||
this.mentions??=0;
|
||||
|
@ -572,10 +572,10 @@ class Channel{
|
|||
}
|
||||
}
|
||||
}
|
||||
delChannel(json){
|
||||
delChannel(json:channeljson){
|
||||
const build=[];
|
||||
for(const thing of this.children){
|
||||
if(thing.snowflake!==json.id){
|
||||
if(thing.id!==json.id){
|
||||
build.push(thing)
|
||||
}
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ class Channel{
|
|||
}
|
||||
return id;
|
||||
}
|
||||
updateChannel(json){
|
||||
updateChannel(json:channeljson){
|
||||
this.type=json.type;
|
||||
this.name=json.name;
|
||||
this.parent_id=new SnowFlake(json.parent_id,undefined);
|
||||
|
@ -661,7 +661,7 @@ class Channel{
|
|||
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.permission_overwritesar.push([SnowFlake.getSnowFlakeFromID(thing.id,Role),this.permission_overwrites.get(thing.id)]);
|
||||
}
|
||||
this.topic=json.topic;
|
||||
this.nsfw=json.nsfw;
|
||||
|
|
|
@ -5,9 +5,10 @@ import { Localuser } from "./localuser.js";
|
|||
import {User} from "./user.js";
|
||||
import { Member } from "./member.js";
|
||||
import { SnowFlake } from "./snowflake.js";
|
||||
import { dirrectjson, memberjson } from "./jsontypes.js";
|
||||
|
||||
class Direct extends Guild{
|
||||
constructor(json,owner:Localuser){
|
||||
constructor(json:dirrectjson[],owner:Localuser){
|
||||
super(-1,owner,null);
|
||||
this.message_notifications=0;
|
||||
console.log(json);
|
||||
|
@ -44,13 +45,13 @@ class Direct extends Guild{
|
|||
return Number(-result);
|
||||
});
|
||||
}
|
||||
giveMember(member){
|
||||
giveMember(_member:memberjson){
|
||||
console.error("not a real guild, can't give member object")
|
||||
}
|
||||
getRole(ID){
|
||||
getRole(ID:string){
|
||||
return null;
|
||||
}
|
||||
hasRole(r){
|
||||
hasRole(r:string){
|
||||
return false;
|
||||
}
|
||||
isAdmin(){
|
||||
|
@ -64,7 +65,7 @@ class Direct extends Guild{
|
|||
}
|
||||
class Group extends Channel{
|
||||
user:User;
|
||||
constructor(json,owner:Direct){
|
||||
constructor(json:dirrectjson,owner:Direct){
|
||||
super(-1,owner);
|
||||
this.owner=owner;
|
||||
this.headers=this.guild.headers;
|
||||
|
|
|
@ -7,6 +7,7 @@ class Embed{
|
|||
owner:Message;
|
||||
json;
|
||||
constructor(json, owner:Message){
|
||||
console.log(json);
|
||||
this.type=this.getType(json);
|
||||
this.owner=owner;
|
||||
this.json=json;
|
||||
|
|
|
@ -7,6 +7,7 @@ import {Member} from "./member.js";
|
|||
import {Settings,RoleList} from "./settings.js";
|
||||
import {Permissions} from "./permissions.js";
|
||||
import { SnowFlake } from "./snowflake.js";
|
||||
import { channeljson, guildjson } from "./jsontypes.js";
|
||||
class Guild{
|
||||
owner:Localuser;
|
||||
headers:Localuser["headers"];
|
||||
|
@ -79,7 +80,7 @@ class Guild{
|
|||
s1.options.push(new RoleList(permlist,this,this.updateRolePermissions.bind(this)));
|
||||
settings.show();
|
||||
}
|
||||
constructor(json,owner:Localuser,member){
|
||||
constructor(json:guildjson|-1,owner:Localuser,member){
|
||||
if(json===-1){
|
||||
return;
|
||||
}
|
||||
|
@ -404,7 +405,7 @@ class Guild{
|
|||
loadGuild(){
|
||||
this.localuser.loadGuild(this.id);
|
||||
}
|
||||
updateChannel(json){
|
||||
updateChannel(json:channeljson){
|
||||
SnowFlake.getSnowFlakeFromID(json.id,Channel).getObject().updateChannel(json);
|
||||
this.headchannels=[];
|
||||
for(const thing of this.channels){
|
||||
|
@ -417,7 +418,7 @@ class Guild{
|
|||
}
|
||||
this.printServers();
|
||||
}
|
||||
createChannelpac(json){
|
||||
createChannelpac(json:channeljson){
|
||||
const thischannel=new Channel(json,this);
|
||||
this.channelids[json.id]=thischannel;
|
||||
this.channels.push(thischannel);
|
||||
|
@ -470,7 +471,7 @@ class Guild{
|
|||
]);
|
||||
channelselect.show();
|
||||
}
|
||||
delChannel(json){
|
||||
delChannel(json:channeljson){
|
||||
const channel=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 { SnowFlake } from "./snowflake.js";
|
||||
import { Message } from "./message.js";
|
||||
import { channeljson, readyjson } from "./jsontypes.js";
|
||||
|
||||
const wsCodesRetry=new Set([4000,4003,4005,4007,4008,4009]);
|
||||
|
||||
|
@ -21,7 +22,7 @@ class Localuser{
|
|||
usersettings:Fullscreen;
|
||||
userConnections:Fullscreen;
|
||||
devPortal:Fullscreen;
|
||||
ready;
|
||||
ready:readyjson;
|
||||
guilds:Guild[];
|
||||
guildids:Map<string,Guild>;
|
||||
user:User;
|
||||
|
@ -42,7 +43,7 @@ class Localuser{
|
|||
this.info=this.serverurls;
|
||||
this.headers={"Content-type": "application/json; charset=UTF-8",Authorization:this.userinfo.token};
|
||||
}
|
||||
gottenReady(ready):void{
|
||||
gottenReady(ready:readyjson):void{
|
||||
this.usersettings=null;
|
||||
this.initialized=true;
|
||||
this.ready=ready;
|
||||
|
@ -119,7 +120,7 @@ class Localuser{
|
|||
"capabilities": 16381,
|
||||
"properties": {
|
||||
"browser": "Jank Client",
|
||||
"client_build_number": 0,
|
||||
"client_build_number": 0,//might update this eventually lol
|
||||
"release_channel": "Custom",
|
||||
"browser_user_agent": navigator.userAgent
|
||||
},
|
||||
|
@ -154,7 +155,7 @@ class Localuser{
|
|||
SnowFlake.getSnowFlakeFromID(temp.d.id,Message).getObject().deleteEvent();
|
||||
break;
|
||||
case "READY":
|
||||
this.gottenReady(temp);
|
||||
this.gottenReady(temp as readyjson);
|
||||
this.genusersettings();
|
||||
returny();
|
||||
break;
|
||||
|
@ -258,24 +259,24 @@ class Localuser{
|
|||
}
|
||||
return undefined;
|
||||
}
|
||||
updateChannel(json):void{
|
||||
updateChannel(json:channeljson):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{
|
||||
createChannel(json:channeljson):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{
|
||||
delChannel(json:channeljson):void{
|
||||
json.guild_id??="@me";
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import {Role} from "./role.js";
|
|||
import {Guild} from "./guild.js";
|
||||
import { Contextmenu } from "./contextmenu.js";
|
||||
import { SnowFlake } from "./snowflake.js";
|
||||
import { memberjson, userjson } from "./jsontypes.js";
|
||||
|
||||
class Member{
|
||||
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.owner=owner;
|
||||
let membery=memberjson;
|
||||
this.roles=[];
|
||||
if(!error){
|
||||
if(memberjson.guild_member){
|
||||
if(memberjson["guild_member"]){
|
||||
memberjson=memberjson as {guild_member:memberjson,user:userjson};
|
||||
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)){
|
||||
if(thing==="guild"){continue}
|
||||
if(thing==="owner"){continue}
|
||||
|
@ -61,7 +64,7 @@ class Member{
|
|||
get 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)){
|
||||
console.error(guild)
|
||||
}
|
||||
|
@ -73,7 +76,7 @@ class Member{
|
|||
}else if(typeof unkown===typeof ""){
|
||||
id=new SnowFlake(unkown as string,undefined);
|
||||
}else{
|
||||
return new Member(unkown,guild);
|
||||
return new Member(unkown as User|memberjson,guild);
|
||||
}
|
||||
if(guild.id==="@me"){return null}
|
||||
if(!Member.already[guild.id]){
|
||||
|
|
|
@ -8,6 +8,7 @@ import {Localuser} from "./localuser.js";
|
|||
import { Role } from "./role.js";
|
||||
import {File} from "./file.js";
|
||||
import { SnowFlake } from "./snowflake.js";
|
||||
import { messagejson } from "./jsontypes.js";
|
||||
|
||||
class Message{
|
||||
static contextmenu=new Contextmenu("message menu");
|
||||
|
@ -26,6 +27,7 @@ class Message{
|
|||
static del:Promise<void>;
|
||||
static resolve:Function;
|
||||
div:HTMLDivElement;
|
||||
member:Member;
|
||||
get id(){
|
||||
return this.snowflake.id;
|
||||
}
|
||||
|
@ -59,13 +61,14 @@ class Message{
|
|||
this.delete();
|
||||
},null,_=>{return _.canDelete()})
|
||||
}
|
||||
constructor(messagejson,owner:Channel){
|
||||
constructor(messagejson:messagejson,owner:Channel){
|
||||
this.owner=owner;
|
||||
this.headers=this.owner.headers;
|
||||
this.giveData(messagejson);
|
||||
|
||||
}
|
||||
giveData(messagejson){
|
||||
giveData(messagejson:messagejson){
|
||||
console.log(messagejson);
|
||||
for(const thing of Object.keys(messagejson)){
|
||||
if(thing==="attachments"){
|
||||
this.attachments=[];
|
||||
|
@ -79,9 +82,13 @@ class Message{
|
|||
}else if(thing ==="id"){
|
||||
this.snowflake=new SnowFlake(messagejson.id,this);
|
||||
continue;
|
||||
}else if(thing==="member"){
|
||||
this.member=new Member(messagejson.member,this.guild);
|
||||
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);
|
||||
|
@ -90,6 +97,11 @@ class Message{
|
|||
for(const thing in this.mentions){
|
||||
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
|
||||
console.log(this.mentions,this.mention_roles)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import {Permissions} from "./permissions.js";
|
|||
import {Localuser} from "./localuser.js";
|
||||
import {Guild} from "./guild.js";
|
||||
import { SnowFlake } from "./snowflake.js";
|
||||
import { rolesjson } from "./jsontypes.js";
|
||||
class Role{
|
||||
permissions:Permissions;
|
||||
owner:Guild;
|
||||
|
@ -18,7 +19,7 @@ class Role{
|
|||
get id(){
|
||||
return this.snowflake.id;
|
||||
}
|
||||
constructor(json, owner:Guild){
|
||||
constructor(json:rolesjson, owner:Guild){
|
||||
this.headers=owner.headers;
|
||||
this.info=owner.info;
|
||||
for(const thing of Object.keys(json)){
|
||||
|
|
|
@ -69,7 +69,7 @@ class User{
|
|||
}
|
||||
}
|
||||
async resolvemember(guild:Guild){
|
||||
await Member.resolve(this,guild);
|
||||
return await Member.resolve(this,guild);
|
||||
}
|
||||
buildpfp(){
|
||||
const pfp=document.createElement('img');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue