summary refs log tree commit diff
path: root/src/util/User.ts
blob: 778730e26101cf10c0f79ec8bd4a468251b8cfe9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { UserModel } from "fosscord-server-util";
import { HTTPError } from "lambert-server";

export async function getPublicUser(user_id: bigint, additional_fields?: any) {
	const user = await UserModel.findOne(
		{ id: user_id },
		{
			username: true,
			discriminator: true,
			id: true,
			public_flags: true,
			avatar: true,
			...additional_fields,
		}
	).exec();
	if (!user) throw new HTTPError("User not found", 404);
	return user;
}