summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-04-12 21:03:49 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-04-12 21:03:49 +1000
commit9a6390b9bdbb6eb7e3ea6360619a2879ce42cbe1 (patch)
treee55ca7e42e0a46975b605673587f249d5774e0b0
parentSet eslint env properly (diff)
downloadserver-9a6390b9bdbb6eb7e3ea6360619a2879ce42cbe1.tar.xz
Fix DC client throwing on GUILD_CREATE
-rw-r--r--src/util/dtos/ReadyGuildDTO.ts15
-rw-r--r--src/util/entities/Member.ts26
2 files changed, 28 insertions, 13 deletions
diff --git a/src/util/dtos/ReadyGuildDTO.ts b/src/util/dtos/ReadyGuildDTO.ts
index 2a99ea46..b21afe74 100644
--- a/src/util/dtos/ReadyGuildDTO.ts
+++ b/src/util/dtos/ReadyGuildDTO.ts
@@ -16,7 +16,14 @@
 	along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-import { Channel, Emoji, Guild, Member, Role, Sticker } from "../entities";
+import {
+	Channel,
+	Emoji,
+	Guild,
+	PublicMember,
+	Role,
+	Sticker,
+} from "../entities";
 
 export interface IReadyGuildDTO {
 	application_command_counts?: { 1: number; 2: number; 3: number }; // ????????????
@@ -28,7 +35,7 @@ export interface IReadyGuildDTO {
 	large: boolean | undefined;
 	lazy: boolean;
 	member_count: number | undefined;
-	members: Member[];
+	members: PublicMember[];
 	premium_subscription_count: number | undefined;
 	properties: {
 		name: string;
@@ -76,7 +83,7 @@ export class ReadyGuildDTO implements IReadyGuildDTO {
 	large: boolean | undefined;
 	lazy: boolean;
 	member_count: number | undefined;
-	members: Member[];
+	members: PublicMember[];
 	premium_subscription_count: number | undefined;
 	properties: {
 		name: string;
@@ -127,7 +134,7 @@ export class ReadyGuildDTO implements IReadyGuildDTO {
 		this.large = guild.large;
 		this.lazy = true; // ??????????
 		this.member_count = guild.member_count;
-		this.members = guild.members;
+		this.members = guild.members?.map((x) => x.toPublicMember());
 		this.premium_subscription_count = guild.premium_subscription_count;
 		this.properties = {
 			name: guild.name,
diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts
index cc2bf2a1..8c208202 100644
--- a/src/util/entities/Member.ts
+++ b/src/util/entities/Member.ts
@@ -330,17 +330,25 @@ export class Member extends BaseClassWithoutId {
 		});
 
 		const memberCount = await Member.count({ where: { guild_id } });
-		const memberPreview = await Member.find({
-			where: {
-				guild_id,
-				user: {
-					sessions: {
-						status: Not("invisible" as const), // lol typescript?
+
+		const memberPreview = (
+			await Member.find({
+				where: {
+					guild_id,
+					user: {
+						sessions: {
+							status: Not("invisible" as const), // lol typescript?
+						},
 					},
 				},
-			},
-			take: 10,
-		});
+				relations: ["user", "roles"],
+				take: 10,
+			})
+		).map((member) => ({
+			...member.toPublicMember(),
+			user: member.user.toPublicUser(),
+			roles: member.roles.map((x) => x.id),
+		}));
 
 		if (
 			await Member.count({