refactor: make use of destructuring for Constants (#1942)

This commit is contained in:
SpaceEEC
2017-09-16 20:31:36 +02:00
committed by Crawl
parent 25ece1882b
commit ec4c98704f
66 changed files with 262 additions and 262 deletions

View File

@@ -1,6 +1,6 @@
const DataStore = require('./DataStore');
const Channel = require('../structures/Channel');
const Constants = require('../util/Constants');
const { Events } = require('../util/Constants');
const kLru = Symbol('LRU');
const lruable = ['group', 'dm'];
@@ -58,7 +58,7 @@ class ChannelStore extends DataStore {
const channel = Channel.create(this.client, data, guild);
if (!channel) {
this.client.emit(Constants.Events.DEBUG, `Failed to find guild for channel ${data.id} ${data.type}`);
this.client.emit(Events.DEBUG, `Failed to find guild for channel ${data.id} ${data.type}`);
return null;
}

View File

@@ -1,6 +1,6 @@
const PresenceStore = require('./PresenceStore');
const Collection = require('../util/Collection');
const Constants = require('../util/Constants');
const { ActivityTypes, OPCodes } = require('../util/Constants');
const { Presence } = require('../structures/Presence');
const { TypeError } = require('../errors');
@@ -34,7 +34,7 @@ class ClientPresenceStore extends PresenceStore {
since: since != null ? since : null, // eslint-disable-line eqeqeq
status: status || this.clientPresence.status,
game: activity ? {
type: typeof activity.type === 'number' ? activity.type : Constants.ActivityTypes.indexOf(activity.type),
type: typeof activity.type === 'number' ? activity.type : ActivityTypes.indexOf(activity.type),
name: activity.name,
url: activity.url,
details: activity.details || undefined,
@@ -54,7 +54,7 @@ class ClientPresenceStore extends PresenceStore {
};
this.clientPresence.patch(packet);
this.client.ws.send({ op: Constants.OPCodes.STATUS_UPDATE, d: packet });
this.client.ws.send({ op: OPCodes.STATUS_UPDATE, d: packet });
return this.clientPresence;
}
}

View File

@@ -1,6 +1,6 @@
const DataStore = require('./DataStore');
const GuildMember = require('../structures/GuildMember');
const Constants = require('../util/Constants');
const { Events, OPCodes } = require('../util/Constants');
const Collection = require('../util/Collection');
const { Error } = require('../errors');
@@ -112,7 +112,7 @@ class GuildMemberStore extends DataStore {
return;
}
this.guild.client.ws.send({
op: Constants.OPCodes.REQUEST_GUILD_MEMBERS,
op: OPCodes.REQUEST_GUILD_MEMBERS,
d: {
guild_id: this.guild.id,
query,
@@ -128,13 +128,13 @@ class GuildMemberStore extends DataStore {
if (this.guild.memberCount <= this.size ||
((query || limit) && members.size < 1000) ||
(limit && fetchedMembers.size >= limit)) {
this.guild.client.removeListener(Constants.Events.GUILD_MEMBERS_CHUNK, handler);
this.guild.client.removeListener(Events.GUILD_MEMBERS_CHUNK, handler);
resolve(query || limit ? fetchedMembers : this);
}
};
this.guild.client.on(Constants.Events.GUILD_MEMBERS_CHUNK, handler);
this.guild.client.on(Events.GUILD_MEMBERS_CHUNK, handler);
this.guild.client.setTimeout(() => {
this.guild.client.removeListener(Constants.Events.GUILD_MEMBERS_CHUNK, handler);
this.guild.client.removeListener(Events.GUILD_MEMBERS_CHUNK, handler);
reject(new Error('GUILD_MEMBERS_TIMEOUT'));
}, 120e3);
});