const { Structures } = require('discord.js'); const GuildMember = Structures.extend('GuildMember', (GuildMember) => { class ExtendedGuildMember extends GuildMember { constructor(...args) { super(...args); this._cached = Date.now(); } async _getExpiration(type) { if(!type) return null; const { callbacks } = this.client.moderationManager; const filtered = callbacks.filter((e) => e.infraction.type === type && 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, target: this.id }, sort: { timestamp: -1 } //latest mute } }).catch((e) => { return null }); //eslint-disable-line if(result) return result; return null; } get admin() { return this.user.developer || this.hasPermission('ADMINISTRATOR') || this.hasPermission('MANAGE_GUILD'); } get timeSinceCached() { return Date.now()-this._cached; } } return ExtendedGuildMember; }); module.exports = GuildMember;