This repository has been archived on 2026-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
2021-04-06 04:30:04 +02:00

25 lines
518 B
TypeScript

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