summary refs log tree commit diff
path: root/src/api/routes/channels/#channel_id/pins.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/routes/channels/#channel_id/pins.ts')
-rw-r--r--src/api/routes/channels/#channel_id/pins.ts8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/api/routes/channels/#channel_id/pins.ts b/src/api/routes/channels/#channel_id/pins.ts
index f48e0ff5..28419383 100644
--- a/src/api/routes/channels/#channel_id/pins.ts
+++ b/src/api/routes/channels/#channel_id/pins.ts
@@ -21,13 +21,11 @@ import {
 	ChannelPinsUpdateEvent,
 	Config,
 	emitEvent,
-	getPermission,
 	Message,
 	MessageUpdateEvent,
 	DiscordApiErrors,
 } from "@fosscord/util";
 import { Router, Request, Response } from "express";
-import { HTTPError } from "lambert-server";
 import { route } from "@fosscord/api";
 
 const router: Router = Router();
@@ -43,7 +41,7 @@ router.put(
 		});
 
 		// * in dm channels anyone can pin messages -> only check for guilds
-		if (message.guild_id) req.permission!.hasThrow("MANAGE_MESSAGES");
+		if (message.guild_id) req.permission?.hasThrow("MANAGE_MESSAGES");
 
 		const pinned_count = await Message.count({
 			where: { channel: { id: channel_id }, pinned: true },
@@ -83,7 +81,7 @@ router.delete(
 		const channel = await Channel.findOneOrFail({
 			where: { id: channel_id },
 		});
-		if (channel.guild_id) req.permission!.hasThrow("MANAGE_MESSAGES");
+		if (channel.guild_id) req.permission?.hasThrow("MANAGE_MESSAGES");
 
 		const message = await Message.findOneOrFail({
 			where: { id: message_id },
@@ -120,7 +118,7 @@ router.get(
 	async (req: Request, res: Response) => {
 		const { channel_id } = req.params;
 
-		let pins = await Message.find({
+		const pins = await Message.find({
 			where: { channel_id: channel_id, pinned: true },
 		});