summary refs log tree commit diff
diff options
context:
space:
mode:
authorPuyodead1 <puyodead@protonmail.com>2022-08-29 11:11:40 -0400
committerPuyodead1 <puyodead@protonmail.com>2022-08-29 11:11:40 -0400
commitc2aba2910cb50211a91a057863ef0bd0497ceead (patch)
tree8fa7c143dd0f397ede278f688dc3d86c5195815e
parentOop, deprecated typeorm call (diff)
downloadserver-c2aba2910cb50211a91a057863ef0bd0497ceead.tar.xz
implement guild profiles and fix user profiles
-rw-r--r--assets/schemas.json120
-rw-r--r--src/api/routes/guilds/#guild_id/members/#member_id/index.ts7
-rw-r--r--src/api/routes/guilds/#guild_id/profile/index.ts30
-rw-r--r--src/api/routes/users/#id/profile.ts56
-rw-r--r--src/api/routes/users/@me/profile.ts34
-rw-r--r--src/cdn/Server.ts7
-rw-r--r--src/cdn/routes/guild-profiles.ts84
-rw-r--r--src/util/entities/Member.ts20
-rw-r--r--src/util/migrations/mariadb/1661785289467-guild-member-profiles.ts60
-rw-r--r--src/util/migrations/postgres/1661785263936-guild-member-profiles.ts63
-rw-r--r--src/util/migrations/sqlite/1661785235464-guild-member-profiles.ts136
-rw-r--r--src/util/schemas/MemberChangeProfileSchema.ts5
-rw-r--r--src/util/schemas/MemberChangeSchema.ts2
-rw-r--r--src/util/schemas/UserProfileModifySchema.ts5
-rw-r--r--src/util/schemas/index.ts2
15 files changed, 540 insertions, 91 deletions
diff --git a/assets/schemas.json b/assets/schemas.json
index 05650a4e..ce3e7360 100644
--- a/assets/schemas.json
+++ b/assets/schemas.json
@@ -94,88 +94,6 @@
 		"required": ["messages"],
 		"$schema": "http://json-schema.org/draft-07/schema#"
 	},
-	"ts.server.TypingInstallerResponse": {
-		"type": "object",
-		"properties": {
-			"kind": {
-				"enum": [
-					"action::invalidate",
-					"action::packageInstalled",
-					"action::set",
-					"event::beginInstallTypes",
-					"event::endInstallTypes",
-					"event::initializationFailed",
-					"event::typesRegistry"
-				],
-				"type": "string"
-			}
-		},
-		"additionalProperties": false,
-		"required": ["kind"],
-		"$schema": "http://json-schema.org/draft-07/schema#"
-	},
-	"ts.server.PackageInstalledResponse": {
-		"type": "object",
-		"properties": {
-			"kind": {
-				"type": "string",
-				"enum": ["action::packageInstalled"]
-			},
-			"success": {
-				"type": "boolean"
-			},
-			"message": {
-				"type": "string"
-			},
-			"projectName": {
-				"type": "string"
-			}
-		},
-		"additionalProperties": false,
-		"required": ["kind", "message", "projectName", "success"],
-		"$schema": "http://json-schema.org/draft-07/schema#"
-	},
-	"ts.server.InitializationFailedResponse": {
-		"type": "object",
-		"properties": {
-			"kind": {
-				"type": "string",
-				"enum": ["event::initializationFailed"]
-			},
-			"message": {
-				"type": "string"
-			},
-			"stack": {
-				"type": "string"
-			}
-		},
-		"additionalProperties": false,
-		"required": ["kind", "message"],
-		"$schema": "http://json-schema.org/draft-07/schema#"
-	},
-	"ts.server.ProjectResponse": {
-		"type": "object",
-		"properties": {
-			"projectName": {
-				"type": "string"
-			},
-			"kind": {
-				"enum": [
-					"action::invalidate",
-					"action::packageInstalled",
-					"action::set",
-					"event::beginInstallTypes",
-					"event::endInstallTypes",
-					"event::initializationFailed",
-					"event::typesRegistry"
-				],
-				"type": "string"
-			}
-		},
-		"additionalProperties": false,
-		"required": ["kind", "projectName"],
-		"$schema": "http://json-schema.org/draft-07/schema#"
-	},
 	"ChannelPermissionOverwriteSchema": {
 		"type": "object",
 		"additionalProperties": false,
@@ -696,6 +614,22 @@
 		"required": ["login", "password"],
 		"$schema": "http://json-schema.org/draft-07/schema#"
 	},
