From 6494a14e8a4ff09700fa06e3928ccc030019ddeb Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 20 Jul 2026 12:44:56 +0200 Subject: [PATCH] Join bot on app --- .../routes/applications/#application_id/bot/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/routes/applications/#application_id/bot/index.ts b/src/api/routes/applications/#application_id/bot/index.ts index 27b6b9c17..d4ef60964 100644 --- a/src/api/routes/applications/#application_id/bot/index.ts +++ b/src/api/routes/applications/#application_id/bot/index.ts @@ -67,19 +67,19 @@ router.post( }, }), async (req: Request, res: Response) => { - const app = await Application.findOneOrFail({ where: { id: req.params.application_id as string } }); - const bot = await User.findOneOrFail({ where: { id: req.params.application_id as string } }); + const app = await Application.findOneOrFail({ where: { id: req.params.application_id as string }, relations: { bot: true } }); const owner = await User.findOneOrFail({ where: { id: app.owner_id }, select: { id: true, totp_secret: true } }); + if (!app.bot) throw DiscordApiErrors.OAUTH2_APPLICATION_BOT_ABSENT; if (owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION; if (owner.totp_secret && (!req.body.code || verifyToken(owner.totp_secret, req.body.code))) throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008); - bot.data = { hash: undefined, valid_tokens_since: new Date() }; + app.bot.data = { hash: undefined, valid_tokens_since: new Date() }; - await bot.save(); + await app.bot.save(); - const token = await generateToken(bot.id); + const token = await generateToken(app.bot.id); res.json({ token }).status(200); },