summary refs log tree commit diff
path: root/src/util/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/entities')
-rw-r--r--src/util/entities/Attachment.ts19
-rw-r--r--src/util/entities/BaseClass.ts21
-rw-r--r--src/util/entities/Channel.ts120
-rw-r--r--src/util/entities/ConnectedAccount.ts5
-rw-r--r--src/util/entities/Guild.ts67
-rw-r--r--src/util/entities/Invite.ts3
-rw-r--r--src/util/entities/Member.ts20
-rw-r--r--src/util/entities/Message.ts12
-rw-r--r--src/util/entities/Migration.ts12
-rw-r--r--src/util/entities/ReadState.ts9
-rw-r--r--src/util/entities/Relationship.ts9
-rw-r--r--src/util/entities/StickerPack.ts9
-rw-r--r--src/util/entities/Team.ts9
-rw-r--r--src/util/entities/TeamMember.ts10
-rw-r--r--src/util/entities/User.ts66
15 files changed, 94 insertions, 297 deletions
diff --git a/src/util/entities/Attachment.ts b/src/util/entities/Attachment.ts
index d60ac41c..946318dd 100644
--- a/src/util/entities/Attachment.ts
+++ b/src/util/entities/Attachment.ts
@@ -16,14 +16,7 @@
 	along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-import {
-	BeforeRemove,
-	Column,
-	Entity,
-	JoinColumn,
-	ManyToOne,
-	RelationId,
-} from "typeorm";
+import { BeforeRemove, Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
 import { URL } from "url";
 import { deleteFile } from "../util/cdn";
 import { BaseClass } from "./BaseClass";
@@ -56,13 +49,9 @@ export class Attachment extends BaseClass {
 	message_id: string;
 
 	@JoinColumn({ name: "message_id" })
-	@ManyToOne(
-		() => require("./Message").Message,
-		(message: import("./Message").Message) => message.attachments,
-		{
-			onDelete: "CASCADE",
-		},
-	)
+	@ManyToOne(() => require("./Message").Message, (message: import("./Message").Message) => message.attachments, {
+		onDelete: "CASCADE",
+	})
 	message: import("./Message").Message;
 
 	@BeforeRemove()
diff --git a/src/util/entities/BaseClass.ts b/src/util/entities/BaseClass.ts
index f4b3cf59..2c19d197 100644
--- a/src/util/entities/BaseClass.ts
+++ b/src/util/entities/BaseClass.ts
@@ -16,14 +16,7 @@
 	along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-import {
-	BaseEntity,
-	BeforeInsert,
-	BeforeUpdate,
-	FindOptionsWhere,
-	ObjectIdColumn,
-	PrimaryColumn,
-} from "typeorm";
+import { BaseEntity, BeforeInsert, BeforeUpdate, FindOptionsWhere, ObjectIdColumn, PrimaryColumn } from "typeorm";
 import { Snowflake } from "../util/Snowflake";
 import { getDatabase } from "../util/Database";
 import { OrmUtils } from "../imports/OrmUtils";
@@ -57,15 +50,15 @@ export class BaseClassWithoutId extends BaseEntity {
 						// eslint-disable-next-line @typescript-eslint/ban-ts-comment
 						// @ts-ignore
 						this[x.propertyName],
-					]),
-				),
+					])
+				)
 		);
 	}
 
 	static increment<T extends BaseClass>(
 		conditions: FindOptionsWhere<T>,
 		propertyPath: string,
-		value: number | string,
+		value: number | string
 	) {
 		const repository = this.getRepository();
 		return repository.increment(conditions, propertyPath, value);
@@ -74,16 +67,14 @@ export class BaseClassWithoutId extends BaseEntity {
 	static decrement<T extends BaseClass>(
 		conditions: FindOptionsWhere<T>,
 		propertyPath: string,
-		value: number | string,
+		value: number | string
 	) {
 		const repository = this.getRepository();
 		return repository.decrement(conditions, propertyPath, value);
 	}
 }
 
-export const PrimaryIdColumn = process.env.DATABASE?.startsWith("mongodb")
-	? ObjectIdColumn
-	: PrimaryColumn;
+export const PrimaryIdColumn = process.env.DATABASE?.startsWith("mongodb") ? ObjectIdColumn : PrimaryColumn;
 
 export class BaseClass extends BaseClassWithoutId {
 	@PrimaryIdColumn()
diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts
index 169eab3d..6672d03d 100644
--- a/src/util/entities/Channel.ts
+++ b/src/util/entities/Channel.ts
@@ -17,24 +17,10 @@
 */
 
 import { HTTPError } from "lambert-server";
-import {
-	Column,
-	Entity,
-	JoinColumn,
-	ManyToOne,
-	OneToMany,
-	RelationId,
-} from "typeorm";
+import { Column, Entity, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm";
 import { DmChannelDTO } from "../dtos";
 import { ChannelCreateEvent, ChannelRecipientRemoveEvent } from "../interfaces";
-import {
-	InvisibleCharacters,
-	Snowflake,
-	containsAll,
-	emitEvent,
-	getPermission,
-	trimSpecial,
-} from "../util";
+import { InvisibleCharacters, Snowflake, containsAll, emitEvent, getPermission, trimSpecial } from "../util";
 import { BaseClass } from "./BaseClass";
 import { Guild } from "./Guild";
 import { Invite } from "./Invite";
@@ -162,14 +148,10 @@ export class Channel extends BaseClass {
 	})
 	messages?: Message[];
 
-	@OneToMany(
-		() => VoiceState,
-		(voice_state: VoiceState) => voice_state.channel,
-		{
-			cascade: true,
-			orphanedRowAction: "delete",
-		},
-	)
+	@OneToMany(() => VoiceState, (voice_state: VoiceState) => voice_state.channel, {
+		cascade: true,
+		orphanedRowAction: "delete",
+	})
 	voice_states?: VoiceState[];
 
 	@OneToMany(() => ReadState, (read_state: ReadState) => read_state.channel, {
@@ -203,7 +185,7 @@ export class Channel extends BaseClass {
 			skipPermissionCheck?: boolean;
 			skipEventEmit?: boolean;
 			skipNameChecks?: boolean;
-		},
+		}
 	) {
 		if (!opts?.skipPermissionCheck) {
 			// Always check if user has permission first
@@ -221,48 +203,26 @@ export class Channel extends BaseClass {
 		});
 
 		if (!opts?.skipNameChecks) {
-			if (
-				!guild.features.includes("ALLOW_INVALID_CHANNEL_NAMES") &&
-				channel.name
-			) {
+			if (!guild.features.includes("ALLOW_INVALID_CHANNEL_NAMES") && channel.name) {
 				for (const character of InvisibleCharacters)
 					if (channel.name.includes(character))
-						throw new HTTPError(
-							"Channel name cannot include invalid characters",
-							403,
-						);
+						throw new HTTPError("Channel name cannot include invalid characters", 403);
 
 				// Categories skip these checks on discord.com
-				if (
-					channel.type !== ChannelType.GUILD_CATEGORY ||
-					guild.features.includes("IRC_LIKE_CATEGORY_NAMES")
-				) {
+				if (channel.type !== ChannelType.GUILD_CATEGORY || guild.features.includes("IRC_LIKE_CATEGORY_NAMES")) {
 					if (channel.name.includes(" "))
-						throw new HTTPError(
-							"Channel name cannot include invalid characters",
-							403,
-						);
+						throw new HTTPError("Channel name cannot include invalid characters", 403);
 
 					if (channel.name.match(/--+/g))
-						throw new HTTPError(
-							"Channel name cannot include multiple adjacent dashes.",
-							403,
-						);
-
-					if (
-						channel.name.charAt(0) === "-" ||
-						channel.name.charAt(channel.name.length - 1) === "-"
-					)
-						throw new HTTPError(
-							"Channel name cannot start/end with dash.",
-							403,
-						);
+						throw new HTTPError("Channel name cannot include multiple adjacent dashes.", 403);
+
+					if (channel.name.charAt(0) === "-" || channel.name.charAt(channel.name.length - 1) === "-")
+						throw new HTTPError("Channel name cannot start/end with dash.", 403);
 				} else channel.name = channel.name.trim(); //category names are trimmed client side on discord.com
 			}
 
 			if (!guild.features.includes("ALLOW_UNNAMED_CHANNELS")) {
-				if (!channel.name)
-					throw new HTTPError("Channel name cannot be empty.", 403);
+				if (!channel.name) throw new HTTPError("Channel name cannot be empty.", 403);
 			}
 		}
 
@@ -274,15 +234,9 @@ export class Channel extends BaseClass {
 					const exists = await Channel.findOneOrFail({
 						where: { id: channel.parent_id },
 					});
-					if (!exists)
-						throw new HTTPError(
-							"Parent id channel doesn't exist",
-							400,
-						);
+					if (!exists) throw new HTTPError("Parent id channel doesn't exist", 400);
 					if (exists.guild_id !== channel.guild_id)
-						throw new HTTPError(
-							"The category channel needs to be in the guild",
-						);
+						throw new HTTPError("The category channel needs to be in the guild");
 				}
 				break;
 			case ChannelType.GUILD_CATEGORY:
@@ -299,9 +253,7 @@ export class Channel extends BaseClass {
 		if (!channel.permission_overwrites) channel.permission_overwrites = [];
 		// TODO: eagerly auto generate position of all guild channels
 
-		const position =
-			(channel.type === ChannelType.UNHANDLED ? 0 : channel.position) ||
-			0;
+		const position = (channel.type === ChannelType.UNHANDLED ? 0 : channel.position) || 0;
 
 		channel = {
 			...channel,
@@ -327,11 +279,7 @@ export class Channel extends BaseClass {
 		return ret;
 	}
 
-	static async createDMChannel(
-		recipients: string[],
-		creator_user_id: string,
-		name?: string,
-	) {
+	static async createDMChannel(recipients: string[], creator_user_id: string, name?: string) {
 		recipients = recipients.unique().filter((x) => x !== creator_user_id);
 		// TODO: check config for max number of recipients
 		/** if you want to disallow note to self channels, uncomment the conditional below
@@ -342,8 +290,7 @@ export class Channel extends BaseClass {
 		}
 		**/
 
-		const type =
-			recipients.length > 1 ? ChannelType.GROUP_DM : ChannelType.DM;
+		const type = recipients.length > 1 ? ChannelType.GROUP_DM : ChannelType.DM;
 
 		let channel = null;
 
@@ -379,11 +326,8 @@ export class Channel extends BaseClass {
 				recipients: channelRecipients.map((x) =>
 					Recipient.create({
 						user_id: x,
-						closed: !(
-							type === ChannelType.GROUP_DM ||
-							x === creator_user_id
-						),
-					}),
+						closed: !(type === ChannelType.GROUP_DM || x === creator_user_id),
+					})
 				),
 				nsfw: false,
 			}).save();
@@ -413,9 +357,7 @@ export class Channel extends BaseClass {
 
 	static async removeRecipientFromChannel(channel: Channel, user_id: string) {
 		await Recipient.delete({ channel_id: channel.id, user_id: user_id });
-		channel.recipients = channel.recipients?.filter(
-			(r) => r.user_id !== user_id,
-		);
+		channel.recipients = channel.recipients?.filter((r) => r.user_id !== user_id);
 
 		if (channel.recipients?.length === 0) {
 			await Channel.deleteChannel(channel);
@@ -464,11 +406,7 @@ export class Channel extends BaseClass {
 		await Channel.delete({ id: channel.id });
 	}
 
-	static async calculatePosition(
-		channel_id: string,
-		guild_id: string,
-		guild?: Guild,
-	) {
+	static async calculatePosition(channel_id: string, guild_id: string, guild?: Guild) {
 		if (!guild)
 			guild = await Guild.findOneOrFail({
 				where: { id: guild_id },
@@ -486,9 +424,7 @@ export class Channel extends BaseClass {
 			});
 
 		const channels = await Promise.all(
-			guild.channel_ordering.map((id) =>
-				Channel.findOneOrFail({ where: { id } }),
-			),
+			guild.channel_ordering.map((id) => Channel.findOneOrFail({ where: { id } }))
 		);
 
 		return channels.reduce((r, v) => {
@@ -499,9 +435,7 @@ export class Channel extends BaseClass {
 	}
 
 	isDm() {
-		return (
-			this.type === ChannelType.DM || this.type === ChannelType.GROUP_DM
-		);
+		return this.type === ChannelType.DM || this.type === ChannelType.GROUP_DM;
 	}
 
 	// Does the channel support sending messages ( eg categories do not )
diff --git a/src/util/entities/ConnectedAccount.ts b/src/util/entities/ConnectedAccount.ts
index 6e089de1..4af72c14 100644
--- a/src/util/entities/ConnectedAccount.ts
+++ b/src/util/entities/ConnectedAccount.ts
@@ -21,10 +21,7 @@ import { ConnectedAccountTokenData } from "../interfaces";
 import { BaseClass } from "./BaseClass";
 import { User } from "./User";
 
-export type PublicConnectedAccount = Pick<
-	ConnectedAccount,
-	"name" | "type" | "verified"
->;
+export type PublicConnectedAccount = Pick<ConnectedAccount, "name" | "type" | "verified">;
 
 @Entity("connected_accounts")
 export class ConnectedAccount extends BaseClass {
diff --git a/src/util/entities/Guild.ts b/src/util/entities/Guild.ts
index fcd6b729..1041e3cc 100644
--- a/src/util/entities/Guild.ts
+++ b/src/util/entities/Guild.ts
@@ -16,14 +16,7 @@
 	along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-import {
-	Column,
-	Entity,
-	JoinColumn,
-	ManyToOne,
-	OneToMany,
-	RelationId,
-} from "typeorm";
+import { Column, Entity, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm";
 import { Config, GuildWelcomeScreen, Snowflake, handleFile } from "..";
 import { Ban } from "./Ban";
 import { BaseClass } from "./BaseClass";
@@ -330,15 +323,12 @@ export class Guild extends BaseClass {
 			channel_ordering: [],
 
 			afk_timeout: Config.get().defaults.guild.afkTimeout,
-			default_message_notifications:
-				Config.get().defaults.guild.defaultMessageNotifications,
-			explicit_content_filter:
-				Config.get().defaults.guild.explicitContentFilter,
+			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,
+			max_video_channel_users: Config.get().defaults.guild.maxVideoChannelUsers,
 			region: Config.get().regions.default,
 		}).save();
 
@@ -361,9 +351,7 @@ export class Guild extends BaseClass {
 		}).save();
 
 		if (!body.channels || !body.channels.length)
-			body.channels = [
-				{ id: "01", type: 0, name: "general", nsfw: false },
-			];
+			body.channels = [{ id: "01", type: 0, name: "general", nsfw: false }];
 
 		const ids = new Map();
 
@@ -373,30 +361,19 @@ export class Guild extends BaseClass {
 			}
 		});
 
-		for (const channel of body.channels.sort((a) =>
-			a.parent_id ? 1 : -1,
-		)) {
+		for (const channel of body.channels.sort((a) => (a.parent_id ? 1 : -1))) {
 			const id = ids.get(channel.id) || Snowflake.generate();
 
 			const parent_id = ids.get(channel.parent_id);
 
-			const saved = await Channel.createChannel(
-				{ ...channel, guild_id, id, parent_id },
-				body.owner_id,
-				{
-					keepId: true,
-					skipExistsCheck: true,
-					skipPermissionCheck: true,
-					skipEventEmit: true,
-				},
-			);
-
-			await Guild.insertChannelInOrder(
-				guild.id,
-				saved.id,
-				parent_id ?? channel.position ?? 0,
-				guild,
-			);
+			const saved = await Channel.createChannel({ ...channel, guild_id, id, parent_id }, body.owner_id, {
+				keepId: true,
+				skipExistsCheck: true,
+				skipPermissionCheck: true,
+				skipEventEmit: true,
+			});
+
+			await Guild.insertChannelInOrder(guild.id, saved.id, parent_id ?? channel.position ?? 0, guild);
 		}
 
 		return guild;
@@ -407,25 +384,25 @@ export class Guild extends BaseClass {
 		guild_id: string,
 		channel_id: string,
 		position: number,
-		guild?: Guild,
+		guild?: Guild
 	): Promise<number>;
 	static async insertChannelInOrder(
 		guild_id: string,
 		channel_id: string,
 		parent_id: string,
-		guild?: Guild,
+		guild?: Guild
 	): Promise<number>;
 	static async insertChannelInOrder(
 		guild_id: string,
 		channel_id: string,
 		insertPoint: string | number,
-		guild?: Guild,
+		guild?: Guild
 	): Promise<number>;
 	static async insertChannelInOrder(
 		guild_id: string,
 		channel_id: string,
 		insertPoint: string | number,
-		guild?: Guild,
+		guild?: Guild
 	): Promise<number> {
 		if (!guild)
 			guild = await Guild.findOneOrFail({
@@ -434,17 +411,13 @@ export class Guild extends BaseClass {
 			});
 
 		let position;
-		if (typeof insertPoint == "string")
-			position = guild.channel_ordering.indexOf(insertPoint) + 1;
+		if (typeof insertPoint == "string") position = guild.channel_ordering.indexOf(insertPoint) + 1;
 		else position = insertPoint;
 
 		guild.channel_ordering.remove(channel_id);
 
 		guild.channel_ordering.splice(position, 0, channel_id);
-		await Guild.update(
-			{ id: guild_id },
-			{ channel_ordering: guild.channel_ordering },
-		);
+		await Guild.update({ id: guild_id }, { channel_ordering: guild.channel_ordering });
 		return position;
 	}
 
diff --git a/src/util/entities/Invite.ts b/src/util/entities/Invite.ts
index f7e54fbe..7670a802 100644
--- a/src/util/entities/Invite.ts
+++ b/src/util/entities/Invite.ts
@@ -99,8 +99,7 @@ export class Invite extends BaseClassWithoutId {
 
 	static async joinGuild(user_id: string, code: string) {
 		const invite = await Invite.findOneOrFail({ where: { code } });
-		if (invite.uses++ >= invite.max_uses && invite.max_uses !== 0)
-			await Invite.delete({ code });
+		if (invite.uses++ >= invite.max_uses && invite.max_uses !== 0) await Invite.delete({ code });
 		else await invite.save();
 
 		await Member.addToGuild(user_id, invite.guild_id);
diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts
index 65942816..275e748f 100644
--- a/src/util/entities/Member.ts
+++ b/src/util/entities/Member.ts
@@ -181,8 +181,7 @@ export class Member extends BaseClassWithoutId {
 			select: ["owner_id"],
 			where: { id: guild_id },
 		});
-		if (guild.owner_id === user_id)
-			throw new Error("The owner cannot be removed of the guild");
+		if (guild.owner_id === user_id) throw new Error("The owner cannot be removed of the guild");
 		const member = await Member.findOneOrFail({
 			where: { id: user_id, guild_id },
 			relations: ["user"],
@@ -244,11 +243,7 @@ export class Member extends BaseClassWithoutId {
 		]);
 	}
 
-	static async removeRole(
-		user_id: string,
-		guild_id: string,
-		role_id: string,
-	) {
+	static async removeRole(user_id: string, guild_id: string, role_id: string) {
 		const [member] = await Promise.all([
 			Member.findOneOrFail({
 				where: { id: user_id, guild_id },
@@ -278,11 +273,7 @@ export class Member extends BaseClassWithoutId {
 		]);
 	}
 
-	static async changeNickname(
-		user_id: string,
-		guild_id: string,
-		nickname: string,
-	) {
+	static async changeNickname(user_id: string, guild_id: string, nickname: string) {
 		const member = await Member.findOneOrFail({
 			where: {
 				id: user_id,
@@ -316,10 +307,7 @@ export class Member extends BaseClassWithoutId {
 		const { maxGuilds } = Config.get().limits.user;
 		const guild_count = await Member.count({ where: { id: user_id } });
 		if (guild_count >= maxGuilds) {
-			throw new HTTPError(
-				`You are at the ${maxGuilds} server limit.`,
-				403,
-			);
+			throw new HTTPError(`You are at the ${maxGuilds} server limit.`, 403);
 		}
 
 		const guild = await Guild.findOneOrFail({
diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts
index b519099a..b56f719e 100644
--- a/src/util/entities/Message.ts
+++ b/src/util/entities/Message.ts
@@ -161,14 +161,10 @@ export class Message extends BaseClass {
 	@ManyToMany(() => Sticker, { cascade: true, onDelete: "CASCADE" })
 	sticker_items?: Sticker[];
 
-	@OneToMany(
-		() => Attachment,
-		(attachment: Attachment) => attachment.message,
-		{
-			cascade: true,
-			orphanedRowAction: "delete",
-		},
-	)
+	@OneToMany(() => Attachment, (attachment: Attachment) => attachment.message, {
+		cascade: true,
+		orphanedRowAction: "delete",
+	})
 	attachments?: Attachment[];
 
 	@Column({ type: "simple-json" })
diff --git a/src/util/entities/Migration.ts b/src/util/entities/Migration.ts
index 5c4e951d..8f2fa190 100644
--- a/src/util/entities/Migration.ts
+++ b/src/util/entities/Migration.ts
@@ -16,17 +16,9 @@
 	along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-import {
-	Column,
-	Entity,
-	ObjectIdColumn,
-	PrimaryGeneratedColumn,
-	BaseEntity,
-} from "typeorm";
+import { Column, Entity, ObjectIdColumn, PrimaryGeneratedColumn, BaseEntity } from "typeorm";
 
-export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith(
-	"mongodb",
-)
+export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith("mongodb")
 	? ObjectIdColumn
 	: PrimaryGeneratedColumn;
 
diff --git a/src/util/entities/ReadState.ts b/src/util/entities/ReadState.ts
index 1b280d12..7add44a2 100644
--- a/src/util/entities/ReadState.ts
+++ b/src/util/entities/ReadState.ts
@@ -16,14 +16,7 @@
 	along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-import {
-	Column,
-	Entity,
-	Index,
-	JoinColumn,
-	ManyToOne,
-	RelationId,
-} from "typeorm";
+import { Column, Entity, Index, JoinColumn, ManyToOne, RelationId } from "typeorm";
 import { BaseClass } from "./BaseClass";
 import { Channel } from "./Channel";
 import { User } from "./User";
diff --git a/src/util/entities/Relationship.ts b/src/util/entities/Relationship.ts
index 740095c2..fe40c782 100644
--- a/src/util/entities/Relationship.ts
+++ b/src/util/entities/Relationship.ts
@@ -16,14 +16,7 @@
 	along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-import {
-	Column,
-	Entity,
-	Index,
-	JoinColumn,
-	ManyToOne,
-	RelationId,
-} from "typeorm";
+import { Column, Entity, Index, JoinColumn, ManyToOne, RelationId } from "typeorm";
 import { BaseClass } from "./BaseClass";
 import { User } from "./User";
 
diff --git a/src/util/entities/StickerPack.ts b/src/util/entities/StickerPack.ts
index 61ab1287..85a9fa77 100644
--- a/src/util/entities/StickerPack.ts
+++ b/src/util/entities/StickerPack.ts
@@ -16,14 +16,7 @@
 	along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-import {
-	Column,
-	Entity,
-	JoinColumn,
-	ManyToOne,
-	OneToMany,
-	RelationId,
-} from "typeorm";
+import { Column, Entity, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm";
 import { Sticker } from ".";
 import { BaseClass } from "./BaseClass";
 
diff --git a/src/util/entities/Team.ts b/src/util/entities/Team.ts
index 7bedc4af..abf68ee6 100644
--- a/src/util/entities/Team.ts
+++ b/src/util/entities/Team.ts
@@ -16,14 +16,7 @@
 	along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-import {
-	Column,
-	Entity,
-	JoinColumn,
-	ManyToOne,
-	OneToMany,
-	RelationId,
-} from "typeorm";
+import { Column, Entity, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm";
 import { BaseClass } from "./BaseClass";
 import { TeamMember } from "./TeamMember";
 import { User } from "./User";
diff --git a/src/util/entities/TeamMember.ts b/src/util/entities/TeamMember.ts
index 539da957..5e88e6a4 100644
--- a/src/util/entities/TeamMember.ts
+++ b/src/util/entities/TeamMember.ts
@@ -38,13 +38,9 @@ export class TeamMember extends BaseClass {
 	team_id: string;
 
 	@JoinColumn({ name: "team_id" })
-	@ManyToOne(
-		() => require("./Team").Team,
-		(team: import("./Team").Team) => team.members,
-		{
-			onDelete: "CASCADE",
-		},
-	)
+	@ManyToOne(() => require("./Team").Team, (team: import("./Team").Team) => team.members, {
+		onDelete: "CASCADE",
+	})
 	team: import("./Team").Team;
 
 	@Column({ nullable: true })
diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts
index c6582b00..45a7015c 100644
--- a/src/util/entities/User.ts
+++ b/src/util/entities/User.ts
@@ -17,14 +17,7 @@
 */
 
 import { Request } from "express";
-import {
-	Column,
-	Entity,
-	FindOneOptions,
-	JoinColumn,
-	OneToMany,
-	OneToOne,
-} from "typeorm";
+import { Column, Entity, FindOneOptions, JoinColumn, OneToMany, OneToOne } from "typeorm";
 import { Config, Email, FieldErrors, Snowflake, trimSpecial } from "..";
 import { BitField } from "../util/BitField";
 import { BaseClass } from "./BaseClass";
@@ -70,7 +63,7 @@ export enum PrivateUserEnum {
 export type PrivateUserKeys = keyof typeof PrivateUserEnum | PublicUserKeys;
 
 export const PublicUserProjection = Object.values(PublicUserEnum).filter(
-	(x) => typeof x === "string",
+	(x) => typeof x === "string"
 ) as PublicUserKeys[];
 export const PrivateUserProjection = [
 	...PublicUserProjection,
@@ -186,25 +179,17 @@ export class User extends BaseClass {
 	sessions: Session[];
 
 	@JoinColumn({ name: "relationship_ids" })
-	@OneToMany(
-		() => Relationship,
-		(relationship: Relationship) => relationship.from,
-		{
-			cascade: true,
-			orphanedRowAction: "delete",
-		},
-	)
+	@OneToMany(() => Relationship, (relationship: Relationship) => relationship.from, {
+		cascade: true,
+		orphanedRowAction: "delete",
+	})
 	relationships: Relationship[];
 
 	@JoinColumn({ name: "connected_account_ids" })
-	@OneToMany(
-		() => ConnectedAccount,
-		(account: ConnectedAccount) => account.user,
-		{
-			cascade: true,
-			orphanedRowAction: "delete",
-		},
-	)
+	@OneToMany(() => ConnectedAccount, (account: ConnectedAccount) => account.user, {
+		cascade: true,
+		orphanedRowAction: "delete",
+	})
 	connected_accounts: ConnectedAccount[];
 
 	@Column({ type: "simple-json", select: false })
@@ -281,9 +266,7 @@ export class User extends BaseClass {
 		});
 	}
 
-	public static async generateDiscriminator(
-		username: string,
-	): Promise<string | undefined> {
+	public static async generateDiscriminator(username: string): Promise<string | undefined> {
 		if (Config.get().register.incrementingDiscriminators) {
 			// discriminator will be incrementally generated
 
@@ -292,10 +275,7 @@ export class User extends BaseClass {
 				where: { username },
 				select: ["discriminator"],
 			});
-			const highestDiscriminator = Math.max(
-				0,
-				...users.map((u) => Number(u.discriminator)),
-			);
+			const highestDiscriminator = Math.max(0, ...users.map((u) => Number(u.discriminator)));
 
 			const discriminator = highestDiscriminator + 1;
 			if (discriminator >= 10000) {
@@ -309,9 +289,7 @@ export class User extends BaseClass {
 			// randomly generates a discriminator between 1 and 9999 and checks max five times if it already exists
 			// TODO: is there any better way to generate a random discriminator only once, without checking if it already exists in the database?
 			for (let tries = 0; tries < 5; tries++) {
-				const discriminator = Math.randomIntBetween(1, 9999)
-					.toString()
-					.padStart(4, "0");
+				const discriminator = Math.randomIntBetween(1, 9999).toString().padStart(4, "0");
 				const exists = await User.findOne({
 					where: { discriminator, username: username },
 					select: ["id"],
@@ -346,8 +324,7 @@ export class User extends BaseClass {
 			throw FieldErrors({
 				username: {
 					code: "USERNAME_TOO_MANY_USERS",
-					message:
-						req?.t("auth:register.USERNAME_TOO_MANY_USERS") || "",
+					message: req?.t("auth:register.USERNAME_TOO_MANY_USERS") || "",
 				},
 			});
 		}
@@ -355,8 +332,7 @@ export class User extends BaseClass {
 		// TODO: save date_of_birth
 		// appearently discord doesn't save the date of birth and just calculate if nsfw is allowed
 		// if nsfw_allowed is null/undefined it'll require date_of_birth to set it to true/false
-		const language =
-			req?.language === "en" ? "en-US" : req?.language || "en-US";
+		const language = req?.language === "en" ? "en-US" : req?.language || "en-US";
 
 		const settings = UserSettings.create({
 			locale: language,
@@ -374,9 +350,7 @@ export class User extends BaseClass {
 			extended_settings: "{}",
 			settings: settings,
 
-			premium_since: Config.get().defaults.user.premium
-				? new Date()
-				: undefined,
+			premium_since: Config.get().defaults.user.premium ? new Date() : undefined,
 			rights: Config.get().register.defaultRights,
 			premium: Config.get().defaults.user.premium ?? false,
 			premium_type: Config.get().defaults.user.premiumType ?? 0,
@@ -390,18 +364,14 @@ export class User extends BaseClass {
 		// send verification email if users aren't verified by default and we have an email
 		if (!Config.get().defaults.user.verified && email) {
 			await Email.sendVerifyEmail(user, email).catch((e) => {
-				console.error(
-					`Failed to send verification email to ${user.username}#${user.discriminator}: ${e}`,
-				);
+				console.error(`Failed to send verification email to ${user.username}#${user.discriminator}: ${e}`);
 			});
 		}
 
 		setImmediate(async () => {
 			if (Config.get().guild.autoJoin.enabled) {
 				for (const guild of Config.get().guild.autoJoin.guilds || []) {
-					await Member.addToGuild(user.id, guild).catch((e) =>
-						console.error("[Autojoin]", e),
-					);
+					await Member.addToGuild(user.id, guild).catch((e) => console.error("[Autojoin]", e));
 				}
 			}
 		});