create util for app bot user creation

This commit is contained in:
Puyodead1
2023-05-07 00:00:42 -04:00
parent 942cce913d
commit bb22e42da9
4 changed files with 30 additions and 35 deletions
+24
View File
@@ -0,0 +1,24 @@
import { Request } from "express";
import { Application, User } from "../entities";
export async function createAppBotUser(app: Application, req: Request) {
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();
return user;
}
+1
View File
@@ -18,6 +18,7 @@
export * from "./ApiError";
export * from "./Array";
export * from "./Application";
export * from "./BitField";
//export * from "./Categories";
export * from "./cdn";