mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 13:14:06 +01:00
✨ invites TTL
This commit is contained in:
parent
4715ef1eab
commit
f72156a40d
@ -24,16 +24,19 @@ router.post("/", check(InviteCreateSchema), async (req: Request, res: Response)
|
|||||||
const permission = await getPermission(user_id, guild_id);
|
const permission = await getPermission(user_id, guild_id);
|
||||||
permission.hasThrow("CREATE_INSTANT_INVITE");
|
permission.hasThrow("CREATE_INSTANT_INVITE");
|
||||||
|
|
||||||
|
const expires_at = new Date(req.body.max_age * 1000 + Date.now());
|
||||||
|
|
||||||
const invite = {
|
const invite = {
|
||||||
code: random(),
|
code: random(),
|
||||||
temporary: req.body.temporary,
|
temporary: req.body.temporary,
|
||||||
uses: 0,
|
uses: 0,
|
||||||
max_uses: req.body.max_uses,
|
max_uses: req.body.max_uses,
|
||||||
max_age: req.body.max_age,
|
max_age: req.body.max_age,
|
||||||
|
expires_at,
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
guild_id,
|
guild_id,
|
||||||
channel_id: channel_id,
|
channel_id: channel_id,
|
||||||
inviter_id: user_id,
|
inviter_id: user_id
|
||||||
};
|
};
|
||||||
|
|
||||||
await new InviteModel(invite).save();
|
await new InviteModel(invite).save();
|
||||||
|
Loading…
Reference in New Issue
Block a user