summary refs log tree commit diff
path: root/src/routes
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-22 17:40:23 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-22 17:40:23 +0200
commitf72156a40da9e056321aad3452f157afc4a58928 (patch)
tree41e94d8e5a8a76634d75a77ac0bd9fd487a8fe5e /src/routes
parent:sparkles: createChannel() (diff)
downloadserver-f72156a40da9e056321aad3452f157afc4a58928.tar.xz
:sparkles: invites TTL
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/channels/#channel_id/invites.ts5
1 files changed, 4 insertions, 1 deletions
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();