From f72156a40da9e056321aad3452f157afc4a58928 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sat, 22 May 2021 17:40:23 +0200 Subject: [PATCH] :sparkles: invites TTL --- src/routes/channels/#channel_id/invites.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/routes/channels/#channel_id/invites.ts b/src/routes/channels/#channel_id/invites.ts index 10d6ae3f..457e78ca 100644 --- a/src/routes/channels/#channel_id/invites.ts +++ b/src/routes/channels/#channel_id/invites.ts @@ -24,16 +24,19 @@ router.post("/", check(InviteCreateSchema), async (req: Request, res: Response) const permission = await getPermission(user_id, guild_id); permission.hasThrow("CREATE_INSTANT_INVITE"); + const expires_at = new Date(req.body.max_age * 1000 + Date.now()); + const invite = { code: random(), temporary: req.body.temporary, uses: 0, max_uses: req.body.max_uses, max_age: req.body.max_age, + expires_at, created_at: new Date(), guild_id, channel_id: channel_id, - inviter_id: user_id, + inviter_id: user_id }; await new InviteModel(invite).save();