From bb22e42da93f9e9a6ea5c00980cff9c865ea3c48 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Sun, 7 May 2023 00:00:42 -0400 Subject: create util for app bot user creation --- src/api/routes/applications/index.ts | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'src/api/routes/applications/index.ts') diff --git a/src/api/routes/applications/index.ts b/src/api/routes/applications/index.ts index 27300c4a..5bba3338 100644 --- a/src/api/routes/applications/index.ts +++ b/src/api/routes/applications/index.ts @@ -22,6 +22,7 @@ import { ApplicationCreateSchema, Config, User, + createAppBotUser, trimSpecial, } from "@spacebar/util"; import { Request, Response, Router } from "express"; @@ -72,24 +73,8 @@ router.post( // april 14, 2023: discord made bot users be automatically added to all new apps const { autoCreateBotUsers } = Config.get().general; if (autoCreateBotUsers) { - const user = await User.register({ - username: app.name, - password: undefined, - id: app.id, - req, - }); - - user.id = app.id; - user.premium_since = new Date(); - user.bot = true; - - await user.save(); - - // flags is NaN here? - app.assign({ bot: user, flags: app.flags || 0 }); - } - - await app.save(); + await createAppBotUser(app, req); + } else await app.save(); res.json(app); }, -- cgit 1.5.1