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 38 additions and 0 deletions

View File

@ -5994,6 +5994,9 @@
},
"suppress": {
"type": "boolean"
},
"flags": {
"type": "integer"
}
},
"required": [
@ -7190,9 +7193,14 @@
},
"instanceId": {
"type": "string"
},
"autoCreateBotUsers": {
"type": "boolean",
"default": false
}
},
"required": [
"autoCreateBotUsers",
"correspondenceEmail",
"correspondenceUserID",
"frontPage",

View File

@ -197032,6 +197032,9 @@
},
"suppress": {
"type": "boolean"
},
"flags": {
"type": "integer"
}
},
"additionalProperties": false,
@ -422581,10 +422584,15 @@
},
"instanceId": {
"type": "string"
},
"autoCreateBotUsers": {
"type": "boolean",
"default": false
}
},
"additionalProperties": false,
"required": [
"autoCreateBotUsers",
"correspondenceEmail",
"correspondenceUserID",
"frontPage",

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;
}