fixes and save method

This commit is contained in:
Erik 2020-04-17 23:18:29 +03:00
parent 34d80332ff
commit 5658c11cc3

View File

@ -7,7 +7,7 @@ class Infraction {
this.client = client; this.client = client;
this.target = opts.target; //User or channel being targeted. 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.executor = opts.executor; //Whoever executed the command.
this.guild = opts.guild; 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 { return {
id: `${this.guild.id}:${this.case}`, id: `${this.guild.id}:${this.case}`,
guild: this.guild.id, guild: this.guild.id,
@ -49,13 +61,13 @@ class Infraction {
expiration: this.expiration, expiration: this.expiration,
reason: this.reason, reason: this.reason,
timestamp: this.timestamp, timestamp: this.timestamp,
} };
} }
get targetName() { get targetName() {
return this.targetType === 'user' return this.targetType === 'user'
? this.target.tag ? this.target.tag
: `#${this.target.name}` : `#${this.target.name}`;
} }
} }