fix presence updating

This commit is contained in:
Amish Shah
2016-10-25 21:40:53 +01:00
parent 2ee6da8d79
commit 0f8e8dddff
4 changed files with 5 additions and 2 deletions

View File

@@ -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')) {

View File

@@ -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,

View File

@@ -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.

View File

@@ -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);