feat: fetching presences

#1429
This commit is contained in:
Elysia
2025-01-21 10:57:25 +07:00
parent 9f44c85782
commit b03adcc7c1
2 changed files with 14 additions and 0 deletions

View File

@@ -53,6 +53,19 @@ class PresenceManager extends CachedManager {
const userId = this.client.users.resolveId(presence);
return this.cache.has(userId) ? userId : null;
}
/**
* Fetches the overall user presence for all of the user's non-offline friends and implicit relationships.
* @returns {Promise<Collection<Snowflake, Presence>>}
*/
async fetch() {
const data = await this.client.api.presences.get();
// https://docs.discord.sex/resources/presence#endpoints
data.presences.forEach(presence => {
this._add(presence, true);
});
return this.cache;
}
}
module.exports = PresenceManager;

1
typings/index.d.ts vendored
View File

@@ -4650,6 +4650,7 @@ export class PermissionOverwriteManager extends CachedManager<
export class PresenceManager extends CachedManager<Snowflake, Presence, PresenceResolvable> {
private constructor(client: Client, iterable?: Iterable<RawPresenceData>);
public fetch(): Promise<Collection<Snowflake, Presence>>;
}
export class ReactionManager extends CachedManager<Snowflake | string, MessageReaction, MessageReactionResolvable> {