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.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}`;
}
}