2020-02-01 23:23:36 +00:00
|
|
|
import { ObjectId } from 'bson';
|
|
|
|
import { PermissionOverwriteOption } from 'discord.js';
|
|
|
|
|
|
|
|
export interface UserInfraction {
|
|
|
|
action: 'Warn' | 'Kick' | 'Mute' | 'Ban';
|
2020-01-19 18:55:35 +00:00
|
|
|
active: boolean;
|
|
|
|
guild: string;
|
|
|
|
id: number;
|
|
|
|
moderator: string;
|
|
|
|
reason: string;
|
|
|
|
time: Date;
|
|
|
|
}
|
|
|
|
|
2020-02-01 23:23:36 +00:00
|
|
|
export interface UserBackup {
|
|
|
|
guild: string;
|
|
|
|
id: number;
|
|
|
|
roles: string[];
|
|
|
|
nickname: string;
|
|
|
|
channelOverrides: UserBackupChannelOverride[];
|
|
|
|
deafened: boolean;
|
|
|
|
muted: boolean;
|
|
|
|
createdAt: Date;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface UserBackupChannelOverride {
|
|
|
|
channelId: number;
|
|
|
|
overrides: PermissionOverwriteOption;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface UserStats {
|
|
|
|
totalSentMessages: number;
|
|
|
|
totalSentCharacters: number;
|
|
|
|
totalDeletedMessages: number;
|
|
|
|
totalCustomEmojisUsed: number;
|
|
|
|
totalTimesMentionedAUser: number;
|
|
|
|
totalSentAttachments: number;
|
|
|
|
totalTimesReacted: number;
|
|
|
|
mostUsedReaction: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface UserReactions {
|
|
|
|
[name: string]: number;
|
|
|
|
}
|
|
|
|
|
2020-01-19 18:55:35 +00:00
|
|
|
export interface UserDoc {
|
|
|
|
blacklisted?: boolean;
|
|
|
|
id: string;
|
2020-02-01 23:23:36 +00:00
|
|
|
infractions?: UserInfraction[];
|
|
|
|
backups?: UserBackup[];
|
|
|
|
stats?: UserStats;
|
|
|
|
reactions?: UserReactions;
|
2020-01-19 18:55:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export class User implements UserDoc {
|
2020-02-01 23:23:36 +00:00
|
|
|
_id: ObjectId;
|
2020-01-19 18:55:35 +00:00
|
|
|
blacklisted: boolean;
|
|
|
|
id: string;
|
|
|
|
infractions: UserInfraction[];
|
2020-02-01 23:23:36 +00:00
|
|
|
backups: UserBackup[];
|
|
|
|
stats: UserStats;
|
2020-01-19 18:55:35 +00:00
|
|
|
constructor(data: UserDoc) {
|
2020-02-01 23:23:36 +00:00
|
|
|
this._id = new ObjectId();
|
2020-01-19 18:55:35 +00:00
|
|
|
this.blacklisted = data.blacklisted ?? false;
|
|
|
|
this.id = data.id;
|
2020-02-01 23:23:36 +00:00
|
|
|
this.infractions = data.infractions ?? [];
|
|
|
|
this.backups = data.backups ?? [];
|
|
|
|
this.stats = data.stats ?? {
|
|
|
|
totalSentMessages: 0,
|
|
|
|
totalSentCharacters: 0,
|
|
|
|
totalDeletedMessages: 0,
|
|
|
|
totalCustomEmojisUsed: 0,
|
|
|
|
totalTimesMentionedAUser: 0,
|
|
|
|
totalSentAttachments: 0,
|
|
|
|
totalTimesReacted: 0,
|
|
|
|
mostUsedReaction: '',
|
|
|
|
};
|
2020-01-19 18:55:35 +00:00
|
|
|
}
|
|
|
|
}
|