1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-22 10:41:34 +02:00

🐛 fix Channel + Invite Model

This commit is contained in:
Flam3rboy 2021-05-22 12:01:07 +02:00
parent 2c77dcb933
commit 0abee6dca4
3 changed files with 20 additions and 8 deletions

View File

@ -2,7 +2,10 @@ import { Schema, model, Types, Document } from "mongoose";
import db from "../util/Database"; import db from "../util/Database";
import toBigInt from "../util/toBigInt"; import toBigInt from "../util/toBigInt";
export interface AnyChannel extends Channel, DMChannel, TextChannel, VoiceChannel {} // @ts-ignore
export interface AnyChannel extends Channel, DMChannel, TextChannel, VoiceChannel {
recipients: null | string[];
}
export interface ChannelDocument extends Document, AnyChannel { export interface ChannelDocument extends Document, AnyChannel {
id: string; id: string;
@ -46,6 +49,7 @@ export interface Channel {
export interface TextBasedChannel { export interface TextBasedChannel {
last_message_id?: string; last_message_id?: string;
last_pin_timestamp?: number; last_pin_timestamp?: number;
recipients: null;
} }
export interface GuildChannel extends Channel { export interface GuildChannel extends Channel {
@ -67,14 +71,18 @@ export enum ChannelPermissionOverwriteType {
member = 1, member = 1,
} }
export interface VoiceChannel extends GuildChannel {} export interface VoiceChannel extends GuildChannel {
video_quality_mode?: number;
bitrate?: number;
user_limit?: number;
}
export interface TextChannel extends GuildChannel, TextBasedChannel { export interface TextChannel extends GuildChannel, TextBasedChannel {
nsfw: boolean; nsfw: boolean;
rate_limit_per_user: number; rate_limit_per_user: number;
topic?: string; topic?: string;
} }
// @ts-ignore
export interface DMChannel extends Channel, TextBasedChannel { export interface DMChannel extends Channel, TextBasedChannel {
owner_id: string; owner_id: string;
recipients: string[]; recipients: string[];

View File

@ -4,22 +4,25 @@ import { ChannelModel } from "./Channel";
import { UserModel } from "./User"; import { UserModel } from "./User";
import { GuildModel } from "./Guild"; import { GuildModel } from "./Guild";
export interface Invite extends Document { export interface Invite {
code: string; code: string;
temporary: boolean; temporary: boolean;
uses: number; uses: number;
max_uses: number; max_uses: number;
max_age: number; max_age: number;
created_at: Date; created_at: Date;
expires_at: Date;
guild_id: string; guild_id: string;
channel_id: string; channel_id: string;
inviter_id: string; inviter_id: string;
// ? What the fucking shit is this // ? What is this?
target_user_id?: string; target_user_id?: string;
target_user_type?: number; target_user_type?: number;
} }
export interface InviteDocument extends Invite, Document {}
export const InviteSchema = new Schema({ export const InviteSchema = new Schema({
code: String, code: String,
temporary: Boolean, temporary: Boolean,
@ -27,11 +30,12 @@ export const InviteSchema = new Schema({
max_uses: Number, max_uses: Number,
max_age: Number, max_age: Number,
created_at: Date, created_at: Date,
expires_at: Date,
guild_id: String, guild_id: String,
channel_id: String, channel_id: String,
inviter_id: String, inviter_id: String,
// ? What the fucking shit is this // ? What is this?
target_user_id: String, target_user_id: String,
target_user_type: Number, target_user_type: Number,
}); });
@ -94,4 +98,4 @@ InviteSchema.virtual("guild", {
}); });
// @ts-ignore // @ts-ignore
export const InviteModel = db.model<Invite>("Invite", InviteSchema, "invites"); export const InviteModel = db.model<InviteDocument>("Invite", InviteSchema, "invites");

View File

@ -145,7 +145,7 @@ export class Permissions extends BitField {
guild: { roles: Role[] }; guild: { roles: Role[] };
channel?: { channel?: {
overwrites?: ChannelPermissionOverwrite[]; overwrites?: ChannelPermissionOverwrite[];
recipients?: string[]; recipients?: string[] | null;
owner_id?: string; owner_id?: string;
}; };
}) { }) {