From f632ae54b4c63511fef3993fc5d06bc5477060b2 Mon Sep 17 00:00:00 2001 From: Navy Date: Thu, 12 Nov 2020 20:12:46 +0200 Subject: [PATCH] method for checking invite --- structure/extensions/Guild.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/structure/extensions/Guild.js b/structure/extensions/Guild.js index b933243..6f4c954 100644 --- a/structure/extensions/Guild.js +++ b/structure/extensions/Guild.js @@ -17,8 +17,19 @@ const Guild = Structures.extend('Guild', (Guild) => { this.callbacks = []; this.webhooks = new Collection(); + this.invites = null; + } + async checkInvite(code) { + + // Is maintained by the utility hook + if (!this.invites && this.me.hasPermission('MANAGE_GUILD')) this.invites = await this.fetchInvites(); + return this.invites?.has(code) || false; + + } + + //Fetch and cache settings async settings() { if(!this._settings) this._settings = this.client.storageManager.mongodb.guilds.findOne({ guildId: this.id });