Skip to content

Commit

Permalink
fix: skip & use extra fields where necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
insertish committed Dec 17, 2024
1 parent c332974 commit 33f8941
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "revolt.js",
"version": "7.0.4",
"version": "7.0.5",
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",
"types": "lib/esm/index.d.ts",
Expand Down Expand Up @@ -54,4 +54,4 @@
"typedoc": "^0.25.1",
"typescript": "^5.4.2"
}
}
}
26 changes: 11 additions & 15 deletions src/events/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,22 +239,18 @@ export async function handleEvent(
}
case "Message": {
if (!client.messages.has(event._id)) {
// TODO: this should not be necessary in future protocols:
if (
event.author &&
event.author != "00000000000000000000000000" &&
!event.webhook &&
// TODO: this is causing a lot of extra requests!
// usually 2 extra requests before a message can come through!!
client.options.eagerFetching
) {
await client.users.fetch(event.author);
const serverId = client.channels.get(event.channel)?.serverId;
if (serverId)
await client.serverMembers.fetch(serverId, event.author);
}

batch(() => {
if (event.member) {
client.serverMembers.getOrCreate(event.member._id, event.member);
}

if (event.user) {
client.users.getOrCreate(event.user._id, event.user);
}

delete event.member;
delete event.user;

client.messages.getOrCreate(event._id, event, true);
client.channels.updateUnderlyingObject(
event.channel,
Expand Down
2 changes: 2 additions & 0 deletions src/hydration/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type HydratedUser = {
discriminator: string;
displayName?: string;
relationship: RelationshipStatus;
relations: null;

online: boolean;
privileged: boolean;
Expand All @@ -38,6 +39,7 @@ export const userHydration: Hydrate<ApiUser, HydratedUser> = {
discriminator: (user) => user.discriminator,
displayName: (user) => user.display_name!,
relationship: (user) => user.relationship!,
relations: () => null,

online: (user) => user.online!,
privileged: (user) => user.privileged,
Expand Down

0 comments on commit 33f8941

Please sign in to comment.