Switch config back to camelCase

This commit is contained in:
Schuyler Cebulskie
2016-09-27 18:42:32 -04:00
parent 4fceae02d6
commit ba8dd3467a
14 changed files with 49 additions and 49 deletions

File diff suppressed because one or more lines are too long

View File

@@ -29,12 +29,12 @@ class Client extends EventEmitter {
*/
this.options = mergeDefault(Constants.DefaultOptions, options);
if (!this.options.shard_id && 'SHARD_ID' in process.env) {
this.options.shard_id = Number(process.env.SHARD_ID);
if (!this.options.shardId && 'SHARD_ID' in process.env) {
this.options.shardId = Number(process.env.SHARD_ID);
}
if (!this.options.shard_count && 'SHARD_COUNT' in process.env) {
this.options.shard_count = Number(process.env.SHARD_COUNT);
if (!this.options.shardCount && 'SHARD_COUNT' in process.env) {
this.options.shardCount = Number(process.env.SHARD_COUNT);
}
/**
@@ -150,8 +150,8 @@ class Client extends EventEmitter {
this._timeouts = new Set();
this._intervals = new Set();
if (this.options.message_sweep_interval > 0) {
this.setInterval(this.sweepMessages.bind(this), this.options.message_sweep_interval * 1000);
if (this.options.messageSweepInterval > 0) {
this.setInterval(this.sweepMessages.bind(this), this.options.messageSweepInterval * 1000);
}
}
@@ -273,12 +273,12 @@ class Client extends EventEmitter {
/**
* Sweeps all channels' messages and removes the ones older than the max message lifetime.
* If the message has been edited, the time of the edit is used rather than the time of the original message.
* @param {number} [lifetime=this.options.message_cache_lifetime] Messages that are older than this (in seconds)
* will be removed from the caches. The default is based on the client's `message_cache_lifetime` option.
* @param {number} [lifetime=this.options.messageCacheLifetime] Messages that are older than this (in seconds)
* will be removed from the caches. The default is based on the client's `messageCacheLifetime` option.
* @returns {number} Amount of messages that were removed from the caches,
* or -1 if the message cache lifetime is unlimited
*/
sweepMessages(lifetime = this.options.message_cache_lifetime) {
sweepMessages(lifetime = this.options.messageCacheLifetime) {
if (typeof lifetime !== 'number' || isNaN(lifetime)) throw new TypeError('Lifetime must be a number.');
if (lifetime <= 0) {
this.emit('debug', 'Didn\'t sweep messages - lifetime is unlimited');

View File

@@ -27,7 +27,7 @@ class ClientDataManager {
* @event Client#guildCreate
* @param {Guild} guild The created guild
*/
if (this.client.options.fetch_all_members) {
if (this.client.options.fetchAllMembers) {
guild.fetchMembers().then(() => { this.client.emit(Constants.Events.GUILD_CREATE, guild); });
} else {
this.client.emit(Constants.Events.GUILD_CREATE, guild);

View File

@@ -24,7 +24,7 @@ class ChannelDeleteAction extends Action {
}
scheduleForDeletion(id) {
this.client.setTimeout(() => this.deleted.delete(id), this.client.options.rest_ws_bridge_timeout);
this.client.setTimeout(() => this.deleted.delete(id), this.client.options.restWsBridgeTimeout);
}
}

View File

@@ -38,7 +38,7 @@ class GuildDeleteAction extends Action {
}
scheduleForDeletion(id) {
this.client.setTimeout(() => this.deleted.delete(id), this.client.options.rest_ws_bridge_timeout);
this.client.setTimeout(() => this.deleted.delete(id), this.client.options.restWsBridgeTimeout);
}
}

View File

@@ -36,7 +36,7 @@ class GuildMemberRemoveAction extends Action {
}
scheduleForDeletion(guildID, userID) {
this.client.setTimeout(() => this.deleted.delete(guildID + userID), this.client.options.rest_ws_bridge_timeout);
this.client.setTimeout(() => this.deleted.delete(guildID + userID), this.client.options.restWsBridgeTimeout);
}
}

View File

@@ -33,7 +33,7 @@ class GuildRoleDeleteAction extends Action {
}
scheduleForDeletion(guildID, roleID) {
this.client.setTimeout(() => this.deleted.delete(guildID + roleID), this.client.options.rest_ws_bridge_timeout);
this.client.setTimeout(() => this.deleted.delete(guildID + roleID), this.client.options.restWsBridgeTimeout);
}
}

View File

@@ -33,7 +33,7 @@ class MessageDeleteAction extends Action {
scheduleForDeletion(channelID, messageID) {
this.client.setTimeout(() => this.deleted.delete(channelID + messageID),
this.client.options.rest_ws_bridge_timeout);
this.client.options.restWsBridgeTimeout);
}
}

View File

@@ -26,7 +26,7 @@ class RESTManager {
}
getRequestHandler() {
switch (this.client.options.api_request_method) {
switch (this.client.options.apiRequestMethod) {
case 'sequential':
return SequentialRequestHandler;
case 'burst':

View File

@@ -41,18 +41,18 @@ class RESTMethods {
return new Promise((resolve, reject) => {
this.rest.makeRequest('get', Constants.Endpoints.gateway, true)
.then(res => {
this.rest.client.ws.gateway = `${res.url}/?encoding=json&v=${this.rest.client.options.protocol_version}`;
this.rest.client.ws.gateway = `${res.url}/?encoding=json&v=${this.rest.client.options.protocolVersion}`;
resolve(this.rest.client.ws.gateway);
})
.catch(reject);
});
}
sendMessage(channel, content, { tts, nonce, disable_everyone, split } = {}, file = null) {
sendMessage(channel, content, { tts, nonce, disableEveryone, split } = {}, file = null) {
return new Promise((resolve, reject) => {
if (typeof content !== 'undefined') content = this.rest.client.resolver.resolveString(content);
if (disable_everyone || (typeof disable_everyone === 'undefined' && this.rest.client.options.disable_everyone)) {
if (disableEveryone || (typeof disableEveryone === 'undefined' && this.rest.client.options.disableEveryone)) {
content = content.replace('@everyone', '@\u200beveryone').replace('@here', '@\u200bhere');
}

View File

@@ -171,8 +171,8 @@ class WebSocketManager extends EventEmitter {
this.reconnecting = false;
const payload = this.client.options.ws;
payload.token = this.client.token;
if (this.client.options.shard_count > 0) {
payload.shard = [Number(this.client.options.shard_id), Number(this.client.options.shard_count)];
if (this.client.options.shardCount > 0) {
payload.shard = [Number(this.client.options.shardId), Number(this.client.options.shardCount)];
}
this.client.emit('debug', 'Identifying as new session');
this.send({
@@ -256,7 +256,7 @@ class WebSocketManager extends EventEmitter {
}
if (unavailableCount === 0) {
this.status = Constants.Status.NEARLY;
if (this.client.options.fetch_all_members) {
if (this.client.options.fetchAllMembers) {
const promises = this.client.guilds.array().map(g => g.fetchMembers());
Promise.all(promises).then(() => this._emitReady()).catch(e => {
this.client.emit(Constants.Event.WARN, `Error on pre-ready guild member fetching - ${e}`);

View File

@@ -18,7 +18,7 @@ class ShardClientUtil {
* @type {number}
*/
get id() {
return this.client.options.shard_id;
return this.client.options.shardId;
}
/**
@@ -26,7 +26,7 @@ class ShardClientUtil {
* @type {number}
*/
get count() {
return this.client.options.shard_count;
return this.client.options.shardCount;
}
/**

View File

@@ -27,7 +27,7 @@ class TextBasedChannel {
* @typedef {Object} MessageOptions
* @property {boolean} [tts=false] Whether or not the message should be spoken aloud
* @property {string} [nonce=''] The nonce for the message
* @property {boolean} [disable_everyone=this.client.options.disable_everyone] Whether or not @everyone and @here
* @property {boolean} [disableEveryone=this.client.options.disableEveryone] Whether or not @everyone and @here
* should be replaced with plain-text
* @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if
* it exceeds the character limit. If an object is provided, these are the options for splitting the message.
@@ -320,7 +320,7 @@ class TextBasedChannel {
}
_cacheMessage(message) {
const maxSize = this.client.options.max_message_cache;
const maxSize = this.client.options.maxMessageCache;
if (maxSize === 0) return null;
if (this.messages.size >= maxSize) this.messages.delete(this.messages.keys().next().value);

View File

@@ -1,35 +1,35 @@
/**
* Options for a Client.
* @typedef {Object} ClientOptions
* @property {string} [api_request_method='sequential'] 'sequential' or 'burst'. Sequential executes all requests in
* @property {string} [apiRequestMethod='sequential'] 'sequential' or 'burst'. Sequential executes all requests in
* the order they are triggered, whereas burst runs multiple at a time, and doesn't guarantee a particular order.
* @property {number} [shard_id=0] The ID of this shard
* @property {number} [shard_count=0] The number of shards
* @property {number} [max_message_cache=200] Number of messages to cache per channel
* @property {number} [message_cache_lifetime=0] How long until a message should be uncached by the message sweeping
* @property {number} [shardId=0] The ID of this shard
* @property {number} [shardCount=0] The number of shards
* @property {number} [maxMessageCache=200] Number of messages to cache per channel
* @property {number} [messageCacheLifetime=0] How long until a message should be uncached by the message sweeping
* (in seconds, 0 for forever)
* @property {number} [message_sweep_interval=0] How frequently to remove messages from the cache that are older than
* @property {number} [messageSweepInterval=0] How frequently to remove messages from the cache that are older than
* the max message lifetime (in seconds, 0 for never)
* @property {boolean} [fetch_all_members=false] Whether to cache all guild members and users upon startup
* @property {boolean} [disable_everyone=false] Default value for MessageOptions.disable_everyone
* @property {number} [rest_ws_bridge_timeout=5000] Maximum time permitted between REST responses and their
* @property {boolean} [fetchAllMembers=false] Whether to cache all guild members and users upon startup
* @property {boolean} [disableEveryone=false] Default value for MessageOptions.disableEveryone
* @property {number} [restWsBridgeTimeout=5000] Maximum time permitted between REST responses and their
* corresponding websocket events
* @property {WebsocketOptions} [ws] Options for the websocket
*/
exports.DefaultOptions = {
api_request_method: 'sequential',
shard_id: 0,
shard_count: 0,
max_message_cache: 200,
message_cache_lifetime: 0,
message_sweep_interval: 0,
fetch_all_members: false,
disable_everyone: false,
rest_ws_bridge_timeout: 5000,
protocol_version: 6,
apiRequestMethod: 'sequential',
shardId: 0,
shardCount: 0,
maxMessageCache: 200,
messageCacheLifetime: 0,
messageSweepInterval: 0,
fetchAllMembers: false,
disableEveryone: false,
restWsBridgeTimeout: 5000,
protocolVersion: 6,
/**
* Websocket options.
* Websocket options. These are left as snake_case to match the API.
* @typedef {Object} WebsocketOptions
* @property {number} [large_threshold=250] Number of members in a guild to be considered large
* @property {boolean} [compress=true] Whether to compress data sent on the connection
@@ -72,10 +72,10 @@ exports.Errors = {
NOT_A_PERMISSION: 'Invalid permission string or number.',
INVALID_RATE_LIMIT_METHOD: 'Unknown rate limiting method.',
BAD_LOGIN: 'Incorrect login details were provided.',
INVALID_SHARD: 'Invalid shard settings were provided',
INVALID_SHARD: 'Invalid shard settings were provided.',
};
const API = `https://discordapp.com/api/v${exports.DefaultOptions.protocol_version}`;
const API = `https://discordapp.com/api/v${exports.DefaultOptions.protocolVersion}`;
const Endpoints = exports.Endpoints = {
// general endpoints