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:
@@ -90,10 +90,11 @@ class Channel extends Base {
|
||||
|
||||
/**
|
||||
* Fetches this channel.
|
||||
* @param {boolean} [force=false] Whether to skip the cache check and request the API
|
||||
* @returns {Promise<Channel>}
|
||||
*/
|
||||
fetch() {
|
||||
return this.client.channels.fetch(this.id, true);
|
||||
fetch(force = false) {
|
||||
return this.client.channels.fetch(this.id, true, force);
|
||||
}
|
||||
|
||||
static create(client, data, guild) {
|
||||
|
||||
@@ -61,10 +61,11 @@ class DMChannel extends Channel {
|
||||
|
||||
/**
|
||||
* Fetch this DMChannel.
|
||||
* @param {boolean} [force=false] Whether to skip the cache check and request the API
|
||||
* @returns {Promise<DMChannel>}
|
||||
*/
|
||||
fetch() {
|
||||
return this.recipient.createDM();
|
||||
fetch(force = false) {
|
||||
return this.recipient.createDM(force);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -373,10 +373,11 @@ class GuildMember extends Base {
|
||||
|
||||
/**
|
||||
* Fetches this GuildMember.
|
||||
* @param {boolean} [force=false] Whether to skip the cache check and request the API
|
||||
* @returns {Promise<GuildMember>}
|
||||
*/
|
||||
fetch() {
|
||||
return this.guild.members.fetch(this.id, true);
|
||||
fetch(force = false) {
|
||||
return this.guild.members.fetch({ user: this.id, cache: true, force });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -547,10 +547,11 @@ class Message extends Base {
|
||||
|
||||
/**
|
||||
* Fetch this message.
|
||||
* @param {boolean} [force=false] Whether to skip the cache check and request the API
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
fetch() {
|
||||
return this.channel.messages.fetch(this.id, true);
|
||||
fetch(force = false) {
|
||||
return this.channel.messages.fetch(this.id, true, force);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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