vylbot-app/src/entity/501231711271780357/Lobby.ts
Vylpes 39999dfbba 3.0.7 (#295)
- Update dependency minimatch to 3.1.1
- Update dependency xml2js

Co-authored-by: Ethan Lane <ethan@vylpes.com>
Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/295
Reviewed-by: VylpesTester <tester@vylpes.com>
2023-05-08 18:24:09 +01:00

45 lines
1.1 KiB
TypeScript

import { Column, Entity, getConnection } from "typeorm";
import BaseEntity from "../../contracts/BaseEntity";
@Entity()
export default class Lobby extends BaseEntity {
constructor(channelId: string, roleId: string, cooldown: number, name: string) {
super();
this.ChannelId = channelId;
this.RoleId = roleId;
this.Cooldown = cooldown;
this.Name = name;
this.LastUsed = new Date(0);
}
@Column()
public ChannelId: string;
@Column()
public RoleId: string;
@Column()
public Cooldown: number;
@Column()
public LastUsed: Date;
@Column()
public Name: string;
public MarkAsUsed() {
this.LastUsed = new Date();
}
public static async FetchOneByChannelId(channelId: string, relations?: string[]): Promise<Lobby | null> {
const connection = getConnection();
const repository = connection.getRepository(Lobby);
const single = await repository.findOne({ where: { ChannelId: channelId }, relations: relations || [] });
return single;
}
}