Merge pull request #1052 from spacebarchat/feat/auto-create-bot-users

Feat: Auto add bot users to new apps
This commit is contained in:
Puyodead1
2023-05-07 00:15:04 -04:00
committed by GitHub
7 changed files with 35 additions and 18 deletions
@@ -28,4 +28,5 @@ export class GeneralConfiguration {
correspondenceUserID: string | null = null;
image: string | null = null;
instanceId: string = Snowflake.generate();
autoCreateBotUsers: boolean = false;
}
+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
@@ -42,3 +42,4 @@ export * from "./Token";
export * from "./TraverseDirectory";
export * from "./WebAuthn";
export * from "./Gifs";
export * from "./Application";