add option to auto add bot users to new apps

This commit is contained in:
Puyodead1 2023-05-06 23:45:09 -04:00
parent dedb20d64f
commit 942cce913d
No known key found for this signature in database
GPG Key ID: A4FA4FEC0DD353FC
4 changed files with 22 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@ -20,6 +20,7 @@ import { route } from "@spacebar/api";
import {
Application,
ApplicationCreateSchema,
Config,
User,
trimSpecial,
} from "@spacebar/util";
@ -68,6 +69,26 @@ router.post(
flags: 0,
});
// 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();
res.json(app);

View File

@ -28,4 +28,5 @@ export class GeneralConfiguration {
correspondenceUserID: string | null = null;
image: string | null = null;
instanceId: string = Snowflake.generate();
autoCreateBotUsers: boolean = false;
}