From b3934787964b48e6d3a4cbfee9d401414ba2002c Mon Sep 17 00:00:00 2001 From: Navy Date: Sun, 19 Apr 2020 22:54:57 +0300 Subject: [PATCH] fetch settings --- structure/extensions/User.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/structure/extensions/User.js b/structure/extensions/User.js index 042ef4d..9462362 100644 --- a/structure/extensions/User.js +++ b/structure/extensions/User.js @@ -18,6 +18,14 @@ const User = Structures.extend('User', (User) => { return Date.now()-this._cached; } + async settings() { + + if (!this._settings) this._settings = this.client.transactionHandler._send({ provider: 'mongodb', request: { collection: 'user_settings', type: 'findOne', query: { user: this.id } } }); + if (this._settings instanceof Promise) this._settings = await this._settings || {}; + return this._settings; + + } + } return ExtendedUser;