summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/util/entities/Guild.ts4
-rw-r--r--src/util/entities/Member.ts18
2 files changed, 18 insertions, 4 deletions
diff --git a/src/util/entities/Guild.ts b/src/util/entities/Guild.ts
index 8854fec0..169921be 100644
--- a/src/util/entities/Guild.ts
+++ b/src/util/entities/Guild.ts
@@ -43,11 +43,11 @@ import { Webhook } from "./Webhook";
 export const PublicGuildRelations = [
 	"channels",
 	"emojis",
-	"members",
 	"roles",
 	"stickers",
 	"voice_states",
-	"members.user",
+	// "members",		// TODO: These are public, but all members should not be fetched.
+	// "members.user",
 ];
 
 @Entity("guilds")
diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts
index f2762adc..27c67c40 100644
--- a/src/util/entities/Member.ts
+++ b/src/util/entities/Member.ts
@@ -10,6 +10,7 @@ import {
 	JoinTable,
 	ManyToMany,
 	ManyToOne,
+	Not,
 	PrimaryGeneratedColumn,
 	RelationId,
 } from "typeorm";
@@ -287,6 +288,19 @@ export class Member extends BaseClassWithoutId {
 			relations: [...PublicGuildRelations, "system_channel"],
 		});
 
+		const memberCount = await Member.count({ where: { guild_id } });
+		const memberPreview = await Member.find({
+			where: {
+				guild_id,
+				user: {
+					sessions: {
+						status: Not("invisible" as "invisible")	// lol typescript?
+					}
+				}
+			},
+			take: 10,
+		});
+
 		if (
 			await Member.count({
 				where: { id: user.id, guild: { id: guild_id } },
@@ -342,8 +356,8 @@ export class Member extends BaseClassWithoutId {
 				event: "GUILD_CREATE",
 				data: {
 					...guild,
-					members: [...guild.members, { ...member, user }],
-					member_count: (guild.member_count || 0) + 1,
+					members: [...memberPreview, { ...member, user }],
+					member_count: memberCount + 1,
 					guild_hashes: {},
 					guild_scheduled_events: [],
 					joined_at: member.joined_at,