From f711a0411cbe48319ea3497c4f26f872c18cd2a2 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sat, 21 Aug 2021 16:47:22 +0200 Subject: :construction: typeorm --- util/oldModels/RateLimit.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 util/oldModels/RateLimit.ts (limited to 'util/oldModels/RateLimit.ts') diff --git a/util/oldModels/RateLimit.ts b/util/oldModels/RateLimit.ts new file mode 100644 index 00000000..6a0e1ffd --- /dev/null +++ b/util/oldModels/RateLimit.ts @@ -0,0 +1,25 @@ +import { Schema, Document, Types } from "mongoose"; +import db from "../util/Database"; + +export interface Bucket { + id: "global" | "error" | string; // channel_239842397 | guild_238927349823 | webhook_238923423498 + user_id: string; + hits: number; + blocked: boolean; + expires_at: Date; +} + +export interface BucketDocument extends Bucket, Document { + id: string; +} + +export const BucketSchema = new Schema({ + id: { type: String, required: true }, + user_id: { type: String, required: true }, // bot, user, oauth_application, webhook + hits: { type: Number, required: true }, // Number of times the user hit this bucket + blocked: { type: Boolean, required: true }, + expires_at: { type: Date, required: true }, +}); + +// @ts-ignore +export const BucketModel = db.model("Bucket", BucketSchema, "ratelimits"); -- cgit 1.5.1