1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 20:52:42 +01:00

🐛 fix vanity url

This commit is contained in:
Flam3rboy 2021-10-10 18:28:38 +02:00
parent c9e827b3e9
commit 4b811d3b51

View File

@ -10,7 +10,7 @@ const InviteRegex = /\W/g;
router.get("/", route({ permission: "MANAGE_GUILD" }), async (req: Request, res: Response) => { router.get("/", route({ permission: "MANAGE_GUILD" }), async (req: Request, res: Response) => {
const { guild_id } = req.params; const { guild_id } = req.params;
const invite = await Invite.findOne({ where: {guild_id: guild_id, vanity_url: true} }); const invite = await Invite.findOne({ where: { guild_id: guild_id, vanity_url: true } });
if (!invite) return res.json({ code: null }); if (!invite) return res.json({ code: null });
return res.json({ code: invite.code, uses: invite.uses }); return res.json({ code: invite.code, uses: invite.uses });
@ -35,15 +35,7 @@ router.patch("/", route({ body: "VanityUrlSchema", permission: "MANAGE_GUILD" })
const { id } = await Channel.findOneOrFail({ guild_id, type: ChannelType.GUILD_TEXT }); const { id } = await Channel.findOneOrFail({ guild_id, type: ChannelType.GUILD_TEXT });
Promise.all([ await Invite.update({ vanity_url: true, guild_id }, { code: code, channel_id: id });
new Invite({
code: code,
uses: 0,
created_at: new Date(),
guild_id,
channel_id: id
}).save()
]);
return res.json({ code: code }); return res.json({ code: code });
}); });