1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-05 10:22:31 +01:00

move guild/user prop initialisations into create/register methods

This commit is contained in:
Madeline 2023-04-14 22:27:22 +10:00
parent 4ecee6b291
commit 46d86c4079
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
2 changed files with 30 additions and 16 deletions

View File

@ -77,7 +77,7 @@ export class Guild extends BaseClass {
afk_channel?: Channel;
@Column({ nullable: true })
afk_timeout?: number = Config.get().defaults.guild.afkTimeout;
afk_timeout?: number;
// * commented out -> use owner instead
// application id of the guild creator if it is bot-created
@ -95,8 +95,7 @@ export class Guild extends BaseClass {
banner?: string;
@Column({ nullable: true })
default_message_notifications?: number =
Config.get().defaults.guild.defaultMessageNotifications;
default_message_notifications?: number;
@Column({ nullable: true })
description?: string;
@ -105,11 +104,10 @@ export class Guild extends BaseClass {
discovery_splash?: string;
@Column({ nullable: true })
explicit_content_filter?: number =
Config.get().defaults.guild.explicitContentFilter;
explicit_content_filter?: number;
@Column({ type: "simple-array" })
features: string[] = Config.get().guild.defaultFeatures || []; //TODO use enum
features: string[] = []; //TODO use enum
//TODO: https://discord.com/developers/docs/resources/guild#guild-object-guild-features
@Column({ nullable: true })
@ -122,14 +120,13 @@ export class Guild extends BaseClass {
large?: boolean = false;
@Column({ nullable: true })
max_members?: number = Config.get().limits.guild.maxMembers;
max_members?: number;
@Column({ nullable: true })
max_presences?: number = Config.get().defaults.guild.maxPresences;
max_presences?: number;
@Column({ nullable: true })
max_video_channel_users?: number =
Config.get().defaults.guild.maxVideoChannelUsers;
max_video_channel_users?: number;
@Column({ nullable: true })
member_count?: number;
@ -247,7 +244,7 @@ export class Guild extends BaseClass {
rules_channel?: string;
@Column({ nullable: true })
region?: string = Config.get().regions.default;
region?: string;
@Column({ nullable: true })
splash?: string;
@ -327,6 +324,18 @@ export class Guild extends BaseClass {
description: "Fill in your description",
welcome_channels: [],
},
afk_timeout: Config.get().defaults.guild.afkTimeout,
default_message_notifications:
Config.get().defaults.guild.defaultMessageNotifications,
explicit_content_filter:
Config.get().defaults.guild.explicitContentFilter,
features: Config.get().guild.defaultFeatures,
max_members: Config.get().limits.guild.maxMembers,
max_presences: Config.get().defaults.guild.maxPresences,
max_video_channel_users:
Config.get().defaults.guild.maxVideoChannelUsers,
region: Config.get().regions.default,
}).save();
// we have to create the role _after_ the guild because else we would get a "SQLITE_CONSTRAINT: FOREIGN KEY constraint failed" error

View File

@ -127,10 +127,10 @@ export class User extends BaseClass {
mobile: boolean = false; // if the user has mobile app installed
@Column()
premium: boolean = Config.get().defaults.user.premium ?? false; // if user bought individual premium
premium: boolean; // if user bought individual premium
@Column()
premium_type: number = Config.get().defaults.user.premiumType ?? 0; // individual premium level
premium_type: number; // individual premium level
@Column()
bot: boolean = false; // if user is bot
@ -157,13 +157,13 @@ export class User extends BaseClass {
totp_last_ticket?: string = "";
@Column()
created_at: Date = new Date(); // registration date
created_at: Date; // registration date
@Column({ nullable: true })
premium_since: Date; // premium date
@Column({ select: false })
verified: boolean = Config.get().defaults.user.verified ?? true; // email is verified
verified: boolean; // email is verified
@Column()
disabled: boolean = false; // if the account is disabled
@ -382,11 +382,16 @@ export class User extends BaseClass {
valid_tokens_since: new Date(),
},
extended_settings: "{}",
settings: settings,
premium_since: Config.get().defaults.user.premium
? new Date()
: undefined,
settings: settings,
rights: Config.get().register.defaultRights,
premium: Config.get().defaults.user.premium ?? false,
premium_type: Config.get().defaults.user.premiumType ?? 0,
verified: Config.get().defaults.user.verified ?? true,
created_at: new Date(),
});
user.validate();