diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-10 18:28:38 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-10 18:28:38 +0200 |
commit | a54711f4aebd8715c768092396e5b9a7f1f20362 (patch) | |
tree | 2962ba820b7706b53645d1333a09fb246f73ab9b /api/src | |
parent | Fix duplicate key (diff) | |
download | server-a54711f4aebd8715c768092396e5b9a7f1f20362.tar.xz |
:bug: fix vanity url
Diffstat (limited to 'api/src')
-rw-r--r-- | api/src/routes/guilds/#guild_id/vanity-url.ts | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/api/src/routes/guilds/#guild_id/vanity-url.ts b/api/src/routes/guilds/#guild_id/vanity-url.ts index 061b317c..63173345 100644 --- a/api/src/routes/guilds/#guild_id/vanity-url.ts +++ b/api/src/routes/guilds/#guild_id/vanity-url.ts @@ -10,7 +10,7 @@ const InviteRegex = /\W/g; router.get("/", route({ permission: "MANAGE_GUILD" }), async (req: Request, res: Response) => { 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 }); 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 }); - Promise.all([ - new Invite({ - code: code, - uses: 0, - created_at: new Date(), - guild_id, - channel_id: id - }).save() - ]); + await Invite.update({ vanity_url: true, guild_id }, { code: code, channel_id: id }); return res.json({ code: code }); }); |