diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-12 20:33:02 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-12 20:33:02 +0200 |
commit | 4f2596789875b894e5b45d7cfafcc7cf6ca46aef (patch) | |
tree | 20b4728a0ff390bd982f2346807f3176efc8c1f9 /util/src/models/RateLimit.ts | |
parent | Merge branch 'rtc' (diff) | |
download | server-4f2596789875b894e5b45d7cfafcc7cf6ca46aef.tar.xz |
:sparkles: util
Diffstat (limited to 'util/src/models/RateLimit.ts')
-rw-r--r-- | util/src/models/RateLimit.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/util/src/models/RateLimit.ts b/util/src/models/RateLimit.ts new file mode 100644 index 00000000..6a0e1ffd --- /dev/null +++ b/util/src/models/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<BucketDocument>("Bucket", BucketSchema, "ratelimits"); |