option for sync get userwrapper

This commit is contained in:
Erik 2022-04-23 01:16:48 +03:00
parent 60422ea3c6
commit 1b291d1236
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -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 (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); return new Promise((resolve) => {
const wrapper = new UserWrapper(this, user); this.users.fetch(id).then((user) => {
this.userWrappers.set(id, wrapper); const wrapper = new UserWrapper(this, user);
return wrapper; this.userWrappers.set(id, wrapper);
resolve(wrapper);
});
});
} }
get prefix() {
return this._options.discord.prefix;
}
} }
module.exports = DiscordClient; module.exports = DiscordClient;