From 58b79be7f263cada43f1098385f3c5f252c3f8d0 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Fri, 26 Jul 2024 16:31:27 -0500 Subject: [PATCH] typing out a lot of the JSON --- .dist/channel.js | 7 +- .dist/direct.js | 2 +- .dist/embed.js | 1 + .dist/jsontypes.js | 1 + .dist/localuser.js | 4 +- .dist/member.js | 6 +- .dist/message.js | 11 ++ .dist/user.js | 2 +- package-lock.json | 2 +- webpage/channel.ts | 16 +-- webpage/direct.ts | 11 +- webpage/embed.ts | 1 + webpage/guild.ts | 9 +- webpage/jsontypes.ts | 279 +++++++++++++++++++++++++++++++++++++++++++ webpage/localuser.ts | 17 +-- webpage/member.ts | 13 +- webpage/message.ts | 16 ++- webpage/role.ts | 3 +- webpage/user.ts | 2 +- 19 files changed, 359 insertions(+), 44 deletions(-) create mode 100644 .dist/jsontypes.js create mode 100644 webpage/jsontypes.ts diff --git a/.dist/channel.js b/.dist/channel.js index 22b1527..c447392 100644 --- a/.dist/channel.js +++ b/.dist/channel.js @@ -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; diff --git a/.dist/direct.js b/.dist/direct.js index d6cb754..babd339 100644 --- a/.dist/direct.js +++ b/.dist/direct.js @@ -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) { diff --git a/.dist/embed.js b/.dist/embed.js index 76fcbf3..279c4d4 100644 --- a/.dist/embed.js +++ b/.dist/embed.js @@ -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; diff --git a/.dist/jsontypes.js b/.dist/jsontypes.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/.dist/jsontypes.js @@ -0,0 +1 @@ +export {}; diff --git a/.dist/localuser.js b/.dist/localuser.js index d66cc47..65c20f6 100644 --- a/.dist/localuser.js +++ b/.dist/localuser.js @@ -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); } } diff --git a/.dist/member.js b/.dist/member.js index c2f20e3..dd08b62 100644 --- a/.dist/member.js +++ b/.dist/member.js @@ -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; diff --git a/.dist/message.js b/.dist/message.js index dcf32cf..0063d38 100644 --- a/.dist/message.js +++ b/.dist/message.js @@ -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); } diff --git a/.dist/user.js b/.dist/user.js index 7a4c50e..1ac96e6 100644 --- a/.dist/user.js +++ b/.dist/user.js @@ -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'); diff --git a/package-lock.json b/package-lock.json index d803596..360cf57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/webpage/channel.ts b/webpage/channel.ts index 95dc395..db27915 100644 --- a/webpage/channel.ts +++ b/webpage/channel.ts @@ -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; diff --git a/webpage/direct.ts b/webpage/direct.ts index 772894c..2f81528 100644 --- a/webpage/direct.ts +++ b/webpage/direct.ts @@ -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; diff --git a/webpage/embed.ts b/webpage/embed.ts index b17de58..e582d3a 100644 --- a/webpage/embed.ts +++ b/webpage/embed.ts @@ -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; diff --git a/webpage/guild.ts b/webpage/guild.ts index 81309fc..e936ad1 100644 --- a/webpage/guild.ts +++ b/webpage/guild.ts @@ -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]; diff --git a/webpage/jsontypes.ts b/webpage/jsontypes.ts new file mode 100644 index 0000000..8726007 --- /dev/null +++ b/webpage/jsontypes.ts @@ -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}; diff --git a/webpage/localuser.ts b/webpage/localuser.ts index 5b83eed..e3b2f9f 100644 --- a/webpage/localuser.ts +++ b/webpage/localuser.ts @@ -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; 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); } } diff --git a/webpage/member.ts b/webpage/member.ts index 6469695..4f2be97 100644 --- a/webpage/member.ts +++ b/webpage/member.ts @@ -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{ + static async resolve(unkown:User|memberjson|string,guild:Guild):Promise{ 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]){ diff --git a/webpage/message.ts b/webpage/message.ts index 475d91f..13e8577 100644 --- a/webpage/message.ts +++ b/webpage/message.ts @@ -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; 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) } diff --git a/webpage/role.ts b/webpage/role.ts index 6eeed36..808c60a 100644 --- a/webpage/role.ts +++ b/webpage/role.ts @@ -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)){ diff --git a/webpage/user.ts b/webpage/user.ts index 9db689a..860a127 100644 --- a/webpage/user.ts +++ b/webpage/user.ts @@ -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');