summary refs log tree commit diff
path: root/api/src/routes/channels/#channel_id/messages/bulk-delete.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-24 16:35:04 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-24 16:35:04 +0200
commitef4d4a318176c3e572adc17427a8b8c728a618ab (patch)
treed95fedbf18b7b7438613b08b72eb30fa5fca8921 /api/src/routes/channels/#channel_id/messages/bulk-delete.ts
parent:sparkles: typeorm entities (diff)
downloadserver-ef4d4a318176c3e572adc17427a8b8c728a618ab.tar.xz
:construction: api
Diffstat (limited to 'api/src/routes/channels/#channel_id/messages/bulk-delete.ts')
-rw-r--r--api/src/routes/channels/#channel_id/messages/bulk-delete.ts6
1 files changed, 3 insertions, 3 deletions
diff --git a/api/src/routes/channels/#channel_id/messages/bulk-delete.ts b/api/src/routes/channels/#channel_id/messages/bulk-delete.ts
index 8132462f..028a5d73 100644
--- a/api/src/routes/channels/#channel_id/messages/bulk-delete.ts
+++ b/api/src/routes/channels/#channel_id/messages/bulk-delete.ts
@@ -1,5 +1,5 @@
 import { Router, Response, Request } from "express";
-import { ChannelModel, Config, emitEvent, getPermission, MessageDeleteBulkEvent, MessageModel } from "@fosscord/util";
+import { Channel, Config, emitEvent, getPermission, MessageDeleteBulkEvent, Message } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 
 import { check } from "../../../../util/instanceOf";
@@ -13,7 +13,7 @@ export default router;
 // https://discord.com/developers/docs/resources/channel#bulk-delete-messages
 router.post("/", check({ messages: [String] }), async (req: Request, res: Response) => {
 	const { channel_id } = req.params;
-	const channel = await ChannelModel.findOne({ id: channel_id }, { permission_overwrites: true, guild_id: true }).exec();
+	const channel = await Channel.findOneOrFail({ id: channel_id }, { permission_overwrites: true, guild_id: true });
 	if (!channel.guild_id) throw new HTTPError("Can't bulk delete dm channel messages", 400);
 
 	const permission = await getPermission(req.user_id, channel?.guild_id, channel_id, { channel });
@@ -25,7 +25,7 @@ router.post("/", check({ messages: [String] }), async (req: Request, res: Respon
 	if (messages.length < 2) throw new HTTPError("You must at least specify 2 messages to bulk delete");
 	if (messages.length > maxBulkDelete) throw new HTTPError(`You cannot delete more than ${maxBulkDelete} messages`);
 
-	await MessageModel.deleteMany({ id: { $in: messages } }).exec();
+	await Message.deleteMany({ id: { $in: messages } });
 
 	await emitEvent({
 		event: "MESSAGE_DELETE_BULK",