add option to auto add bot users to new apps
This commit is contained in:
parent
dedb20d64f
commit
942cce913d
@ -5994,6 +5994,9 @@
|
|||||||
},
|
},
|
||||||
"suppress": {
|
"suppress": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"flags": {
|
||||||
|
"type": "integer"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
@ -7190,9 +7193,14 @@
|
|||||||
},
|
},
|
||||||
"instanceId": {
|
"instanceId": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"autoCreateBotUsers": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
"autoCreateBotUsers",
|
||||||
"correspondenceEmail",
|
"correspondenceEmail",
|
||||||
"correspondenceUserID",
|
"correspondenceUserID",
|
||||||
"frontPage",
|
"frontPage",
|
||||||
|
@ -197032,6 +197032,9 @@
|
|||||||
},
|
},
|
||||||
"suppress": {
|
"suppress": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"flags": {
|
||||||
|
"type": "integer"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
@ -422581,10 +422584,15 @@
|
|||||||
},
|
},
|
||||||
"instanceId": {
|
"instanceId": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"autoCreateBotUsers": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
|
"autoCreateBotUsers",
|
||||||
"correspondenceEmail",
|
"correspondenceEmail",
|
||||||
"correspondenceUserID",
|
"correspondenceUserID",
|
||||||
"frontPage",
|
"frontPage",
|
||||||
|
@ -20,6 +20,7 @@ import { route } from "@spacebar/api";
|
|||||||
import {
|
import {
|
||||||
Application,
|
Application,
|
||||||
ApplicationCreateSchema,
|
ApplicationCreateSchema,
|
||||||
|
Config,
|
||||||
User,
|
User,
|
||||||
trimSpecial,
|
trimSpecial,
|
||||||
} from "@spacebar/util";
|
} from "@spacebar/util";
|
||||||
@ -68,6 +69,26 @@ router.post(
|
|||||||
flags: 0,
|
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();
|
await app.save();
|
||||||
|
|
||||||
res.json(app);
|
res.json(app);
|
||||||
|
@ -28,4 +28,5 @@ export class GeneralConfiguration {
|
|||||||
correspondenceUserID: string | null = null;
|
correspondenceUserID: string | null = null;
|
||||||
image: string | null = null;
|
image: string | null = null;
|
||||||
instanceId: string = Snowflake.generate();
|
instanceId: string = Snowflake.generate();
|
||||||
|
autoCreateBotUsers: boolean = false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user