summary refs log tree commit diff
path: root/src/util/User.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/User.ts')
-rw-r--r--src/util/User.ts18
1 files changed, 18 insertions, 0 deletions
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; +}