summary refs log tree commit diff
path: root/api/src/routes/channels/#channel_id/invites.ts
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/routes/channels/#channel_id/invites.ts')
-rw-r--r--api/src/routes/channels/#channel_id/invites.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/api/src/routes/channels/#channel_id/invites.ts b/api/src/routes/channels/#channel_id/invites.ts
index 438f8c51..cc77df26 100644
--- a/api/src/routes/channels/#channel_id/invites.ts
+++ b/api/src/routes/channels/#channel_id/invites.ts
@@ -6,14 +6,14 @@ import { random } from "../../../util/RandomInviteID";
 
 import { InviteCreateSchema } from "../../../schema/Invite";
 
-import { getPermission, ChannelModel, InviteModel, InviteCreateEvent, toObject, emitEvent } from "@fosscord/util";
+import { getPermission, Channel, InviteModel, InviteCreateEvent, toObject, emitEvent } from "@fosscord/util";
 
 const router: Router = Router();
 
 router.post("/", check(InviteCreateSchema), async (req: Request, res: Response) => {
 	const { user_id } = req;
 	const { channel_id } = req.params;
-	const channel = await ChannelModel.findOne({ id: channel_id }).exec();
+	const channel = await Channel.findOneOrFail({ id: channel_id });
 
 	if (!channel.guild_id) {
 		throw new HTTPError("This channel doesn't exist", 404);
@@ -47,7 +47,7 @@ router.post("/", check(InviteCreateSchema), async (req: Request, res: Response)
 router.get("/", async (req: Request, res: Response) => {
 	const { user_id } = req;
 	const { channel_id } = req.params;
-	const channel = await ChannelModel.findOne({ id: channel_id }).exec();
+	const channel = await Channel.findOneOrFail({ id: channel_id });
 
 	if (!channel.guild_id) {
 		throw new HTTPError("This channel doesn't exist", 404);
@@ -56,9 +56,9 @@ router.get("/", async (req: Request, res: Response) => {
 	const permission = await getPermission(user_id, guild_id);
 	permission.hasThrow("MANAGE_CHANNELS");
 
-	const invites = await InviteModel.find({ guild_id }).exec();
+	const invites = await Invite.find({ guild_id });
 
-	res.status(200).send(toObject(invites));
+	res.status(200).send(invites);
 });
 
 export default router;