fix: RelationshipManager cache missing
This commit is contained in:
parent
1c0aefd7ec
commit
0324e0f684
@ -112,6 +112,8 @@ module.exports = async (client, { d: data }, shard) => {
|
||||
|
||||
client.user.connectedAccounts = data.connected_accounts ?? [];
|
||||
|
||||
client.relationships._setup(data.relationships);
|
||||
|
||||
client.user._patchNote(data.notes);
|
||||
|
||||
const syncTime = Date.now();
|
||||
@ -159,7 +161,5 @@ module.exports = async (client, { d: data }, shard) => {
|
||||
});
|
||||
}
|
||||
|
||||
client.relationships._setup(data.relationships);
|
||||
|
||||
shard.checkReady();
|
||||
};
|
||||
|
@ -111,20 +111,25 @@ class RelationshipManager {
|
||||
|
||||
/**
|
||||
* Obtains a user from Discord, or the user cache if it's already available.
|
||||
* @param {UserResolvable} user The user to fetch
|
||||
* @param {UserResolvable} [user] The user to fetch
|
||||
* @param {BaseFetchOptions} [options] Additional options for this fetch
|
||||
* @returns {Promise<RelationshipTypes>} Enums
|
||||
* @returns {Promise<RelationshipTypes|RelationshipManager>}
|
||||
*/
|
||||
async fetch(user, { force = false } = {}) {
|
||||
const id = this.resolveId(user);
|
||||
if (!force) {
|
||||
const existing = this.cache.get(id);
|
||||
if (existing && !existing.partial) return existing;
|
||||
if (user) {
|
||||
const id = this.resolveId(user);
|
||||
if (!force) {
|
||||
const existing = this.cache.get(id);
|
||||
if (existing && !existing.partial) return existing;
|
||||
}
|
||||
const data = await this.client.api.users['@me'].relationships.get();
|
||||
await this._setup(data);
|
||||
return this.cache.get(id);
|
||||
} else {
|
||||
const data = await this.client.api.users['@me'].relationships.get();
|
||||
await this._setup(data);
|
||||
return this;
|
||||
}
|
||||
|
||||
const data = await this.client.api.users['@me'].relationships.get();
|
||||
await this._setup(data);
|
||||
return this.cache.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,6 +115,12 @@ class DMChannel extends Channel {
|
||||
* @returns {Promise<VoiceConnection>}
|
||||
*/
|
||||
call(options = {}) {
|
||||
options = Object.assign(
|
||||
{
|
||||
ring: true,
|
||||
},
|
||||
options || {},
|
||||
);
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.client.options.patchVoice) {
|
||||
reject(
|
||||
@ -124,7 +130,7 @@ class DMChannel extends Channel {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
if (options?.ring) {
|
||||
if (options.ring) {
|
||||
this.client.api.channels(this.id).call.ring.post({
|
||||
body: {
|
||||
recipients: null,
|
||||
|
@ -311,6 +311,12 @@ class PartialGroupDMChannel extends Channel {
|
||||
* @returns {Promise<VoiceConnection>}
|
||||
*/
|
||||
call(options = {}) {
|
||||
options = Object.assign(
|
||||
{
|
||||
ring: true,
|
||||
},
|
||||
options || {},
|
||||
);
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.client.options.patchVoice) {
|
||||
reject(
|
||||
@ -320,7 +326,7 @@ class PartialGroupDMChannel extends Channel {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
if (options?.ring) {
|
||||
if (options.ring) {
|
||||
this.client.api.channels(this.id).call.ring.post({
|
||||
body: {
|
||||
recipients: null,
|
||||
|
Loading…
Reference in New Issue
Block a user