summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-03-04 10:08:55 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-03-04 10:08:55 +0100
commitce01628650ec1f1ae39a2e3f5a139ffae26ee00f (patch)
tree12e540211690dcc1cbe6642ba83bf457070ca121
parent:art: getPermission() default opts (diff)
downloadserver-ce01628650ec1f1ae39a2e3f5a139ffae26ee00f.tar.xz
:sparkles: AuditLog
-rw-r--r--dist/models/AuditLog.d.ts187
-rw-r--r--dist/models/AuditLog.js129
-rw-r--r--dist/models/AuditLog.js.map1
-rw-r--r--src/models/AuditLog.ts220
4 files changed, 537 insertions, 0 deletions
diff --git a/dist/models/AuditLog.d.ts b/dist/models/AuditLog.d.ts
new file mode 100644

index 00000000..902513a3 --- /dev/null +++ b/dist/models/AuditLog.d.ts
@@ -0,0 +1,187 @@ +/// <reference path="../util/MongoBigInt.d.ts" /> +import { Schema, Document, Types } from "mongoose"; +import { ChannelPermissionOverwrite } from "./Channel"; +import { PublicUser } from "./User"; +export interface AuditLogResponse { + webhooks: []; + users: PublicUser[]; + audit_log_entries: AuditLogEntries[]; + integrations: []; +} +export interface AuditLogEntries { + target_id?: bigint; + user_id: bigint; + id: bigint; + action_type: AuditLogEvents; + options?: { + delete_member_days?: string; + members_removed?: string; + channel_id?: bigint; + messaged_id?: bigint; + count?: string; + id?: bigint; + type?: string; + role_name?: string; + }; + changes: AuditLogChange[]; + reason?: string; +} +export interface AuditLogChange { + new_value?: AuditLogChangeValue; + old_value?: AuditLogChangeValue; + key: string; +} +export interface AuditLogChangeValue { + name?: string; + description?: string; + icon_hash?: string; + splash_hash?: string; + discovery_splash_hash?: string; + banner_hash?: string; + owner_id?: bigint; + region?: string; + preferred_locale?: string; + afk_channel_id?: bigint; + afk_timeout?: number; + rules_channel_id?: bigint; + public_updates_channel_id?: bigint; + mfa_level?: number; + verification_level?: number; + explicit_content_filter?: number; + default_message_notifications?: number; + vanity_url_code?: string; + $add?: {}[]; + $remove?: {}[]; + prune_delete_days?: number; + widget_enabled?: boolean; + widget_channel_id?: bigint; + system_channel_id?: bigint; + position?: number; + topic?: string; + bitrate?: number; + permission_overwrites?: ChannelPermissionOverwrite[]; + nsfw?: boolean; + application_id?: bigint; + rate_limit_per_user?: number; + permissions?: string; + color?: number; + hoist?: boolean; + mentionable?: boolean; + allow?: string; + deny?: string; + code?: string; + channel_id?: bigint; + inviter_id?: bigint; + max_uses?: number; + uses?: number; + max_age?: number; + temporary?: boolean; + deaf?: boolean; + mute?: boolean; + nick?: string; + avatar_hash?: string; + id?: bigint; + type?: number; + enable_emoticons?: boolean; + expire_behavior?: number; + expire_grace_period?: number; + user_limit?: number; +} +export interface AuditLogEntriesDocument extends Document, AuditLogEntries { + id: bigint; +} +export declare const AuditLogChanges: { + name: StringConstructor; + description: StringConstructor; + icon_hash: StringConstructor; + splash_hash: StringConstructor; + discovery_splash_hash: StringConstructor; + banner_hash: StringConstructor; + owner_id: typeof Types.Long; + region: StringConstructor; + preferred_locale: StringConstructor; + afk_channel_id: typeof Types.Long; + afk_timeout: NumberConstructor; + rules_channel_id: typeof Types.Long; + public_updates_channel_id: typeof Types.Long; + mfa_level: NumberConstructor; + verification_level: NumberConstructor; + explicit_content_filter: NumberConstructor; + default_message_notifications: NumberConstructor; + vanity_url_code: StringConstructor; + $add: {}[]; + $remove: {}[]; + prune_delete_days: NumberConstructor; + widget_enabled: BooleanConstructor; + widget_channel_id: typeof Types.Long; + system_channel_id: typeof Types.Long; + position: NumberConstructor; + topic: StringConstructor; + bitrate: NumberConstructor; + permission_overwrites: {}[]; + nsfw: BooleanConstructor; + application_id: typeof Types.Long; + rate_limit_per_user: NumberConstructor; + permissions: StringConstructor; + color: NumberConstructor; + hoist: BooleanConstructor; + mentionable: BooleanConstructor; + allow: StringConstructor; + deny: StringConstructor; + code: StringConstructor; + channel_id: typeof Types.Long; + inviter_id: typeof Types.Long; + max_uses: NumberConstructor; + uses: NumberConstructor; + max_age: NumberConstructor; + temporary: BooleanConstructor; + deaf: BooleanConstructor; + mute: BooleanConstructor; + nick: StringConstructor; + avatar_hash: StringConstructor; + id: typeof Types.Long; + type: NumberConstructor; + enable_emoticons: BooleanConstructor; + expire_behavior: NumberConstructor; + expire_grace_period: NumberConstructor; + user_limit: NumberConstructor; +}; +export declare const AuditLogSchema: Schema<Document<any>, import("mongoose").Model<Document<any>>, undefined>; +export declare const AuditLogModel: import("mongoose").Model<AuditLogEntries>; +export declare enum AuditLogEvents { + GUILD_UPDATE = 1, + CHANNEL_CREATE = 10, + CHANNEL_UPDATE = 11, + CHANNEL_DELETE = 12, + CHANNEL_OVERWRITE_CREATE = 13, + CHANNEL_OVERWRITE_UPDATE = 14, + CHANNEL_OVERWRITE_DELETE = 15, + MEMBER_KICK = 20, + MEMBER_PRUNE = 21, + MEMBER_BAN_ADD = 22, + MEMBER_BAN_REMOVE = 23, + MEMBER_UPDATE = 24, + MEMBER_ROLE_UPDATE = 25, + MEMBER_MOVE = 26, + MEMBER_DISCONNECT = 27, + BOT_ADD = 28, + ROLE_CREATE = 30, + ROLE_UPDATE = 31, + ROLE_DELETE = 32, + INVITE_CREATE = 40, + INVITE_UPDATE = 41, + INVITE_DELETE = 42, + WEBHOOK_CREATE = 50, + WEBHOOK_UPDATE = 51, + WEBHOOK_DELETE = 52, + EMOJI_CREATE = 60, + EMOJI_UPDATE = 61, + EMOJI_DELETE = 62, + MESSAGE_DELETE = 72, + MESSAGE_BULK_DELETE = 73, + MESSAGE_PIN = 74, + MESSAGE_UNPIN = 75, + INTEGRATION_CREATE = 80, + INTEGRATION_UPDATE = 81, + INTEGRATION_DELETE = 82 +} diff --git a/dist/models/AuditLog.js b/dist/models/AuditLog.js new file mode 100644
index 00000000..53df5c30 --- /dev/null +++ b/dist/models/AuditLog.js
@@ -0,0 +1,129 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AuditLogEvents = exports.AuditLogModel = exports.AuditLogSchema = exports.AuditLogChanges = void 0; +const mongoose_1 = require("mongoose"); +const Database_1 = __importDefault(require("../util/Database")); +exports.AuditLogChanges = { + name: String, + description: String, + icon_hash: String, + splash_hash: String, + discovery_splash_hash: String, + banner_hash: String, + owner_id: mongoose_1.Types.Long, + region: String, + preferred_locale: String, + afk_channel_id: mongoose_1.Types.Long, + afk_timeout: Number, + rules_channel_id: mongoose_1.Types.Long, + public_updates_channel_id: mongoose_1.Types.Long, + mfa_level: Number, + verification_level: Number, + explicit_content_filter: Number, + default_message_notifications: Number, + vanity_url_code: String, + $add: [{}], + $remove: [{}], + prune_delete_days: Number, + widget_enabled: Boolean, + widget_channel_id: mongoose_1.Types.Long, + system_channel_id: mongoose_1.Types.Long, + position: Number, + topic: String, + bitrate: Number, + permission_overwrites: [{}], + nsfw: Boolean, + application_id: mongoose_1.Types.Long, + rate_limit_per_user: Number, + permissions: String, + color: Number, + hoist: Boolean, + mentionable: Boolean, + allow: String, + deny: String, + code: String, + channel_id: mongoose_1.Types.Long, + inviter_id: mongoose_1.Types.Long, + max_uses: Number, + uses: Number, + max_age: Number, + temporary: Boolean, + deaf: Boolean, + mute: Boolean, + nick: String, + avatar_hash: String, + id: mongoose_1.Types.Long, + type: Number, + enable_emoticons: Boolean, + expire_behavior: Number, + expire_grace_period: Number, + user_limit: Number, +}; +exports.AuditLogSchema = new mongoose_1.Schema({ + target_id: mongoose_1.Types.Long, + user_id: { type: mongoose_1.Types.Long, required: true }, + id: { type: mongoose_1.Types.Long, required: true }, + action_type: { type: Number, required: true }, + options: { + delete_member_days: String, + members_removed: String, + channel_id: mongoose_1.Types.Long, + messaged_id: mongoose_1.Types.Long, + count: String, + id: mongoose_1.Types.Long, + type: String, + role_name: String, + }, + changes: [ + { + new_value: exports.AuditLogChanges, + old_value: exports.AuditLogChanges, + key: String, + }, + ], + reason: String, +}); +// @ts-ignore +exports.AuditLogModel = Database_1.default.model("AuditLog", exports.AuditLogSchema, "auditlogs"); +var AuditLogEvents; +(function (AuditLogEvents) { + AuditLogEvents[AuditLogEvents["GUILD_UPDATE"] = 1] = "GUILD_UPDATE"; + AuditLogEvents[AuditLogEvents["CHANNEL_CREATE"] = 10] = "CHANNEL_CREATE"; + AuditLogEvents[AuditLogEvents["CHANNEL_UPDATE"] = 11] = "CHANNEL_UPDATE"; + AuditLogEvents[AuditLogEvents["CHANNEL_DELETE"] = 12] = "CHANNEL_DELETE"; + AuditLogEvents[AuditLogEvents["CHANNEL_OVERWRITE_CREATE"] = 13] = "CHANNEL_OVERWRITE_CREATE"; + AuditLogEvents[AuditLogEvents["CHANNEL_OVERWRITE_UPDATE"] = 14] = "CHANNEL_OVERWRITE_UPDATE"; + AuditLogEvents[AuditLogEvents["CHANNEL_OVERWRITE_DELETE"] = 15] = "CHANNEL_OVERWRITE_DELETE"; + AuditLogEvents[AuditLogEvents["MEMBER_KICK"] = 20] = "MEMBER_KICK"; + AuditLogEvents[AuditLogEvents["MEMBER_PRUNE"] = 21] = "MEMBER_PRUNE"; + AuditLogEvents[AuditLogEvents["MEMBER_BAN_ADD"] = 22] = "MEMBER_BAN_ADD"; + AuditLogEvents[AuditLogEvents["MEMBER_BAN_REMOVE"] = 23] = "MEMBER_BAN_REMOVE"; + AuditLogEvents[AuditLogEvents["MEMBER_UPDATE"] = 24] = "MEMBER_UPDATE"; + AuditLogEvents[AuditLogEvents["MEMBER_ROLE_UPDATE"] = 25] = "MEMBER_ROLE_UPDATE"; + AuditLogEvents[AuditLogEvents["MEMBER_MOVE"] = 26] = "MEMBER_MOVE"; + AuditLogEvents[AuditLogEvents["MEMBER_DISCONNECT"] = 27] = "MEMBER_DISCONNECT"; + AuditLogEvents[AuditLogEvents["BOT_ADD"] = 28] = "BOT_ADD"; + AuditLogEvents[AuditLogEvents["ROLE_CREATE"] = 30] = "ROLE_CREATE"; + AuditLogEvents[AuditLogEvents["ROLE_UPDATE"] = 31] = "ROLE_UPDATE"; + AuditLogEvents[AuditLogEvents["ROLE_DELETE"] = 32] = "ROLE_DELETE"; + AuditLogEvents[AuditLogEvents["INVITE_CREATE"] = 40] = "INVITE_CREATE"; + AuditLogEvents[AuditLogEvents["INVITE_UPDATE"] = 41] = "INVITE_UPDATE"; + AuditLogEvents[AuditLogEvents["INVITE_DELETE"] = 42] = "INVITE_DELETE"; + AuditLogEvents[AuditLogEvents["WEBHOOK_CREATE"] = 50] = "WEBHOOK_CREATE"; + AuditLogEvents[AuditLogEvents["WEBHOOK_UPDATE"] = 51] = "WEBHOOK_UPDATE"; + AuditLogEvents[AuditLogEvents["WEBHOOK_DELETE"] = 52] = "WEBHOOK_DELETE"; + AuditLogEvents[AuditLogEvents["EMOJI_CREATE"] = 60] = "EMOJI_CREATE"; + AuditLogEvents[AuditLogEvents["EMOJI_UPDATE"] = 61] = "EMOJI_UPDATE"; + AuditLogEvents[AuditLogEvents["EMOJI_DELETE"] = 62] = "EMOJI_DELETE"; + AuditLogEvents[AuditLogEvents["MESSAGE_DELETE"] = 72] = "MESSAGE_DELETE"; + AuditLogEvents[AuditLogEvents["MESSAGE_BULK_DELETE"] = 73] = "MESSAGE_BULK_DELETE"; + AuditLogEvents[AuditLogEvents["MESSAGE_PIN"] = 74] = "MESSAGE_PIN"; + AuditLogEvents[AuditLogEvents["MESSAGE_UNPIN"] = 75] = "MESSAGE_UNPIN"; + AuditLogEvents[AuditLogEvents["INTEGRATION_CREATE"] = 80] = "INTEGRATION_CREATE"; + AuditLogEvents[AuditLogEvents["INTEGRATION_UPDATE"] = 81] = "INTEGRATION_UPDATE"; + AuditLogEvents[AuditLogEvents["INTEGRATION_DELETE"] = 82] = "INTEGRATION_DELETE"; +})(AuditLogEvents = exports.AuditLogEvents || (exports.AuditLogEvents = {})); +//# sourceMappingURL=AuditLog.js.map \ No newline at end of file diff --git a/dist/models/AuditLog.js.map b/dist/models/AuditLog.js.map new file mode 100644
index 00000000..b809fa3d --- /dev/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,CAAC,KAAK,CAAkB,UAAU,EAAE,sBAAc,EAAE,WAAW,CAAC,CAAC;AAEhG,IAAY,cAoCX;AApCD,WAAY,cAAc;IACzB,mEAAgB,CAAA;IAChB,wEAAmB,CAAA;IACnB,wEAAmB,CAAA;IACnB,wEAAmB,CAAA;IACnB,4FAA6B,CAAA;IAC7B,4FAA6B,CAAA;IAC7B,4FAA6B,CAAA;IAC7B,kEAAgB,CAAA;IAChB,oEAAiB,CAAA;IACjB,wEAAmB,CAAA;IACnB,8EAAsB,CAAA;IACtB,sEAAkB,CAAA;IAClB,gFAAuB,CAAA;IACvB,kEAAgB,CAAA;IAChB,8EAAsB,CAAA;IACtB,0DAAY,CAAA;IACZ,kEAAgB,CAAA;IAChB,kEAAgB,CAAA;IAChB,kEAAgB,CAAA;IAChB,sEAAkB,CAAA;IAClB,sEAAkB,CAAA;IAClB,sEAAkB,CAAA;IAClB,wEAAmB,CAAA;IACnB,wEAAmB,CAAA;IACnB,wEAAmB,CAAA;IACnB,oEAAiB,CAAA;IACjB,oEAAiB,CAAA;IACjB,oEAAiB,CAAA;IACjB,wEAAmB,CAAA;IACnB,kFAAwB,CAAA;IACxB,kEAAgB,CAAA;IAChB,sEAAkB,CAAA;IAClB,gFAAuB,CAAA;IACvB,gFAAuB,CAAA;IACvB,gFAAuB,CAAA;AACxB,CAAC,EApCW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAoCzB"} \ No newline at end of file diff --git a/src/models/AuditLog.ts b/src/models/AuditLog.ts new file mode 100644
index 00000000..f69c4329 --- /dev/null +++ b/src/models/AuditLog.ts
@@ -0,0 +1,220 @@ +import { Schema, Document, Types } from "mongoose"; +import db from "../util/Database"; +import { ChannelPermissionOverwrite } from "./Channel"; +import { PublicUser } from "./User"; + +export interface AuditLogResponse { + webhooks: []; // TODO: + users: PublicUser[]; + audit_log_entries: AuditLogEntries[]; + integrations: []; +} + +export interface AuditLogEntries { + target_id?: bigint; + user_id: bigint; + id: bigint; + action_type: AuditLogEvents; + options?: { + delete_member_days?: string; + members_removed?: string; + channel_id?: bigint; + messaged_id?: bigint; + count?: string; + id?: bigint; + type?: string; + role_name?: string; + }; + changes: AuditLogChange[]; + reason?: string; +} + +export interface AuditLogChange { + new_value?: AuditLogChangeValue; + old_value?: AuditLogChangeValue; + key: string; +} + +export interface AuditLogChangeValue { + name?: string; + description?: string; + icon_hash?: string; + splash_hash?: string; + discovery_splash_hash?: string; + banner_hash?: string; + owner_id?: bigint; + region?: string; + preferred_locale?: string; + afk_channel_id?: bigint; + afk_timeout?: number; + rules_channel_id?: bigint; + public_updates_channel_id?: bigint; + mfa_level?: number; + verification_level?: number; + explicit_content_filter?: number; + default_message_notifications?: number; + vanity_url_code?: string; + $add?: {}[]; + $remove?: {}[]; + prune_delete_days?: number; + widget_enabled?: boolean; + widget_channel_id?: bigint; + system_channel_id?: bigint; + position?: number; + topic?: string; + bitrate?: number; + permission_overwrites?: ChannelPermissionOverwrite[]; + nsfw?: boolean; + application_id?: bigint; + rate_limit_per_user?: number; + permissions?: string; + color?: number; + hoist?: boolean; + mentionable?: boolean; + allow?: string; + deny?: string; + code?: string; + channel_id?: bigint; + inviter_id?: bigint; + max_uses?: number; + uses?: number; + max_age?: number; + temporary?: boolean; + deaf?: boolean; + mute?: boolean; + nick?: string; + avatar_hash?: string; + id?: bigint; + type?: number; + enable_emoticons?: boolean; + expire_behavior?: number; + expire_grace_period?: number; + user_limit?: number; +} + +export interface AuditLogEntriesDocument extends Document, AuditLogEntries { + id: bigint; +} + +export const AuditLogChanges = { + name: String, + description: String, + icon_hash: String, + splash_hash: String, + discovery_splash_hash: String, + banner_hash: String, + owner_id: Types.Long, + region: String, + preferred_locale: String, + afk_channel_id: Types.Long, + afk_timeout: Number, + rules_channel_id: Types.Long, + public_updates_channel_id: Types.Long, + mfa_level: Number, + verification_level: Number, + explicit_content_filter: Number, + default_message_notifications: Number, + vanity_url_code: String, + $add: [{}], + $remove: [{}], + prune_delete_days: Number, + widget_enabled: Boolean, + widget_channel_id: Types.Long, + system_channel_id: Types.Long, + position: Number, + topic: String, + bitrate: Number, + permission_overwrites: [{}], + nsfw: Boolean, + application_id: Types.Long, + rate_limit_per_user: Number, + permissions: String, + color: Number, + hoist: Boolean, + mentionable: Boolean, + allow: String, + deny: String, + code: String, + channel_id: Types.Long, + inviter_id: Types.Long, + max_uses: Number, + uses: Number, + max_age: Number, + temporary: Boolean, + deaf: Boolean, + mute: Boolean, + nick: String, + avatar_hash: String, + id: Types.Long, + type: Number, + enable_emoticons: Boolean, + expire_behavior: Number, + expire_grace_period: Number, + user_limit: Number, +}; + +export const AuditLogSchema = new Schema({ + target_id: Types.Long, + user_id: { type: Types.Long, required: true }, + id: { type: Types.Long, required: true }, + action_type: { type: Number, required: true }, + options: { + delete_member_days: String, + members_removed: String, + channel_id: Types.Long, + messaged_id: Types.Long, + count: String, + id: Types.Long, + type: String, + role_name: String, + }, + changes: [ + { + new_value: AuditLogChanges, + old_value: AuditLogChanges, + key: String, + }, + ], + reason: String, +}); + +// @ts-ignore +export const AuditLogModel = db.model<AuditLogEntries>("AuditLog", AuditLogSchema, "auditlogs"); + +export enum AuditLogEvents { + GUILD_UPDATE = 1, + CHANNEL_CREATE = 10, + CHANNEL_UPDATE = 11, + CHANNEL_DELETE = 12, + CHANNEL_OVERWRITE_CREATE = 13, + CHANNEL_OVERWRITE_UPDATE = 14, + CHANNEL_OVERWRITE_DELETE = 15, + MEMBER_KICK = 20, + MEMBER_PRUNE = 21, + MEMBER_BAN_ADD = 22, + MEMBER_BAN_REMOVE = 23, + MEMBER_UPDATE = 24, + MEMBER_ROLE_UPDATE = 25, + MEMBER_MOVE = 26, + MEMBER_DISCONNECT = 27, + BOT_ADD = 28, + ROLE_CREATE = 30, + ROLE_UPDATE = 31, + ROLE_DELETE = 32, + INVITE_CREATE = 40, + INVITE_UPDATE = 41, + INVITE_DELETE = 42, + WEBHOOK_CREATE = 50, + WEBHOOK_UPDATE = 51, + WEBHOOK_DELETE = 52, + EMOJI_CREATE = 60, + EMOJI_UPDATE = 61, + EMOJI_DELETE = 62, + MESSAGE_DELETE = 72, + MESSAGE_BULK_DELETE = 73, + MESSAGE_PIN = 74, + MESSAGE_UNPIN = 75, + INTEGRATION_CREATE = 80, + INTEGRATION_UPDATE = 81, + INTEGRATION_DELETE = 82, +}