From 1b291d1236e6e51a49691cf9393c0fc138758274 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sat, 23 Apr 2022 01:16:48 +0300 Subject: [PATCH] option for sync get userwrapper --- src/structure/DiscordClient.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/structure/DiscordClient.js b/src/structure/DiscordClient.js index f9f7613..c742a23 100644 --- a/src/structure/DiscordClient.js +++ b/src/structure/DiscordClient.js @@ -234,17 +234,30 @@ class DiscordClient extends Client { } - async getUserWrapper(id) { + getUserWrapper(id, fetch = true) { if (this.userWrappers.has(id)) return this.userWrappers.get(id); + if (!fetch) { + const user = this.users.cache.get(id); + const wrapper = new UserWrapper(this, user); + this.userWrappers.set(id, wrapper); + return wrapper; + } - const user = await this.users.fetch(id); - const wrapper = new UserWrapper(this, user); - this.userWrappers.set(id, wrapper); - return wrapper; + return new Promise((resolve) => { + this.users.fetch(id).then((user) => { + const wrapper = new UserWrapper(this, user); + this.userWrappers.set(id, wrapper); + resolve(wrapper); + }); + }); } + get prefix() { + return this._options.discord.prefix; + } + } module.exports = DiscordClient;