summary refs log tree commit diff
path: root/api/src/routes/guilds/#guild_id/delete.ts
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/routes/guilds/#guild_id/delete.ts')
-rw-r--r--api/src/routes/guilds/#guild_id/delete.ts19
1 files changed, 9 insertions, 10 deletions
diff --git a/api/src/routes/guilds/#guild_id/delete.ts b/api/src/routes/guilds/#guild_id/delete.ts
index a53271ce..043260e9 100644
--- a/api/src/routes/guilds/#guild_id/delete.ts
+++ b/api/src/routes/guilds/#guild_id/delete.ts
@@ -1,4 +1,4 @@
-import { Channel, emitEvent, EmojiModel, GuildDeleteEvent, Guild, InviteModel, Member, Message, Role, User } from "@fosscord/util";
+import { Channel, emitEvent, GuildDeleteEvent, Guild, Member, Message, Role, Invite, Emoji } from "@fosscord/util";
 import { Router, Request, Response } from "express";
 import { HTTPError } from "lambert-server";
 
@@ -9,7 +9,7 @@ const router = Router();
 router.post("/", async (req: Request, res: Response) => {
 	var { guild_id } = req.params;
 
-	const guild = await Guild.findOneOrFail({ id: guild_id }, "owner_id");
+	const guild = await Guild.findOneOrFail({ where: { id: guild_id }, select: ["owner_id"] });
 	if (guild.owner_id !== req.user_id) throw new HTTPError("You are not the owner of this guild", 401);
 
 	await emitEvent({
@@ -21,14 +21,13 @@ router.post("/", async (req: Request, res: Response) => {
 	} as GuildDeleteEvent);
 
 	await Promise.all([
-		Guild.deleteOne({ id: guild_id }),
-		User.updateMany({ guilds: guild_id }, { $pull: { guilds: guild_id } }),
-		Role.deleteMany({ guild_id }),
-		Channel.deleteMany({ guild_id }),
-		Emoji.deleteMany({ guild_id }),
-		Invite.deleteMany({ guild_id }),
-		Message.deleteMany({ guild_id }),
-		Member.deleteMany({ guild_id })
+		Guild.delete({ id: guild_id }),
+		Role.delete({ guild_id }),
+		Channel.delete({ guild_id }),
+		Emoji.delete({ guild_id }),
+		Invite.delete({ guild_id }),
+		Message.delete({ guild_id }),
+		Member.delete({ guild_id })
 	]);
 
 	return res.sendStatus(204);