diff --git a/structure/moderation/interfaces/Infraction.js b/structure/moderation/interfaces/Infraction.js index 0283fc1..b38f045 100644 --- a/structure/moderation/interfaces/Infraction.js +++ b/structure/moderation/interfaces/Infraction.js @@ -7,7 +7,7 @@ class Infraction { this.client = client; this.target = opts.target; //User or channel being targeted. - this.targetType = opts.targetType; // 'user' or 'channek'. + this.targetType = opts.targetType; // 'user' or 'channel'. this.executor = opts.executor; //Whoever executed the command. this.guild = opts.guild; @@ -34,7 +34,19 @@ class Infraction { } - _json() { + async save() { + + await this.client.transactionHandler._send({ + provider: 'mongodb', + request: { + type: 'insertOne', + data: this._json + } + }).catch(console.error); + + } + + get _json() { return { id: `${this.guild.id}:${this.case}`, guild: this.guild.id, @@ -49,13 +61,13 @@ class Infraction { expiration: this.expiration, reason: this.reason, timestamp: this.timestamp, - } + }; } get targetName() { return this.targetType === 'user' ? this.target.tag - : `#${this.target.name}` + : `#${this.target.name}`; } }