forked from Galactic/galactic-bot
fixes and save method
This commit is contained in:
parent
34d80332ff
commit
5658c11cc3
@ -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}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user