update invites endpoints to support latest api

This commit is contained in:
Madeline
2023-08-12 00:43:00 +10:00
parent 3eb2338c3e
commit 23e234a87b
5 changed files with 542 additions and 137 deletions
+6 -3
View File
@@ -17,10 +17,10 @@
*/
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { Member } from "./Member";
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
import { Channel } from "./Channel";
import { Guild } from "./Guild";
import { Member } from "./Member";
import { User } from "./User";
export const PublicInviteRelation = ["inviter", "guild", "channel"];
@@ -45,8 +45,8 @@ export class Invite extends BaseClassWithoutId {
@Column()
created_at: Date;
@Column()
expires_at: Date;
@Column({ nullable: true })
expires_at?: Date;
@Column({ nullable: true })
@RelationId((invite: Invite) => invite.guild)
@@ -94,6 +94,9 @@ export class Invite extends BaseClassWithoutId {
@Column({ nullable: true })
vanity_url?: boolean;
@Column()
flags: number;
static async joinGuild(user_id: string, code: string) {
const invite = await Invite.findOneOrFail({ where: { code } });
if (invite.uses++ >= invite.max_uses && invite.max_uses !== 0)
+1
View File
@@ -26,4 +26,5 @@ export interface InviteCreateSchema {
unique?: boolean;
target_user?: string;
target_user_type?: number;
flags?: number;
}