2020-05-07 01:26:16 +02:00
|
|
|
const { Structures } = require('discord.js');
|
|
|
|
|
|
|
|
const GuildMember = Structures.extend('GuildMember', (GuildMember) => {
|
|
|
|
|
|
|
|
class ExtendedGuildMember extends GuildMember {
|
|
|
|
|
|
|
|
constructor(...args) {
|
|
|
|
|
|
|
|
super(...args);
|
|
|
|
|
|
|
|
this._cached = Date.now();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-06-16 00:15:13 +02:00
|
|
|
async _getMute() {
|
|
|
|
const { expirations } = this.client.moderationManager;
|
|
|
|
const filtered = expirations.filter((e) => e.infraction.type === 'MUTE'
|
|
|
|
&& e.infraction.target === this.id);
|
|
|
|
|
|
|
|
if(filtered.length > 0) return filtered.first();
|
|
|
|
const result = await this.client.transactionHandler.send({ //Checking for permanent mutes, won't show up in expirations.
|
|
|
|
provider: 'mongodb',
|
|
|
|
request: {
|
|
|
|
collection: 'infractions',
|
|
|
|
type: 'findOne',
|
|
|
|
query: { duration: 0, type: 'MUTE', target: this.id },
|
|
|
|
sort: { $natural: -1 } //latest mute
|
|
|
|
}
|
|
|
|
}).catch((e) => {}); //eslint-disable-line
|
|
|
|
if(result) return result;
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-07 01:26:16 +02:00
|
|
|
get timeSinceCached() {
|
|
|
|
return Date.now()-this._cached;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ExtendedGuildMember;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = GuildMember;
|