mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
feat: bypass cache check with forceFetch param (#4592)
This commit is contained in:
@@ -222,11 +222,15 @@ class User extends Base {
|
||||
|
||||
/**
|
||||
* Creates a DM channel between the client and the user.
|
||||
* @param {boolean} [force=false] Whether to skip the cache check and request the API
|
||||
* @returns {Promise<DMChannel>}
|
||||
*/
|
||||
async createDM() {
|
||||
const { dmChannel } = this;
|
||||
if (dmChannel && !dmChannel.partial) return dmChannel;
|
||||
async createDM(force = false) {
|
||||
if (!force) {
|
||||
const { dmChannel } = this;
|
||||
if (dmChannel && !dmChannel.partial) return dmChannel;
|
||||
}
|
||||
|
||||
const data = await this.client.api.users(this.client.user.id).channels.post({
|
||||
data: {
|
||||
recipient_id: this.id,
|
||||
@@ -265,10 +269,11 @@ class User extends Base {
|
||||
|
||||
/**
|
||||
* Fetches this user's flags.
|
||||
* @param {boolean} [force=false] Whether to skip the cache check and request the AP
|
||||
* @returns {Promise<UserFlags>}
|
||||
*/
|
||||
async fetchFlags() {
|
||||
if (this.flags) return this.flags;
|
||||
async fetchFlags(force = false) {
|
||||
if (this.flags && !force) return this.flags;
|
||||
const data = await this.client.api.users(this.id).get();
|
||||
this._patch(data);
|
||||
return this.flags;
|
||||
@@ -276,10 +281,11 @@ class User extends Base {
|
||||
|
||||
/**
|
||||
* Fetches this user.
|
||||
* @param {boolean} [force=false] Whether to skip the cache check and request the AP
|
||||
* @returns {Promise<User>}
|
||||
*/
|
||||
fetch() {
|
||||
return this.client.users.fetch(this.id, true);
|
||||
fetch(force = false) {
|
||||
return this.client.users.fetch(this.id, true, force);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user