Fetch group recipients upon first seeing a group.

This commit is contained in:
Paul
2021-03-30 21:52:02 +01:00
parent 28ae2e307e
commit cec93fa513
3 changed files with 11 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "revolt.js",
"version": "4.0.0-alpha.15",
"version": "4.0.0-alpha.16",
"main": "dist/index.js",
"repository": "https://gitlab.insrt.uk/revolt/revolt.js",
"author": "Paul Makles <insrt.uk>",
+1 -1
View File
@@ -1,7 +1,7 @@
export * from './Client';
export { Channel, User, Message } from './api/objects';
export const LIBRARY_VERSION = '4.0.0-alpha.15';
export const LIBRARY_VERSION = '4.0.0-alpha.16';
export const defaultConfig = {
apiURL: 'https://api.revolt.chat',
+9
View File
@@ -26,6 +26,15 @@ export default class Channels extends Collection<Channel> {
async fetchMutable(id: string) {
if (this.map[id]) return this.get(id) as Channel;
let res = await this.client.req<'GET', '/channels/:id'>('GET', `/channels/${id}` as any);
// Fetch user information if this is the first time we are seeing this object.
// We shouldn't need to fetch for anything apart from groups.
if (res.channel_type === 'Group') {
for (let member of res.recipients) {
await this.client.users.fetch(member);
}
}
this.set(res);
return this.get(id) as Channel;
}