summary refs log tree commit diff
path: root/src/models/Invite.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/Invite.ts')
-rw-r--r--src/models/Invite.ts82
1 files changed, 70 insertions, 12 deletions
diff --git a/src/models/Invite.ts b/src/models/Invite.ts

index fc60b93c..41f33a02 100644 --- a/src/models/Invite.ts +++ b/src/models/Invite.ts
@@ -1,5 +1,8 @@ import { Schema, Document, Types } from "mongoose"; import db from "../util/Database"; +import { ChannelModel } from "./Channel"; +import { UserModel } from "./User"; +import { GuildModel } from "./Guild"; export interface Invite extends Document { code: string; @@ -8,14 +11,13 @@ export interface Invite extends Document { max_uses: number; max_age: number; created_at: Date; - guild_id: bigint; - channel_id: bigint; - inviter_id: bigint; + guild_id: string; + channel_id: string; + inviter_id: string; - //! What the fucking shit is this - target_user_id?: bigint; + // ? What the fucking shit is this + target_user_id?: string; target_user_type?: number; - // ! } export const InviteSchema = new Schema({ @@ -25,14 +27,70 @@ export const InviteSchema = new Schema({ max_uses: Number, max_age: Number, created_at: Date, - guild_id: Types.Long, - channel_id: Types.Long, - inviter_id: Types.Long, + guild_id: String, + channel_id: String, + inviter_id: String, - //! What the fucking shit is this - target_user_id: Types.Long, + // ? What the fucking shit is this + target_user_id: String, target_user_type: Number, - // ! +}); + +InviteSchema.virtual("channel", { + ref: ChannelModel, + localField: "channel_id", + foreignField: "id", + justOne: true, + autopopulate: { + select: { + id: true, + name: true, + type: true, + }, + }, +}); + +InviteSchema.virtual("inviter", { + ref: UserModel, + localField: "inviter_id", + foreignField: "id", + justOne: true, + autopopulate: { + select: { + id: true, + username: true, + avatar: true, + discriminater: true, + public_flags: true, + }, + }, +}); + +InviteSchema.virtual("guild", { + ref: GuildModel, + localField: "guild_id", + foreignField: "id", + justOne: true, + autopopulate: { + select: { + id: true, + name: true, + splash: true, + banner: true, + description: true, + icon: true, + features: true, + verification_level: true, + vanity_url_code: true, + welcome_screen: true, + nsfw: true, + + // TODO: hide the following entries: + // channels: false, + // roles: false, + // emojis: false, + }, + }, }); // @ts-ignore