summary refs log tree commit diff
path: root/src/api/routes/channels
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-23 19:02:05 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-23 19:02:05 +0200
commitba0ba4b61ede1404454b8ab89bd9da61851f8a6e (patch)
tree254cf1238adea372014b55555e22db6637683d72 /src/api/routes/channels
parentMerge remote-tracking branch 'Puyodead1/patch/prettier-config' into staging (diff)
parentNew db migration script - multiplatform, fix mariadb migrations (diff)
downloadserver-ba0ba4b61ede1404454b8ab89bd9da61851f8a6e.tar.xz
Merge branch 'dev/cherry-plugins-improvements' into staging
Diffstat (limited to 'src/api/routes/channels')
-rw-r--r--src/api/routes/channels/#channel_id/followers.ts2
-rw-r--r--src/api/routes/channels/#channel_id/index.ts9
-rw-r--r--src/api/routes/channels/#channel_id/invites.ts72
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/ack.ts5
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/crosspost.ts2
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/index.ts112
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts82
-rw-r--r--src/api/routes/channels/#channel_id/messages/bulk-delete.ts7
-rw-r--r--src/api/routes/channels/#channel_id/messages/index.ts49
-rw-r--r--src/api/routes/channels/#channel_id/permissions.ts10
-rw-r--r--src/api/routes/channels/#channel_id/pins.ts14
-rw-r--r--src/api/routes/channels/#channel_id/purge.ts25
-rw-r--r--src/api/routes/channels/#channel_id/recipients.ts6
-rw-r--r--src/api/routes/channels/#channel_id/typing.ts4
-rw-r--r--src/api/routes/channels/#channel_id/webhooks.ts6
15 files changed, 199 insertions, 206 deletions
diff --git a/src/api/routes/channels/#channel_id/followers.ts b/src/api/routes/channels/#channel_id/followers.ts
index 641af4f8..c06db61b 100644
--- a/src/api/routes/channels/#channel_id/followers.ts
+++ b/src/api/routes/channels/#channel_id/followers.ts
@@ -1,4 +1,4 @@
-import { Router, Response, Request } from "express";
+import { Router } from "express";
 const router: Router = Router();
 // TODO:
 
diff --git a/src/api/routes/channels/#channel_id/index.ts b/src/api/routes/channels/#channel_id/index.ts
index bb8b868b..a65cf451 100644
--- a/src/api/routes/channels/#channel_id/index.ts
+++ b/src/api/routes/channels/#channel_id/index.ts
@@ -1,17 +1,16 @@
+import { route } from "@fosscord/api";
 import {
 	Channel,
 	ChannelDeleteEvent,
-	ChannelPermissionOverwriteType,
+	ChannelModifySchema,
 	ChannelType,
 	ChannelUpdateEvent,
 	emitEvent,
-	Recipient,
 	handleFile,
-	ChannelModifySchema
+	OrmUtils,
+	Recipient
 } from "@fosscord/util";
 import { Request, Response, Router } from "express";
-import { route } from "@fosscord/api";
-import { OrmUtils } from "@fosscord/util";
 
 const router: Router = Router();
 // TODO: delete channel
diff --git a/src/api/routes/channels/#channel_id/invites.ts b/src/api/routes/channels/#channel_id/invites.ts
index b5c65c0d..3a1d2666 100644
--- a/src/api/routes/channels/#channel_id/invites.ts
+++ b/src/api/routes/channels/#channel_id/invites.ts
@@ -1,45 +1,45 @@
-import { Router, Request, Response } from "express";
-import { HTTPError } from "@fosscord/util";
 import { route } from "@fosscord/api";
-import { random } from "@fosscord/api";
-import { Channel, Invite, InviteCreateEvent, emitEvent, User, Guild, PublicInviteRelation } from "@fosscord/util";
+import { Channel, emitEvent, Guild, HTTPError, Invite, InviteCreateEvent, OrmUtils, PublicInviteRelation, User } from "@fosscord/util";
+import { Request, Response, Router } from "express";
 import { isTextChannel } from "./messages";
-import { OrmUtils } from "@fosscord/util";
 
 const router: Router = Router();
 
