summary refs log tree commit diff
path: root/util/src/entities/RateLimit.ts
blob: 3ac35df36ceef23fcffda47fb5f219d6e0a67923 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass";
import { User } from "./User";

@Entity("rate_limits")
export class RateLimit extends BaseClass {
	@Column()
	id: "global" | "error" | string; // channel_239842397 | guild_238927349823 | webhook_238923423498

	@RelationId((rate_limit: RateLimit) => rate_limit.user)
	user_id: string;

	@JoinColumn({ name: "user_id" })
	@ManyToOne(() => User, (user) => user.id)
	user: User;

	@Column()
	hits: number;

	@Column()
	blocked: boolean;

	@Column()
	expires_at: Date;
}