forked from Galactic/galactic-bot
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
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.size > 0) return filtered.first();
|
|
const result = await this.client.storageManager.mongodb.infractions.findOne(
|
|
{ duration: 0, type, target: this.id },
|
|
{ sort: { timestamp: -1 } }// Finds latest mute.
|
|
).catch((error) => { //eslint-disable-line no-unused-vars
|
|
return null;
|
|
});
|
|
|
|
return result || null;
|
|
|
|
}
|
|
|
|
get admin() {
|
|
return this.user.developer || this.hasPermission('ADMINISTRATOR') || this.hasPermission('MANAGE_GUILD');
|
|
}
|
|
|
|
get timeSinceCached() {
|
|
return Date.now()-this._cached;
|
|
}
|
|
|
|
get display() {
|
|
return this.user.tag;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
return ExtendedGuildMember;
|
|
|
|
});
|
|
|
|
module.exports = GuildMember; |