From a0cb65ccad9036c9f58de3ae800b20e99c8a430e Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Mon, 22 Feb 2021 15:51:53 +0100 Subject: :art: restructure + add/remove Member() function --- src/util/User.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/util/User.ts (limited to 'src/util/User.ts') diff --git a/src/util/User.ts b/src/util/User.ts new file mode 100644 index 00000000..778730e2 --- /dev/null +++ b/src/util/User.ts @@ -0,0 +1,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; +} -- cgit 1.5.1