add ClientPresence, remove ClientPresenceStore

This commit is contained in:
Amish Shah
2018-08-11 10:46:51 +01:00
parent 3c2eaff226
commit ea764afad2
8 changed files with 21 additions and 33 deletions

View File

@@ -14,7 +14,7 @@ const VoiceBroadcast = require('./voice/VoiceBroadcast');
const UserStore = require('../stores/UserStore');
const ChannelStore = require('../stores/ChannelStore');
const GuildStore = require('../stores/GuildStore');
const ClientPresenceStore = require('../stores/ClientPresenceStore');
const ClientPresence = require('../structures/ClientPresence');
const GuildEmojiStore = require('../stores/GuildEmojiStore');
const { Events, browser } = require('../util/Constants');
const DataResolver = require('../util/DataResolver');
@@ -97,10 +97,11 @@ class Client extends BaseClient {
this.channels = new ChannelStore(this);
/**
* Presences that have been received for the client user, mapped by user IDs
* @type {ClientPresenceStore<Snowflake, Presence>}
* The presence of the Client
* @private
* @type {ClientPresence}
*/
this.presences = new ClientPresenceStore(this);
this.presence = new ClientPresence(this);
Object.defineProperty(this, 'token', { writable: true });
if (!browser && !this.token && 'CLIENT_TOKEN' in process.env) {

View File

@@ -41,9 +41,9 @@ class ClientManager {
const timeout = this.client.setTimeout(() => reject(new Error('WS_CONNECTION_TIMEOUT')), 1000 * 300);
this.client.api.gateway.get().then(async res => {
if (this.client.options.presence != null) { // eslint-disable-line eqeqeq
const presence = await this.client.presences._parse(this.client.options.presence);
const presence = await this.client.presence._parse(this.client.options.presence);
this.client.options.ws.presence = presence;
this.client.presences.clientPresence.patch(presence);
this.client.presence.patch(presence);
}
const gateway = `${res.url}/`;
this.client.emit(Events.DEBUG, `Using gateway ${gateway}`);

View File

@@ -9,7 +9,7 @@ class ReadyHandler extends AbstractHandler {
client.ws.heartbeat();
client.presences.clientPresence.userID = data.user.id;
client.presence.userID = data.user.id;
if (!ClientUser) ClientUser = require('../../../../structures/ClientUser');
const clientUser = new ClientUser(client, data.user);
client.user = clientUser;