Update UserNoteManager.js

This commit is contained in:
Elysia 2024-01-13 19:31:15 +07:00
parent 39b1d33857
commit ce5143bf9b

View File

@ -28,6 +28,26 @@ class UserNoteManager extends BaseManager {
else this.cache.set(id, note); else this.cache.set(id, note);
return this; return this;
} }
/**
* Obtains a user from Discord, or the user cache if it's already available.
* @param {UserResolvable} user The user to fetch
* @param {BaseFetchOptions} [options] Additional options for this fetch
* @returns {Promise<string>}
*/
async fetch(user, { cache = true, force = false } = {}) {
const id = this.resolveId(user);
if (!force) {
const existing = this.cache.get(id);
if (existing) return existing;
}
const data = await this.client.api.users['@me'].notes[id]
.get()
.then(d => d.note)
.catch(() => '');
if (cache) this.cache.set(id, data);
return data;
}
} }
module.exports = UserNoteManager; module.exports = UserNoteManager;