-router.post("/", route({ body: "InviteCreateSchema", permission: "CREATE_INSTANT_INVITE", right: "CREATE_INVITES" }),
-			async (req: Request, res: Response) => {
-	const { user_id } = req;
-	const { channel_id } = req.params;
-	const channel = await Channel.findOneOrFail({ where: { id: channel_id }, select: ["id", "name", "type", "guild_id"] });
-	isTextChannel(channel.type);
-
-	if (!channel.guild_id) {
-		throw new HTTPError("This channel doesn't exist", 404);
+router.post(
+	"/",
+	route({ body: "InviteCreateSchema", permission: "CREATE_INSTANT_INVITE", right: "CREATE_INVITES" }),
+	async (req: Request, res: Response) => {
+		const { user_id } = req;
+		const { channel_id } = req.params;
+		const channel = await Channel.findOneOrFail({ where: { id: channel_id }, select: ["id", "name", "type", "guild_id"] });
+		isTextChannel(channel.type);
+
+		if (!channel.guild_id) {
+			throw new HTTPError("This channel doesn't exist", 404);
+		}
+		const { guild_id } = channel;
+
+		const expires_at = new Date(req.body.max_age * 1000 + Date.now());
+
+		const invite = await OrmUtils.mergeDeep(new Invite(), {
+			temporary: req.body.temporary || true,
+			max_uses: req.body.max_uses,
+			max_age: req.body.max_age,
+			expires_at,
+			guild_id,
+			channel_id,
+			inviter_id: user_id
+		}).save();
+		//TODO: check this, removed toJSON call
+		const data = JSON.parse(JSON.stringify(invite));
+		data.inviter = await User.getPublicUser(req.user_id);
+		data.guild = await Guild.findOne({ where: { id: guild_id } });
+		data.channel = channel;
+
+		await emitEvent({ event: "INVITE_CREATE", data, guild_id } as InviteCreateEvent);
+		res.status(201).send(data);
 	}
-	const { guild_id } = channel;
-
-	const expires_at = new Date(req.body.max_age * 1000 + Date.now());
-
-	const invite = await OrmUtils.mergeDeep(new Invite(),{
-		temporary: req.body.temporary || true,
-		max_uses: req.body.max_uses,
-		max_age: req.body.max_age,
-		expires_at,
-		guild_id,
-		channel_id,
-		inviter_id: user_id
-	}).save();
-	//TODO: check this, removed toJSON call
-	const data = JSON.parse(JSON.stringify(invite));
-	data.inviter = await User.getPublicUser(req.user_id);
-	data.guild = await Guild.findOne({ where: { id: guild_id } });
-	data.channel = channel;
-
-	await emitEvent({ event: "INVITE_CREATE", data, guild_id } as InviteCreateEvent);
-	res.status(201).send(data);
-});
+);
 
 router.get("/", route({ permission: "MANAGE_CHANNELS" }), async (req: Request, res: Response) => {
 	const { channel_id } = req.params;
diff --git a/src/api/routes/channels/#channel_id/messages/#message_id/ack.ts b/src/api/routes/channels/#channel_id/messages/#message_id/ack.ts
index 041f4d5e..5ebeed49 100644
--- a/src/api/routes/channels/#channel_id/messages/#message_id/ack.ts
+++ b/src/api/routes/channels/#channel_id/messages/#message_id/ack.ts
@@ -1,7 +1,6 @@
-import { emitEvent, getPermission, MessageAckEvent, ReadState, Snowflake } from "@fosscord/util";
-import { Request, Response, Router } from "express";
 import { route } from "@fosscord/api";
-import { OrmUtils } from "@fosscord/util";
+import { emitEvent, getPermission, MessageAckEvent, OrmUtils, ReadState } from "@fosscord/util";
+import { Request, Response, Router } from "express";
 
 const router = Router();
 
diff --git a/src/api/routes/channels/#channel_id/messages/#message_id/crosspost.ts b/src/api/routes/channels/#channel_id/messages/#message_id/crosspost.ts
index b2cb6763..fbbc65f0 100644
--- a/src/api/routes/channels/#channel_id/messages/#message_id/crosspost.ts
+++ b/src/api/routes/channels/#channel_id/messages/#message_id/crosspost.ts
@@ -1,5 +1,5 @@
-import { Router, Response, Request } from "express";
 import { route } from "@fosscord/api";
+import { Request, Response, Router } from "express";
 
 const router = Router();
 
diff --git a/src/api/routes/channels/#channel_id/messages/#message_id/index.ts b/src/api/routes/channels/#channel_id/messages/#message_id/index.ts
index d7e27062..b082e083 100644
--- a/src/api/routes/channels/#channel_id/messages/#message_id/index.ts
+++ b/src/api/routes/channels/#channel_id/messages/#message_id/index.ts
@@ -1,25 +1,22 @@
+import { handleMessage, postHandleMessage, route } from "@fosscord/api";
 import {
 	Attachment,
 	Channel,
-	Embed,
-	DiscordApiErrors,
 	emitEvent,
 	FosscordApiErrors,
 	getPermission,
 	getRights,
- 	Message,
+	HTTPError,
+	Message,
 	MessageCreateEvent,
+	MessageCreateSchema,
 	MessageDeleteEvent,
 	MessageUpdateEvent,
 	Snowflake,
-	uploadFile, 
-	MessageCreateSchema
+	uploadFile
 } from "@fosscord/util";
-import { Router, Response, Request } from "express";
+import { Request, Response, Router } from "express";
 import multer from "multer";
-import { route } from "@fosscord/api";
-import { handleMessage, postHandleMessage } from "@fosscord/api";
-import { HTTPError } from "@fosscord/util";
 
 const router = Router();
 // TODO: message content/embed string length limit
@@ -33,50 +30,53 @@ const messageUpload = multer({
 	storage: multer.memoryStorage()
 }); // max upload 50 mb
 
-router.patch("/", route({ body: "MessageCreateSchema", permission: "SEND_MESSAGES", right: "SEND_MESSAGES" }), async (req: Request, res: Response) => {
-	const { message_id, channel_id } = req.params;
-	let body = req.body as MessageCreateSchema;
+router.patch(
+	"/",
+	route({ body: "MessageCreateSchema", permission: "SEND_MESSAGES", right: "SEND_MESSAGES" }),
+	async (req: Request, res: Response) => {
+		const { message_id, channel_id } = req.params;
+		let body = req.body as MessageCreateSchema;
 
-	const message = await Message.findOneOrFail({ where: { id: message_id, channel_id }, relations: ["attachments"] });
+		const message = await Message.findOneOrFail({ where: { id: message_id, channel_id }, relations: ["attachments"] });
 
-	const permissions = await getPermission(req.user_id, undefined, channel_id);
-	
-	const rights = await getRights(req.user_id);
+		const permissions = await getPermission(req.user_id, undefined, channel_id);
 
-	if ((req.user_id !== message.author_id)) {
-		if (!rights.has("MANAGE_MESSAGES")) {
-			permissions.hasThrow("MANAGE_MESSAGES");
-			body = { flags: body.flags };
-// guild admins can only suppress embeds of other messages, no such restriction imposed to instance-wide admins
-		}
-	} else rights.hasThrow("SELF_EDIT_MESSAGES");
-
-	const new_message = await handleMessage({
-		...message,
-		// TODO: should message_reference be overridable?
-		// @ts-ignore
-		message_reference: message.message_reference,
-		...body,
-		author_id: message.author_id,
-		channel_id,
-		id: message_id,
-		edited_timestamp: new Date()
-	});
-
-	await Promise.all([
-		new_message!.save(),
-		await emitEvent({
-			event: "MESSAGE_UPDATE",
+		const rights = await getRights(req.user_id);
+
+		if (req.user_id !== message.author_id) {
+			if (!rights.has("MANAGE_MESSAGES")) {
+				permissions.hasThrow("MANAGE_MESSAGES");
+				body = { flags: body.flags };
+				// guild admins can only suppress embeds of other messages, no such restriction imposed to instance-wide admins
+			}
+		} else rights.hasThrow("SELF_EDIT_MESSAGES");
+
+		const new_message = await handleMessage({
+			...message,
+			// TODO: should message_reference be overridable?
+			// @ts-ignore
+			message_reference: message.message_reference,
+			...body,
+			author_id: message.author_id,
 			channel_id,
-			data: { ...new_message, nonce: undefined }
-		} as MessageUpdateEvent)
-	]);
+			id: message_id,
+			edited_timestamp: new Date()
+		});
 
-	postHandleMessage(message);
+		await Promise.all([
+			new_message!.save(),
+			await emitEvent({
+				event: "MESSAGE_UPDATE",
+				channel_id,
+				data: { ...new_message, nonce: undefined }
+			} as MessageUpdateEvent)
+		]);
 
-	return res.json(message);
-});
+		postHandleMessage(message);
 
+		return res.json(message);
+	}
+);
 
 // Backfill message with specific timestamp
 router.put(
@@ -94,7 +94,7 @@ router.put(
 		const { channel_id, message_id } = req.params;
 		let body = req.body as MessageCreateSchema;
 		const attachments: Attachment[] = [];
-		
+
 		const rights = await getRights(req.user_id);
 		rights.hasThrow("SEND_MESSAGES");
 
@@ -103,13 +103,13 @@ router.put(
 			throw new HTTPError("Message IDs must be positive integers", 400);
 		}
 
-		const snowflake = Snowflake.deconstruct(message_id)
+		const snowflake = Snowflake.deconstruct(message_id);
 		if (Date.now() < snowflake.timestamp) {
 			// message is in the future
 			throw FosscordApiErrors.CANNOT_BACKFILL_TO_THE_FUTURE;
 		}
 
-		const exists = await Message.findOne({ where: { id: message_id, channel_id: channel_id }});
+		const exists = await Message.findOne({ where: { id: message_id, channel_id: channel_id } });
 		if (exists) {
 			throw FosscordApiErrors.CANNOT_REPLACE_BY_BACKFILL;
 		}
@@ -136,19 +136,19 @@ router.put(
 			channel_id,
 			attachments,
 			edited_timestamp: undefined,
-			timestamp: new Date(snowflake.timestamp),
+			timestamp: new Date(snowflake.timestamp)
 		});
 
 		//Fix for the client bug
-		delete message.member
-		
+		delete message.member;
+
 		await Promise.all([
 			message.save(),
 			emitEvent({ event: "MESSAGE_CREATE", channel_id: channel_id, data: message } as MessageCreateEvent),
 			channel.save()
 		]);
 
-		postHandleMessage(message).catch((e) => { }); // no await as it shouldnt block the message send function and silently catch error
+		postHandleMessage(message).catch((e) => {}); // no await as it shouldnt block the message send function and silently catch error
 
 		return res.json(message);
 	}
@@ -160,7 +160,7 @@ router.get("/", route({ permission: "VIEW_CHANNEL" }), async (req: Request, res:
 	const message = await Message.findOneOrFail({ where: { id: message_id, channel_id }, relations: ["attachments"] });
 
 	const permissions = await getPermission(req.user_id, undefined, channel_id);
-	
+
 	if (message.author_id !== req.user_id) permissions.hasThrow("READ_MESSAGE_HISTORY");
 
 	return res.json(message);
@@ -171,10 +171,10 @@ router.delete("/", route({}), async (req: Request, res: Response) => {
 
 	const channel = await Channel.findOneOrFail({ where: { id: channel_id } });
 	const message = await Message.findOneOrFail({ where: { id: message_id } });
-	
+
 	const rights = await getRights(req.user_id);
 
-	if ((message.author_id !== req.user_id)) {
+	if (message.author_id !== req.user_id) {
 		if (!rights.has("MANAGE_MESSAGES")) {
 			const permission = await getPermission(req.user_id, channel.guild_id, channel_id);
 			permission.hasThrow("MANAGE_MESSAGES");
diff --git a/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts b/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts
index d0ab35bb..44de5c45 100644
--- a/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts
+++ b/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts
@@ -1,8 +1,10 @@
+import { route } from "@fosscord/api";
 import {
 	Channel,
 	emitEvent,
 	Emoji,
 	getPermission,
+	HTTPError,
 	Member,
 	Message,
 	MessageReactionAddEvent,
@@ -13,9 +15,7 @@ import {
 	PublicUserProjection,
 	User
 } from "@fosscord/util";
-import { route } from "@fosscord/api";
-import { Router, Response, Request } from "express";
-import { HTTPError } from "@fosscord/util";
+import { Request, Response, Router } from "express";
 import { In } from "typeorm";
 
 const router = Router();
@@ -101,48 +101,52 @@ router.get("/:emoji", route({ permission: "VIEW_CHANNEL" }), async (req: Request
 	res.json(users);
 });
 
-router.put("/:emoji/:user_id", route({ permission: "READ_MESSAGE_HISTORY", right: "SELF_ADD_REACTIONS" }), async (req: Request, res: Response) => {
-	const { message_id, channel_id, user_id } = req.params;
-	if (user_id !== "@me") throw new HTTPError("Invalid user");
-	const emoji = getEmoji(req.params.emoji);
-
-	const channel = await Channel.findOneOrFail({ where: { id: channel_id } });
-	const message = await Message.findOneOrFail({ where: { id: message_id, channel_id } });
-	const already_added = message.reactions.find((x) => (x.emoji.id === emoji.id && emoji.id) || x.emoji.name === emoji.name);
-
-	if (!already_added) req.permission!.hasThrow("ADD_REACTIONS");
-
-	if (emoji.id) {
-		const external_emoji = await Emoji.findOneOrFail({ where: { id: emoji.id } });
-		if (!already_added) req.permission!.hasThrow("USE_EXTERNAL_EMOJIS");
-		emoji.animated = external_emoji.animated;
-		emoji.name = external_emoji.name;
-	}
+router.put(
+	"/:emoji/:user_id",
+	route({ permission: "READ_MESSAGE_HISTORY", right: "SELF_ADD_REACTIONS" }),
+	async (req: Request, res: Response) => {
+		const { message_id, channel_id, user_id } = req.params;
+		if (user_id !== "@me") throw new HTTPError("Invalid user");
+		const emoji = getEmoji(req.params.emoji);
+
+		const channel = await Channel.findOneOrFail({ where: { id: channel_id } });
+		const message = await Message.findOneOrFail({ where: { id: message_id, channel_id } });
+		const already_added = message.reactions.find((x) => (x.emoji.id === emoji.id && emoji.id) || x.emoji.name === emoji.name);
+
+		if (!already_added) req.permission!.hasThrow("ADD_REACTIONS");
+
+		if (emoji.id) {
+			const external_emoji = await Emoji.findOneOrFail({ where: { id: emoji.id } });
+			if (!already_added) req.permission!.hasThrow("USE_EXTERNAL_EMOJIS");
+			emoji.animated = external_emoji.animated;
+			emoji.name = external_emoji.name;
+		}
 
-	if (already_added) {
-		if (already_added.user_ids.includes(req.user_id)) return res.sendStatus(204); // Do not throw an error ¯\_(ツ)_/¯ as discord also doesn't throw any error
-		already_added.count++;
-	} else message.reactions.push({ count: 1, emoji, user_ids: [req.user_id] });
+		if (already_added) {
+			if (already_added.user_ids.includes(req.user_id)) return res.sendStatus(204); // Do not throw an error ¯\_(ツ)_/¯ as discord also doesn't throw any error
+			already_added.count++;
+		} else message.reactions.push({ count: 1, emoji, user_ids: [req.user_id] });
 
-	await message.save();
+		await message.save();
 
-	const member = channel.guild_id && (await Member.findOneOrFail({ where: { id: req.user_id } }));
+		const member = channel.guild_id && (await Member.findOneOrFail({ where: { id: req.user_id } }));
 
-	await emitEvent({
-		event: "MESSAGE_REACTION_ADD",
-		channel_id,
-		data: {
-			user_id: req.user_id,
+		await emitEvent({
+			event: "MESSAGE_REACTION_ADD",
 			channel_id,
-			message_id,
-			guild_id: channel.guild_id,
-			emoji,
-			member
-		}
-	} as MessageReactionAddEvent);
+			data: {
+				user_id: req.user_id,
+				channel_id,
+				message_id,
+				guild_id: channel.guild_id,
+				emoji,
+				member
+			}
+		} as MessageReactionAddEvent);
 
-	res.sendStatus(204);
-});
+		res.sendStatus(204);
+	}
+);
 
 router.delete("/:emoji/:user_id", route({}), async (req: Request, res: Response) => {
 	let { message_id, channel_id, user_id } = req.params;
diff --git a/src/api/routes/channels/#channel_id/messages/bulk-delete.ts b/src/api/routes/channels/#channel_id/messages/bulk-delete.ts
index af44b522..561a40c0 100644
--- a/src/api/routes/channels/#channel_id/messages/bulk-delete.ts
+++ b/src/api/routes/channels/#channel_id/messages/bulk-delete.ts
@@ -1,7 +1,6 @@
-import { Router, Response, Request } from "express";
-import { Channel, Config, emitEvent, getPermission, getRights, MessageDeleteBulkEvent, Message } from "@fosscord/util";
-import { HTTPError } from "@fosscord/util";
 import { route } from "@fosscord/api";
+import { Channel, Config, emitEvent, getPermission, getRights, HTTPError, Message, MessageDeleteBulkEvent } from "@fosscord/util";
+import { Request, Response, Router } from "express";
 import { In } from "typeorm";
 
 const router: Router = Router();
@@ -13,7 +12,7 @@ export default router;
 // https://discord.com/developers/docs/resources/channel#bulk-delete-messages
 router.post("/", route({ body: "BulkDeleteSchema" }), async (req: Request, res: Response) => {
 	const { channel_id } = req.params;
-	const channel = await Channel.findOneOrFail({where:{ id: channel_id} });
+	const channel = await Channel.findOneOrFail({ where: { id: channel_id } });
 	if (!channel.guild_id) throw new HTTPError("Can't bulk delete dm channel messages", 400);
 
 	const rights = await getRights(req.user_id);
diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts
index 9ab0d97d..5fdcb6f9 100644
--- a/src/api/routes/channels/#channel_id/messages/index.ts
+++ b/src/api/routes/channels/#channel_id/messages/index.ts
@@ -1,4 +1,4 @@
-import { Router, Response, Request } from "express";
+import { handleMessage, postHandleMessage, route } from "@fosscord/api";
 import {
 	Attachment,
 	Channel,
@@ -7,16 +7,15 @@ import {
 	DmChannelDTO,
 	emitEvent,
 	getPermission,
-	getRights,
+	HTTPError,
+	Member,
 	Message,
 	MessageCreateEvent,
+	MessageCreateSchema,
 	Snowflake,
-	uploadFile,
-	Member,
-	MessageCreateSchema
+	uploadFile
 } from "@fosscord/util";
-import { HTTPError } from "@fosscord/util";
-import { handleMessage, postHandleMessage, route } from "@fosscord/api";
+import { Request, Response, Router } from "express";
 import multer from "multer";
 import { FindManyOptions, LessThan, MoreThan } from "typeorm";
 import { URL } from "url";
@@ -69,23 +68,20 @@ router.get("/", async (req: Request, res: Response) => {
 	permissions.hasThrow("VIEW_CHANNEL");
 	if (!permissions.has("READ_MESSAGE_HISTORY")) return res.json([]);
 
-	let query: FindManyOptions<Message> & { where: { id?: any; }; } = {
+	let query: FindManyOptions<Message> & { where: { id?: any } } = {
 		order: { id: "DESC" },
 		take: limit,
 		where: { channel_id },
 		relations: ["author", "webhook", "application", "mentions", "mention_roles", "mention_channels", "sticker_items", "attachments"]
 	};
-	
 
 	if (after) {
 		if (after > new Snowflake()) return res.status(422);
 		query.where.id = MoreThan(after);
-	}
-	else if (before) { 
+	} else if (before) {
 		if (before < req.params.channel_id) return res.status(422);
 		query.where.id = LessThan(before);
-	}
-	else if (around) {
+	} else if (around) {
 		query.where.id = [
 			MoreThan((BigInt(around) - BigInt(halfLimit)).toString()),
 			LessThan((BigInt(around) + BigInt(halfLimit)).toString())
@@ -110,15 +106,14 @@ router.get("/", async (req: Request, res: Response) => {
 				const uri = y.proxy_url.startsWith("http") ? y.proxy_url : `https://example.org${y.proxy_url}`;
 				y.proxy_url = `${endpoint == null ? "" : endpoint}${new URL(uri).pathname}`;
 			});
-			
+
 			/**
 			Some clients ( discord.js ) only check if a property exists within the response,
 			which causes erorrs when, say, the `application` property is `null`.
 			**/
-			
+
 			for (let curr in x) {
-				if (x[curr] === null)
-					delete x[curr];
+				if (x[curr] === null) delete x[curr];
 			}
 
 			return x;
@@ -130,7 +125,7 @@ router.get("/", async (req: Request, res: Response) => {
 const messageUpload = multer({
 	limits: {
 		fileSize: 1024 * 1024 * 100,
-		fields: 10,
+		fields: 10
 		// files: 1
 	},
 	storage: multer.memoryStorage()
@@ -162,16 +157,15 @@ router.post(
 
 		const channel = await Channel.findOneOrFail({ where: { id: channel_id }, relations: ["recipients", "recipients.user"] });
 		if (!channel.isWritable()) {
-			throw new HTTPError(`Cannot send messages to channel of type ${channel.type}`, 400)
+			throw new HTTPError(`Cannot send messages to channel of type ${channel.type}`, 400);
 		}
 
-		const files = req.files as Express.Multer.File[] ?? [];
+		const files = (req.files as Express.Multer.File[]) ?? [];
 		for (let currFile of files) {
 			try {
 				const file: any = await uploadFile(`/attachments/${channel.id}`, currFile);
 				attachments.push({ ...file, proxy_url: file.url });
-			}
-			catch (error) {
+			} catch (error) {
 				return res.status(400).json(error);
 			}
 		}
@@ -212,11 +206,11 @@ router.post(
 				})
 			);
 		}
-	
-	    //Defining member fields
+
+		//Defining member fields
 		var member = await Member.findOneOrFail({ where: { id: req.user_id }, relations: ["roles"] });
 		// TODO: This doesn't work either
-        // member.roles = member.roles.filter((role) => {
+		// member.roles = member.roles.filter((role) => {
 		// 	return role.id !== role.guild_id;
 		// }).map((role) => {
 		// 	return role.id;
@@ -225,7 +219,7 @@ router.post(
 		// TODO: Figure this out
 		// delete message.member.last_message_id;
 		// delete message.member.index;
-		
+
 		await Promise.all([
 			message.save(),
 			emitEvent({ event: "MESSAGE_CREATE", channel_id: channel_id, data: message } as MessageCreateEvent),
@@ -233,9 +227,8 @@ router.post(
 			channel.save()
 		]);
 
-		postHandleMessage(message).catch((e) => { }); // no await as it shouldnt block the message send function and silently catch error
+		postHandleMessage(message).catch((e) => {}); // no await as it shouldnt block the message send function and silently catch error
 
 		return res.json(message);
 	}
 );
-
diff --git a/src/api/routes/channels/#channel_id/permissions.ts b/src/api/routes/channels/#channel_id/permissions.ts
index 34052fe5..bd462ea6 100644
--- a/src/api/routes/channels/#channel_id/permissions.ts
+++ b/src/api/routes/channels/#channel_id/permissions.ts
@@ -1,17 +1,15 @@
+import { route } from "@fosscord/api";
 import {
 	Channel,
 	ChannelPermissionOverwrite,
 	ChannelPermissionOverwriteSchema,
-	ChannelPermissionOverwriteType,
 	ChannelUpdateEvent,
 	emitEvent,
-	getPermission,
+	HTTPError,
 	Member,
 	Role
 } from "@fosscord/util";
-import { Router, Response, Request } from "express";
-import { HTTPError } from "@fosscord/util";
-import { route } from "@fosscord/api";
+import { Request, Response, Router } from "express";
 
 const router: Router = Router();
 
@@ -22,7 +20,7 @@ router.put(
 		const { channel_id, overwrite_id } = req.params;
 		const body = req.body as ChannelPermissionOverwriteSchema;
 
-		let channel = await Channel.findOneOrFail({ where: {id: channel_id} });
+		let channel = await Channel.findOneOrFail({ where: { id: channel_id } });
 		if (!channel.guild_id) throw new HTTPError("Channel not found", 404);
 
 		if (body.type === 0) {
diff --git a/src/api/routes/channels/#channel_id/pins.ts b/src/api/routes/channels/#channel_id/pins.ts
index 003638c5..5c28feac 100644
--- a/src/api/routes/channels/#channel_id/pins.ts
+++ b/src/api/routes/channels/#channel_id/pins.ts
@@ -1,16 +1,6 @@
-import {
-	Channel,
-	ChannelPinsUpdateEvent,
-	Config,
-	emitEvent,
-	getPermission,
-	Message,
-	MessageUpdateEvent,
-	DiscordApiErrors
-} from "@fosscord/util";
-import { Router, Request, Response } from "express";
-import { HTTPError } from "@fosscord/util";
 import { route } from "@fosscord/api";
+import { Channel, ChannelPinsUpdateEvent, Config, DiscordApiErrors, emitEvent, Message, MessageUpdateEvent } from "@fosscord/util";
+import { Request, Response, Router } from "express";
 
 const router: Router = Router();
 
diff --git a/src/api/routes/channels/#channel_id/purge.ts b/src/api/routes/channels/#channel_id/purge.ts
index 1ef6e1d7..aebdb832 100644
--- a/src/api/routes/channels/#channel_id/purge.ts
+++ b/src/api/routes/channels/#channel_id/purge.ts
@@ -1,10 +1,18 @@
-import { HTTPError, PurgeSchema } from "@fosscord/util";
 import { route } from "@fosscord/api";
+import {
+	Channel,
+	Config,
+	emitEvent,
+	getPermission,
+	getRights,
+	HTTPError,
+	Message,
+	MessageDeleteBulkEvent,
+	PurgeSchema
+} from "@fosscord/util";
+import { Request, Response, Router } from "express";
+import { Between, FindManyOptions, In, Not } from "typeorm";
 import { isTextChannel } from "./messages";
-import { FindManyOptions, Between, Not } from "typeorm";
-import { Channel, Config, emitEvent, getPermission, getRights, Message, MessageDeleteBulkEvent } from "@fosscord/util";
-import { Router, Response, Request } from "express";
-import { In } from "typeorm";
 
 const router: Router = Router();
 
@@ -13,7 +21,12 @@ export default router;
 /**
 TODO: apply the delete bit by bit to prevent client and database stress
 **/
-router.post("/",route({ /*body: "PurgeSchema",*/ }), async (req: Request, res: Response) => {
+router.post(
+	"/",
+	route({
+		/*body: "PurgeSchema",*/
+	}),
+	async (req: Request, res: Response) => {
 		const { channel_id } = req.params;
 		const channel = await Channel.findOneOrFail({ where: { id: channel_id } });
 
diff --git a/src/api/routes/channels/#channel_id/recipients.ts b/src/api/routes/channels/#channel_id/recipients.ts
index 069212e2..276a0eda 100644
--- a/src/api/routes/channels/#channel_id/recipients.ts
+++ b/src/api/routes/channels/#channel_id/recipients.ts
@@ -1,4 +1,4 @@
-import { Request, Response, Router } from "express";
+import { route } from "@fosscord/api";
 import {
 	Channel,
 	ChannelRecipientAddEvent,
@@ -6,12 +6,12 @@ import {
 	DiscordApiErrors,
 	DmChannelDTO,
 	emitEvent,
+	OrmUtils,
 	PublicUserProjection,
 	Recipient,
 	User
 } from "@fosscord/util";
-import { route } from "@fosscord/api";
-import { OrmUtils } from "@fosscord/util";
+import { Request, Response, Router } from "express";
 
 const router: Router = Router();
 
diff --git a/src/api/routes/channels/#channel_id/typing.ts b/src/api/routes/channels/#channel_id/typing.ts
index 99460f6e..26d0fcfa 100644
--- a/src/api/routes/channels/#channel_id/typing.ts
+++ b/src/api/routes/channels/#channel_id/typing.ts
@@ -1,6 +1,6 @@
-import { Channel, emitEvent, Member, TypingStartEvent } from "@fosscord/util";
 import { route } from "@fosscord/api";
-import { Router, Request, Response } from "express";
+import { Channel, emitEvent, Member, TypingStartEvent } from "@fosscord/util";
+import { Request, Response, Router } from "express";
 
 const router: Router = Router();
 
diff --git a/src/api/routes/channels/#channel_id/webhooks.ts b/src/api/routes/channels/#channel_id/webhooks.ts
index b11c8eb9..38dcb869 100644
--- a/src/api/routes/channels/#channel_id/webhooks.ts
+++ b/src/api/routes/channels/#channel_id/webhooks.ts
@@ -1,9 +1,7 @@
-import { Router, Response, Request } from "express";
 import { route } from "@fosscord/api";
-import { Channel, Config, getPermission, trimSpecial, Webhook } from "@fosscord/util";
-import { HTTPError } from "@fosscord/util";
+import { Channel, Config, DiscordApiErrors, HTTPError, trimSpecial, Webhook } from "@fosscord/util";
+import { Request, Response, Router } from "express";
 import { isTextChannel } from "./messages/index";
-import { DiscordApiErrors } from "@fosscord/util";
 
 const router: Router = Router();
 //TODO: implement webhooks