From d29107cced31419a9eea68ae7dc85dbfacdb03ba Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Mon, 28 Mar 2022 01:43:12 +0300 Subject: [PATCH] perms fetch --- src/structure/client/wrappers/GuildWrapper.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/structure/client/wrappers/GuildWrapper.js b/src/structure/client/wrappers/GuildWrapper.js index be04c78..c0ed07f 100644 --- a/src/structure/client/wrappers/GuildWrapper.js +++ b/src/structure/client/wrappers/GuildWrapper.js @@ -17,6 +17,14 @@ class GuildWrapper { } + 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; + + } + async settings(forceFetch = false) { if (this._settings && !forceFetch) return this._settings; @@ -43,6 +51,16 @@ class GuildWrapper { } } + async permissions() { + if (this._permissions) return this._permissions; + + const perms = await this.client.storageManager.mongodb.permissions.findOne({ guildId: this.id }); + if (!perms) this._permissions = { guildId: this.id }; + else this._permissions = perms; + + return this._permissions; + } + /** * Update a webhook entry in the database *