From 0f8e8dddff99219223d74e8eaa1ba416f6164594 Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Tue, 25 Oct 2016 21:40:53 +0100 Subject: [PATCH] fix presence updating --- src/client/websocket/packets/handlers/Ready.js | 2 +- src/structures/ClientUser.js | 1 + src/util/Constants.js | 2 ++ test/random.js | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client/websocket/packets/handlers/Ready.js b/src/client/websocket/packets/handlers/Ready.js index b512c962d..bb35ea47b 100644 --- a/src/client/websocket/packets/handlers/Ready.js +++ b/src/client/websocket/packets/handlers/Ready.js @@ -31,7 +31,7 @@ class ReadyHandler extends AbstractHandler { client._setPresence(presence.user.id, presence); } - if (!client.user.bot) client.setInterval(client.syncGuilds.bind(client), 30000); + if (!client.user.bot && client.options.sync) client.setInterval(client.syncGuilds.bind(client), 30000); client.once('ready', client.syncGuilds.bind(client)); if (!client.users.has('1')) { diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index ab19f5ea7..899504411 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -198,6 +198,7 @@ class ClientUser extends User { this.localPresence = { status, game, afk }; this.localPresence.since = 0; + this.localPresence.game = this.localPresence.game || null; this.client.ws.send({ op: 3, diff --git a/src/util/Constants.js b/src/util/Constants.js index 2adb29dae..cd163cc37 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -8,6 +8,7 @@ exports.Package = require('../../package.json'); * @property {number} [shardId=0] The ID of this shard * @property {number} [shardCount=0] The number of shards * @property {number} [messageCacheMaxSize=200] Maximum number of messages to cache per channel + * @property {boolean} [sync=false] Whether to periodically sync guilds * (-1 for unlimited - don't do this without message sweeping, otherwise memory usage will climb indefinitely) * @property {number} [messageCacheLifetime=0] How long until a message should be uncached by the message sweeping * (in seconds, 0 for forever) @@ -34,6 +35,7 @@ exports.DefaultOptions = { disableEveryone: false, restWsBridgeTimeout: 5000, disabledEvents: [], + sync: false, /** * Websocket options. These are left as snake_case to match the API. diff --git a/test/random.js b/test/random.js index efc8662f6..502c43456 100644 --- a/test/random.js +++ b/test/random.js @@ -8,7 +8,7 @@ const client = new Discord.Client({ fetchAllMembers: false, apiRequestMethod: 's const { email, password, token, usertoken, song } = require('./auth.json'); -client.login(token).then(atoken => console.log('logged in with token ' + atoken)).catch(console.error); +client.login(usertoken).then(atoken => console.log('logged in with token ' + atoken)).catch(console.error); client.ws.on('send', console.log);