diff --git a/src/webpage/jsontypes.ts b/src/webpage/jsontypes.ts index fb845b2..1d64cde 100644 --- a/src/webpage/jsontypes.ts +++ b/src/webpage/jsontypes.ts @@ -978,6 +978,16 @@ type wsjson = user: userjson; }; s: number; + } + | { + op: 0; + t: "MESSAGE_ACK"; + d: { + channel_id: string; + message_id: string; + version: number; //I don't think this really matters lol + }; + s: number; }; export interface interactionCreate { diff --git a/src/webpage/localuser.ts b/src/webpage/localuser.ts index f439394..90a414e 100644 --- a/src/webpage/localuser.ts +++ b/src/webpage/localuser.ts @@ -249,6 +249,17 @@ class Localuser { mic.classList.add("svg-mic"); } } + channelByID(id: string): Channel | void { + let channel: Channel | void = undefined; + this.guilds.forEach((_) => { + _.channels.forEach((_) => { + if (_.id === id) { + channel = _; + } + }); + }); + return channel; + } trace: {trace: trace; time: Date}[] = []; handleTrace(str: string[]) { const json = str.map((_) => JSON.parse(_)) as trace[]; @@ -940,6 +951,15 @@ class Localuser { channel.addRec(new User(temp.d.user, this)); break; } + case "MESSAGE_ACK": { + const channel = this.channelByID(temp.d.channel_id); + if (!channel) break; + channel.lastreadmessageid = temp.d.message_id; + channel.mentions = 0; + channel.unreads(); + channel.guild.unreads(); + break; + } default: { //@ts-expect-error