+	"MemberChangeProfileSchema": {
+		"type": "object",
+		"properties": {
+			"banner": {
+				"type": ["null", "string"]
+			},
+			"nick": {
+				"type": "string"
+			},
+			"bio": {
+				"type": "string"
+			}
+		},
+		"additionalProperties": false,
+		"$schema": "http://json-schema.org/draft-07/schema#"
+	},
 	"MemberChangeSchema": {
 		"type": "object",
 		"properties": {
@@ -704,6 +638,12 @@
 				"items": {
 					"type": "string"
 				}
+			},
+			"nick": {
+				"type": "string"
+			},
+			"avatar": {
+				"type": ["null", "string"]
 			}
 		},
 		"additionalProperties": false,
@@ -1113,6 +1053,22 @@
 		"additionalProperties": false,
 		"$schema": "http://json-schema.org/draft-07/schema#"
 	},
+	"UserProfileModifySchema": {
+		"type": "object",
+		"properties": {
+			"bio": {
+				"type": "string"
+			},
+			"accent_color": {
+				"type": ["null", "integer"]
+			},
+			"banner": {
+				"type": ["null", "string"]
+			}
+		},
+		"additionalProperties": false,
+		"$schema": "http://json-schema.org/draft-07/schema#"
+	},
 	"UserSettingsSchema": {
 		"type": "object",
 		"additionalProperties": false,
diff --git a/src/api/routes/guilds/#guild_id/members/#member_id/index.ts b/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
index 57152f9a..06474f3e 100644
--- a/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
+++ b/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
@@ -6,6 +6,7 @@ import {
 	getRights,
 	Guild,
 	GuildMemberUpdateEvent,
+	handleFile,
 	Member,
 	MemberChangeSchema,
 	OrmUtils,
@@ -30,7 +31,7 @@ router.patch("/", route({ body: "MemberChangeSchema" }), async (req: Request, re
 	if (member_id === "@me") member_id = req.user_id;
 	const body = req.body as MemberChangeSchema;
 
-	const member = await Member.findOneOrFail({ where: { id: member_id, guild_id }, relations: ["roles", "user"] });
+	let member = await Member.findOneOrFail({ where: { id: member_id, guild_id }, relations: ["roles", "user"] });
 	const permission = await getPermission(req.user_id, guild_id);
 	const everyone = await Role.findOneOrFail({ where: { guild_id: guild_id, name: "@everyone", position: 0 } });
 
@@ -41,6 +42,10 @@ router.patch("/", route({ body: "MemberChangeSchema" }), async (req: Request, re
 		member.roles = body.roles.map((x) => OrmUtils.mergeDeep(new Role(), { id: x })); // foreign key constraint will fail if role doesn't exist
 	}
 
+	if (body.avatar) body.avatar = await handleFile(`/guilds/${guild_id}/users/${member_id}/avatars`, body.avatar as string);
+
+	member = await OrmUtils.mergeDeep(member, body);
+
 	await member.save();
 
 	member.roles = member.roles.filter((x) => x.id !== everyone.id);
diff --git a/src/api/routes/guilds/#guild_id/profile/index.ts b/src/api/routes/guilds/#guild_id/profile/index.ts
new file mode 100644
index 00000000..ddc30943
--- /dev/null
+++ b/src/api/routes/guilds/#guild_id/profile/index.ts
@@ -0,0 +1,30 @@
+import { route } from "@fosscord/api";
+import { emitEvent, GuildMemberUpdateEvent, handleFile, Member, MemberChangeProfileSchema, OrmUtils } from "@fosscord/util";
+import { Request, Response, Router } from "express";
+
+const router = Router();
+
+router.patch("/:member_id", route({ body: "MemberChangeProfileSchema" }), async (req: Request, res: Response) => {
+	let { guild_id, member_id } = req.params;
+	if (member_id === "@me") member_id = req.user_id;
+	const body = req.body as MemberChangeProfileSchema;
+
+	let member = await Member.findOneOrFail({ where: { id: req.user_id, guild_id }, relations: ["roles", "user"] });
+
+	if (body.banner) body.banner = await handleFile(`/guilds/${guild_id}/users/${req.user_id}/avatars`, body.banner as string);
+
+	member = await OrmUtils.mergeDeep(member, body);
+
+	await member.save();
+
+	// do not use promise.all as we have to first write to db before emitting the event to catch errors
+	await emitEvent({
+		event: "GUILD_MEMBER_UPDATE",
+		guild_id,
+		data: { ...member, roles: member.roles.map((x) => x.id) }
+	} as GuildMemberUpdateEvent);
+
+	res.json(member);
+});
+
+export default router;
diff --git a/src/api/routes/users/#id/profile.ts b/src/api/routes/users/#id/profile.ts
index 766c9880..0b9107e2 100644
--- a/src/api/routes/users/#id/profile.ts
+++ b/src/api/routes/users/#id/profile.ts
@@ -1,5 +1,16 @@
 import { route } from "@fosscord/api";
-import { Member, PublicConnectedAccount, User, UserPublic } from "@fosscord/util";
+import {
+	emitEvent,
+	handleFile,
+	Member,
+	OrmUtils,
+	PrivateUserProjection,
+	PublicConnectedAccount,
+	User,
+	UserProfileModifySchema,
+	UserPublic,
+	UserUpdateEvent
+} from "@fosscord/util";
 import { Request, Response, Router } from "express";
 
 const router: Router = Router();
@@ -64,10 +75,10 @@ router.get("/", route({ test: { response: { body: "UserProfileResponse" } } }),
 
 	const guildMemberDto = guild_member
 		? {
-				avatar: user.avatar, // TODO
-				banner: user.banner, // TODO
-				bio: req.user_bot ? null : user.bio, // TODO
-				communication_disabled_until: null, // TODO
+				avatar: guild_member.avatar,
+				banner: guild_member.banner,
+				bio: req.user_bot ? null : guild_member.bio,
+				communication_disabled_until: guild_member.communication_disabled_until,
 				deaf: guild_member.deaf,
 				flags: user.flags,
 				is_pending: guild_member.pending,
@@ -81,13 +92,46 @@ router.get("/", route({ test: { response: { body: "UserProfileResponse" } } }),
 		  }
 		: undefined;
 
+	const guildMemberProfile = {
+		accent_color: null,
+		banner: guild_member?.banner || null,
+		bio: guild_member?.bio || "",
+		guild_id
+	};
 	res.json({
 		connected_accounts: user.connected_accounts,
 		premium_guild_since: premium_guild_since, // TODO
 		premium_since: user.premium_since, // TODO
 		mutual_guilds: mutual_guilds, // TODO {id: "", nick: null} when ?with_mutual_guilds=true
 		user: userDto,
-		guild_member: guildMemberDto
+		guild_member: guildMemberDto,
+		guild_member_profile: guildMemberProfile
+	});
+});
+
+router.patch("/", route({ body: "UserProfileModifySchema" }), async (req: Request, res: Response) => {
+	const body = req.body as UserProfileModifySchema;
+
+	if (body.banner) body.banner = await handleFile(`/banners/${req.user_id}`, body.banner as string);
+	let user = await User.findOneOrFail({ where: { id: req.user_id }, select: [...PrivateUserProjection, "data"] });
+
+	user = OrmUtils.mergeDeep(user, body);
+	await user.save();
+
+	// @ts-ignore
+	delete user.data;
+
+	// TODO: send update member list event in gateway
+	await emitEvent({
+		event: "USER_UPDATE",
+		user_id: req.user_id,
+		data: user
+	} as UserUpdateEvent);
+
+	res.json({
+		accent_color: user.accent_color,
+		bio: user.bio,
+		banner: user.banner
 	});
 });
 
diff --git a/src/api/routes/users/@me/profile.ts b/src/api/routes/users/@me/profile.ts
new file mode 100644
index 00000000..95aa8e6b
--- /dev/null
+++ b/src/api/routes/users/@me/profile.ts
@@ -0,0 +1,34 @@
+// import { route } from "@fosscord/api";
+// import { emitEvent, handleFile, OrmUtils, PrivateUserProjection, User, UserUpdateEvent } from "@fosscord/util";
+// import { Request, Response, Router } from "express";
+// import { UserProfileModifySchema } from "../../../../util/schemas/UserProfileModifySchema";
+
+// const router: Router = Router();
+
+// router.patch("/", route({ body: "UserProfileModifySchema" }), async (req: Request, res: Response) => {
+// 	const body = req.body as UserProfileModifySchema;
+
+// 	if (body.banner) body.banner = await handleFile(`/banners/${req.user_id}`, body.banner as string);
+// 	let user = await User.findOneOrFail({ where: { id: req.user_id }, select: [...PrivateUserProjection, "data"] });
+
+// 	user = OrmUtils.mergeDeep(user, body);
+// 	await user.save();
+
+// 	// @ts-ignore
+// 	delete user.data;
+
+// 	// TODO: send update member list event in gateway
+// 	await emitEvent({
+// 		event: "USER_UPDATE",
+// 		user_id: req.user_id,
+// 		data: user
+// 	} as UserUpdateEvent);
+
+// 	res.json({
+// 		accent_color: user.accent_color,
+// 		bio: user.bio,
+// 		banner: user.banner
+// 	});
+// });
+
+// export default router;
diff --git a/src/cdn/Server.ts b/src/cdn/Server.ts
index ec5edc68..9cedaa02 100644
--- a/src/cdn/Server.ts
+++ b/src/cdn/Server.ts
@@ -3,6 +3,7 @@ import bodyParser from "body-parser";
 import { Server, ServerOptions } from "lambert-server";
 import path from "path";
 import avatarsRoute from "./routes/avatars";
+import guildProfilesRoute from "./routes/guild-profiles";
 import iconsRoute from "./routes/role-icons";
 
 export interface CDNServerOptions extends ServerOptions {}
@@ -65,6 +66,12 @@ export class CDNServer extends Server {
 		this.app.use("/channel-icons/", avatarsRoute);
 		this.log("verbose", "[Server] Route /channel-icons registered");
 
+		this.app.use("/guilds/:guild_id/users/:user_id/avatars", guildProfilesRoute);
+		this.log("verbose", "[Server] Route /guilds/avatars registered");
+
+		this.app.use("/guilds/:guild_id/users/:user_id/banners", guildProfilesRoute);
+		this.log("verbose", "[Server] Route /guilds/banners registered");
+
 		return super.start();
 	}
 
diff --git a/src/cdn/routes/guild-profiles.ts b/src/cdn/routes/guild-profiles.ts
new file mode 100644
index 00000000..32c05ad9
--- /dev/null
+++ b/src/cdn/routes/guild-profiles.ts
@@ -0,0 +1,84 @@
+import { Config, HTTPError, Snowflake } from "@fosscord/util";
+import crypto from "crypto";
+import { Request, Response, Router } from "express";
+import FileType from "file-type";
+import { multer } from "../util/multer";
+import { storage } from "../util/Storage";
+
+// TODO: check premium and animated pfp are allowed in the config
+// TODO: generate different sizes of icon
+// TODO: generate different image types of icon
+// TODO: delete old icons
+
+const ANIMATED_MIME_TYPES = ["image/apng", "image/gif", "image/gifv"];
+const STATIC_MIME_TYPES = ["image/png", "image/jpeg", "image/webp", "image/svg+xml", "image/svg"];
+const ALLOWED_MIME_TYPES = [...ANIMATED_MIME_TYPES, ...STATIC_MIME_TYPES];
+
+const router = Router();
+
+router.post("/", multer.single("file"), async (req: Request, res: Response) => {
+	if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature");
+	if (!req.file) throw new HTTPError("Missing file");
+	const { buffer, mimetype, size, originalname, fieldname } = req.file;
+	const { guild_id, user_id } = req.params;
+
+	let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex");
+
+	const type = await FileType.fromBuffer(buffer);
+	if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type");
+	if (ANIMATED_MIME_TYPES.includes(type.mime)) hash = `a_${hash}`; // animated icons have a_ infront of the hash
+
+	const path = `guilds/${guild_id}/users/${user_id}/avatars/${hash}`;
+	const endpoint = Config.get().cdn.endpointPublic || "http://localhost:3003";
+
+	await storage.set(path, buffer);
+
+	return res.json({
+		id: hash,
+		content_type: type.mime,
+		size,
+		url: `${endpoint}${req.baseUrl}/${user_id}/${hash}`
+	});
+});
+
+router.get("/", async (req: Request, res: Response) => {
+	let { guild_id, user_id } = req.params;
+	user_id = user_id.split(".")[0]; // remove .file extension
+	const path = `guilds/${guild_id}/users/${user_id}/avatars`;
+
+	const file = await storage.get(path);
+	if (!file) throw new HTTPError("not found", 404);
+	const type = await FileType.fromBuffer(file);
+
+	res.set("Content-Type", type?.mime);
+	res.set("Cache-Control", "public, max-age=31536000");
+
+	return res.send(file);
+});
+
+router.get("/:hash", async (req: Request, res: Response) => {
+	let { guild_id, user_id, hash } = req.params;
+	hash = hash.split(".")[0]; // remove .file extension
+	const path = `guilds/${guild_id}/users/${user_id}/avatars/${hash}`;
+
+	const file = await storage.get(path);
+	if (!file) throw new HTTPError("not found", 404);
+	const type = await FileType.fromBuffer(file);
+
+	res.set("Content-Type", type?.mime);
+	res.set("Cache-Control", "public, max-age=31536000");
+
+	return res.send(file);
+});
+
+router.delete("/:id", async (req: Request, res: Response) => {
+	if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature");
+	const { guild_id, user_id, id } = req.params;
+	const path = `guilds/${guild_id}/users/${user_id}/avatars/${id}`;
+
+	await storage.delete(path);
+
+	return res.send({ success: true });
+});
+
+export default router;
diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts
index 42a014d4..a2a7b8cb 100644
--- a/src/util/entities/Member.ts
+++ b/src/util/entities/Member.ts
@@ -94,7 +94,19 @@ export class Member extends BaseClassWithoutId {
 	// do not auto-kick force-joined members just because their joiners left the server
 	}) **/
 	@Column({ nullable: true })
-	joined_by?: string;
+	joined_by: string;
+
+	@Column({ nullable: true })
+	avatar: string;
+
+	@Column({ nullable: true })
+	banner: string;
+
+	@Column()
+	bio: string;
+
+	@Column({ nullable: true })
+	communication_disabled_until: Date;
 
 	// TODO: add this when we have proper read receipts
 	// @Column({ type: "simple-json" })
@@ -243,7 +255,11 @@ export class Member extends BaseClassWithoutId {
 			premium_since: null,
 			deaf: false,
 			mute: false,
-			pending: false
+			pending: false,
+			avatar: null,
+			banner: null,
+			bio: "",
+			communication_disabled_until: null
 		};
 		//TODO: check for bugs
 		if (guild.member_count) guild.member_count++;
diff --git a/src/util/migrations/mariadb/1661785289467-guild-member-profiles.ts b/src/util/migrations/mariadb/1661785289467-guild-member-profiles.ts
new file mode 100644
index 00000000..223876f9
--- /dev/null
+++ b/src/util/migrations/mariadb/1661785289467-guild-member-profiles.ts
@@ -0,0 +1,60 @@
+import { MigrationInterface, QueryRunner } from "typeorm";
+
+export class guildMemberProfiles1661785289467 implements MigrationInterface {
+    name = 'guildMemberProfiles1661785289467'
+
+    public async up(queryRunner: QueryRunner): Promise<void> {
+        await queryRunner.query(`
+            ALTER TABLE \`connected_accounts\` DROP COLUMN \`external_id\`
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`connected_accounts\` DROP COLUMN \`integrations\`
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`members\`
+            ADD \`avatar\` varchar(255) NULL
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`members\`
+            ADD \`banner\` varchar(255) NULL
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`members\`
+            ADD \`bio\` varchar(255) NOT NULL
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`members\`
+            ADD \`communication_disabled_until\` datetime NULL
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`connected_accounts\` CHANGE \`access_token\` \`access_token\` varchar(255) NOT NULL
+        `);
+    }
+
+    public async down(queryRunner: QueryRunner): Promise<void> {
+        await queryRunner.query(`
+            ALTER TABLE \`connected_accounts\` CHANGE \`access_token\` \`access_token\` varchar(255) NULL
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`members\` DROP COLUMN \`communication_disabled_until\`
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`members\` DROP COLUMN \`bio\`
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`members\` DROP COLUMN \`banner\`
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`members\` DROP COLUMN \`avatar\`
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`connected_accounts\`
+            ADD \`integrations\` text NOT NULL
+        `);
+        await queryRunner.query(`
+            ALTER TABLE \`connected_accounts\`
+            ADD \`external_id\` varchar(255) NOT NULL
+        `);
+    }
+
+}
diff --git a/src/util/migrations/postgres/1661785263936-guild-member-profiles.ts b/src/util/migrations/postgres/1661785263936-guild-member-profiles.ts
new file mode 100644
index 00000000..af0f2a33
--- /dev/null
+++ b/src/util/migrations/postgres/1661785263936-guild-member-profiles.ts
@@ -0,0 +1,63 @@
+import { MigrationInterface, QueryRunner } from "typeorm";
+
+export class guildMemberProfiles1661785263936 implements MigrationInterface {
+    name = 'guildMemberProfiles1661785263936'
+
+    public async up(queryRunner: QueryRunner): Promise<void> {
+        await queryRunner.query(`
+            ALTER TABLE "connected_accounts" DROP COLUMN "external_id"
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "connected_accounts" DROP COLUMN "integrations"
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "members"
+            ADD "avatar" character varying
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "members"
+            ADD "banner" character varying
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "members"
+            ADD "bio" character varying NOT NULL
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "members"
+            ADD "communication_disabled_until" TIMESTAMP
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "connected_accounts"
+            ALTER COLUMN "access_token"
+            SET NOT NULL
+        `);
+    }
+
+    public async down(queryRunner: QueryRunner): Promise<void> {
+        await queryRunner.query(`
+            ALTER TABLE "connected_accounts"
+            ALTER COLUMN "access_token" DROP NOT NULL
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "members" DROP COLUMN "communication_disabled_until"
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "members" DROP COLUMN "bio"
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "members" DROP COLUMN "banner"
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "members" DROP COLUMN "avatar"
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "connected_accounts"
+            ADD "integrations" text NOT NULL
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "connected_accounts"
+            ADD "external_id" character varying NOT NULL
+        `);
+    }
+
+}
diff --git a/src/util/migrations/sqlite/1661785235464-guild-member-profiles.ts b/src/util/migrations/sqlite/1661785235464-guild-member-profiles.ts
new file mode 100644
index 00000000..9a3b648d
--- /dev/null
+++ b/src/util/migrations/sqlite/1661785235464-guild-member-profiles.ts
@@ -0,0 +1,136 @@
+import { MigrationInterface, QueryRunner } from "typeorm";
+
+export class guildMemberProfiles1661785235464 implements MigrationInterface {
+    name = 'guildMemberProfiles1661785235464'
+
+    public async up(queryRunner: QueryRunner): Promise<void> {
+        await queryRunner.query(`
+            DROP INDEX "IDX_bb2bf9386ac443afbbbf9f12d3"
+        `);
+        await queryRunner.query(`
+            CREATE TABLE "temporary_members" (
+                "index" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
+                "id" varchar NOT NULL,
+                "guild_id" varchar NOT NULL,
+                "nick" varchar,
+                "joined_at" datetime NOT NULL,
+                "premium_since" datetime,
+                "deaf" boolean NOT NULL,
+                "mute" boolean NOT NULL,
+                "pending" boolean NOT NULL,
+                "settings" text NOT NULL,
+                "last_message_id" varchar,
+                "joined_by" varchar,
+                "avatar" varchar,
+                "banner" varchar,
+                "bio" varchar NOT NULL,
+                "communication_disabled_until" datetime,
+                CONSTRAINT "FK_28b53062261b996d9c99fa12404" FOREIGN KEY ("id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
+                CONSTRAINT "FK_16aceddd5b89825b8ed6029ad1c" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
+            )
+        `);
+        await queryRunner.query(`
+            INSERT INTO "temporary_members"(
+                    "index",
+                    "id",
+                    "guild_id",
+                    "nick",
+                    "joined_at",
+                    "premium_since",
+                    "deaf",
+                    "mute",
+                    "pending",
+                    "settings",
+                    "last_message_id",
+                    "joined_by"
+                )
+            SELECT "index",
+                "id",
+                "guild_id",
+                "nick",
+                "joined_at",
+                "premium_since",
+                "deaf",
+                "mute",
+                "pending",
+                "settings",
+                "last_message_id",
+                "joined_by"
+            FROM "members"
+        `);
+        await queryRunner.query(`
+            DROP TABLE "members"
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "temporary_members"
+                RENAME TO "members"
+        `);
+        await queryRunner.query(`
+            CREATE UNIQUE INDEX "IDX_bb2bf9386ac443afbbbf9f12d3" ON "members" ("id", "guild_id")
+        `);
+    }
+
+    public async down(queryRunner: QueryRunner): Promise<void> {
+        await queryRunner.query(`
+            DROP INDEX "IDX_bb2bf9386ac443afbbbf9f12d3"
+        `);
+        await queryRunner.query(`
+            ALTER TABLE "members"
+                RENAME TO "temporary_members"
+        `);
+        await queryRunner.query(`
+            CREATE TABLE "members" (
+                "index" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
+                "id" varchar NOT NULL,
+                "guild_id" varchar NOT NULL,
+                "nick" varchar,
+                "joined_at" datetime NOT NULL,
+                "premium_since" datetime,
+                "deaf" boolean NOT NULL,
+                "mute" boolean NOT NULL,
+                "pending" boolean NOT NULL,
+                "settings" text NOT NULL,
+                "last_message_id" varchar,
+                "joined_by" varchar,
+                CONSTRAINT "FK_28b53062261b996d9c99fa12404" FOREIGN KEY ("id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
+                CONSTRAINT "FK_16aceddd5b89825b8ed6029ad1c" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
+            )
+        `);
+        await queryRunner.query(`
+            INSERT INTO "members"(
+                    "index",
+                    "id",
+                    "guild_id",
+                    "nick",
+                    "joined_at",
+                    "premium_since",
+                    "deaf",
+                    "mute",
+                    "pending",
+                    "settings",
+                    "last_message_id",
+                    "joined_by"
+                )
+            SELECT "index",
+                "id",
+                "guild_id",
+                "nick",
+                "joined_at",
+                "premium_since",
+                "deaf",
+                "mute",
+                "pending",
+                "settings",
+                "last_message_id",
+                "joined_by"
+            FROM "temporary_members"
+        `);
+        await queryRunner.query(`
+            DROP TABLE "temporary_members"
+        `);
+        await queryRunner.query(`
+            CREATE UNIQUE INDEX "IDX_bb2bf9386ac443afbbbf9f12d3" ON "members" ("id", "guild_id")
+        `);
+    }
+
+}
diff --git a/src/util/schemas/MemberChangeProfileSchema.ts b/src/util/schemas/MemberChangeProfileSchema.ts
new file mode 100644
index 00000000..3e85174d
--- /dev/null
+++ b/src/util/schemas/MemberChangeProfileSchema.ts
@@ -0,0 +1,5 @@
+export interface MemberChangeProfileSchema {
+	banner?: string | null;
+	nick?: string;
+	bio?: string;
+}
diff --git a/src/util/schemas/MemberChangeSchema.ts b/src/util/schemas/MemberChangeSchema.ts
index db434538..0cbab4a3 100644
--- a/src/util/schemas/MemberChangeSchema.ts
+++ b/src/util/schemas/MemberChangeSchema.ts
@@ -1,3 +1,5 @@
 export interface MemberChangeSchema {
 	roles?: string[];
+	nick?: string;
+	avatar?: string | null;
 }
diff --git a/src/util/schemas/UserProfileModifySchema.ts b/src/util/schemas/UserProfileModifySchema.ts
new file mode 100644
index 00000000..33a372c9
--- /dev/null
+++ b/src/util/schemas/UserProfileModifySchema.ts
@@ -0,0 +1,5 @@
+export interface UserProfileModifySchema {
+	bio?: string;
+	accent_color?: number | null;
+	banner?: string | null;
+}
diff --git a/src/util/schemas/index.ts b/src/util/schemas/index.ts
index a15ab4b0..3770daf0 100644
--- a/src/util/schemas/index.ts
+++ b/src/util/schemas/index.ts
@@ -17,6 +17,7 @@ export * from "./IdentifySchema";
 export * from "./InviteCreateSchema";
 export * from "./LazyRequestSchema";
 export * from "./LoginSchema";
+export * from "./MemberChangeProfileSchema";
 export * from "./MemberChangeSchema";
 export * from "./MemberNickChangeSchema";
 export * from "./MessageAcknowledgeSchema";
@@ -36,6 +37,7 @@ export * from "./TotpDisableSchema";
 export * from "./TotpEnableSchema";
 export * from "./TotpSchema";
 export * from "./UserModifySchema";
+export * from "./UserProfileModifySchema";
 export * from "./UserSettingsSchema";
 export * from "./VanityUrlSchema";
 export * from "./VoiceStateUpdateSchema";