From 5658c11cc3a2b13a86bbd4b5ff3bb1780d675acd Mon Sep 17 00:00:00 2001 From: Navy Date: Fri, 17 Apr 2020 23:18:29 +0300 Subject: [PATCH] fixes and save method --- structure/moderation/interfaces/Infraction.js | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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}`; } }