Rip, fixes a bug we didn't even know to look for... 1870 lives on. (#1931)

possibly fixes #1870
This commit is contained in:
bdistin
2017-09-24 10:24:58 -05:00
committed by Crawl
parent 26c978c465
commit c2029a66e9

View File

@@ -90,17 +90,18 @@ class GuildMemberStore extends DataStore {
*/ */
fetch(options) { fetch(options) {
if (!options) return this._fetchMany(); if (!options) return this._fetchMany();
const user = this.resolveID(options); const user = this.client.users.resolveID(options);
if (user) return this._fetchSingle({ user, cache: true }); if (user) return this._fetchSingle({ user, cache: true });
if (options.user) { if (options.user) {
options.user = this.resolveID(options.user); options.user = this.client.users.resolveID(options.user);
if (options.user) return this._fetchSingle(options); if (options.user) return this._fetchSingle(options);
} }
return this._fetchMany(options); return this._fetchMany(options);
} }
_fetchSingle({ user, cache }) { _fetchSingle({ user, cache }) {
if (this.has(user)) return Promise.resolve(this.get(user)); const existing = this.get(user);
if (existing) return Promise.resolve(existing);
return this.client.api.guilds(this.guild.id).members(user).get() return this.client.api.guilds(this.guild.id).members(user).get()
.then(data => this.create(data, cache)); .then(data => this.create(data, cache));
} }