forked from Galactic/galactic-bot
68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
const { Structures } = require('discord.js');
|
|
|
|
const Guild = Structures.extend('Guild', (Guild) => {
|
|
|
|
class ExtendedGuild extends Guild {
|
|
|
|
constructor(...args) {
|
|
|
|
super(...args);
|
|
|
|
this._settings = null; //internal cache of current guild's settings; should ALWAYS stay the same as database.
|
|
|
|
}
|
|
|
|
async settings() {
|
|
|
|
if (!this._settings) this._settings = this.client.transactionHandler._send({ provider: 'mongodb', request: { type: 'findOne', query: { guild: this.id } } });
|
|
if (this._settings instanceof Promise) this._settings = await this._settings;
|
|
return this._settings;
|
|
|
|
}
|
|
|
|
async resolveMembers(members, strict = false) {
|
|
|
|
return await this.client.resolver.resolveMembers(members, this, strict);
|
|
|
|
}
|
|
|
|
async resolveMember(member, strict) {
|
|
|
|
let [ result ] = await this.resolveMembers([ member ], strict);
|
|
return result;
|
|
|
|
}
|
|
|
|
async resolveChannels(channels, strict = false) {
|
|
|
|
return await this.client.resolver.resolveChannels(channels, this, strict);
|
|
|
|
}
|
|
|
|
async resolveChannel(channel, strict) {
|
|
|
|
let [ result ] = await this.resolveMembers([ channel ], strict);
|
|
return result;
|
|
|
|
}
|
|
|
|
async resolveRoles(roles, strict = false) {
|
|
|
|
return await this.client.resolver.resolveRoles(roles, this, strict);
|
|
|
|
}
|
|
|
|
async resolveRole(role, strict) {
|
|
|
|
let [ result ] = await this.resolveRoles([ role ], strict);
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ExtendedGuild;
|
|
|
|
});
|
|
|
|
module.exports = Guild; |