Add user status/activity

This commit is contained in:
Samuel Elliott 2018-04-14 15:15:03 +01:00
parent a7b300d233
commit 1b75753a3d
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
2 changed files with 15 additions and 0 deletions

View File

@ -33,6 +33,7 @@ export const Modules = {
get UserStore() { return this._getModule('UserStore'); },
get RelationshipStore() { return this._getModule('RelationshipStore'); },
get RelationshipManager() { return this._getModule('RelationshipManager'); },
get UserStatusStore() { return this._getModule('UserStatusStore'); },
get DiscordPermissions() { return this.DiscordConstants.Permissions; }
};

View File

@ -47,6 +47,20 @@ export class User {
return DiscordApi.guilds.filter(g => g.members.find(m => m.id === this.id));
}
get status() {
return Modules.UserStatusStore.getStatus(this.id);
}
get activity() {
// type can be either 0 (normal/rich presence game), 1 (streaming) or 2 (listening to Spotify)
// (3 appears as watching but is undocumented)
return Modules.UserStatusStore.getActivity(this.id);
}
get direct_messages() {
return DiscordApi.channels.find(c => c.type === 'DM' && c.recipient_id === this.id);
}
async ensurePrivateChannel() {
if (DiscordApi.currentUser.id === this.id)
throw new Error('Cannot create a direct message channel to the current user.');