From d52d9c62fc30e31e2c01bf6b63f9aedebdde216f Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 8 Aug 2022 04:27:28 +0200 Subject: Bunch of fixes and improvements, everything appears to work now --- util/src/entities/Guild.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'util/src/entities/Guild.ts') diff --git a/util/src/entities/Guild.ts b/util/src/entities/Guild.ts index 328c586e..058033e8 100644 --- a/util/src/entities/Guild.ts +++ b/util/src/entities/Guild.ts @@ -285,7 +285,7 @@ export class Guild extends BaseClass { }) { const guild_id = Snowflake.generate(); - const guild = await new Guild({ + const guild: Guild = Object.assign(new Guild(),{ name: body.name || "Fosscord", icon: await handleFile(`/icons/${guild_id}`, body.icon as string), region: Config.get().regions.default, @@ -316,11 +316,12 @@ export class Guild extends BaseClass { welcome_channels: [], }, widget_enabled: true, // NB: don't set it as false to prevent artificial restrictions - }).save(); + }); + await guild.save(); // we have to create the role _after_ the guild because else we would get a "SQLITE_CONSTRAINT: FOREIGN KEY constraint failed" error // TODO: make the @everyone a pseudorole that is dynamically generated at runtime so we can save storage - await new Role({ + let role: Role = Object.assign(new Role(), { id: guild_id, guild_id: guild_id, color: 0, @@ -333,7 +334,8 @@ export class Guild extends BaseClass { position: 0, icon: null, unicode_emoji: null - }).save(); + }); + await role.save(); if (!body.channels || !body.channels.length) body.channels = [{ id: "01", type: 0, name: "general" }]; -- cgit 1.5.1