summary refs log tree commit diff
path: root/src/api/routes/applications/#id
diff options
context:
space:
mode:
authorPuyodead1 <puyodead@proton.me>2023-05-07 00:00:42 -0400
committerPuyodead1 <puyodead@proton.me>2023-05-07 00:00:42 -0400
commitbb22e42da93f9e9a6ea5c00980cff9c865ea3c48 (patch)
tree6759f8b810cf413eb36f08f2d55da02f8198126d /src/api/routes/applications/#id
parentadd option to auto add bot users to new apps (diff)
downloadserver-ts-bb22e42da93f9e9a6ea5c00980cff9c865ea3c48.tar.xz
create util for app bot user creation
Diffstat (limited to 'src/api/routes/applications/#id')
-rw-r--r--src/api/routes/applications/#id/bot/index.ts19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/api/routes/applications/#id/bot/index.ts b/src/api/routes/applications/#id/bot/index.ts

index 0a6e6fd4..3c431e3d 100644 --- a/src/api/routes/applications/#id/bot/index.ts +++ b/src/api/routes/applications/#id/bot/index.ts
@@ -22,6 +22,7 @@ import { BotModifySchema, DiscordApiErrors, User, + createAppBotUser, generateToken, handleFile, } from "@spacebar/util"; @@ -52,23 +53,7 @@ router.post( if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION; - 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(); + const user = await createAppBotUser(app, req); res.send({ token: await generateToken(user.id),