Cherry pick commits from indev

This commit is contained in:
Schuyler Cebulskie
2016-10-27 19:48:34 -04:00
parent 96e46cbf37
commit 1841122a8f
8 changed files with 21 additions and 49 deletions

View File

@@ -1,30 +1,16 @@
<div align="center"> <div align="center">
<p> <p>
<a href="https://discord.js.org"> <a href="https://discord.js.org"><img src="https://i.imgur.com/StEGtEh.png" width="546" alt="discord.js" /></a>
<img src="https://i.imgur.com/StEGtEh.png" width="546" alt="discord.js" />
</a>
</p> </p>
<p> <p>
<a href="https://discord.gg/bRCvFy9"> <a href="https://discord.gg/bRCvFy9"><img src="https://discordapp.com/api/guilds/222078108977594368/embed.png" alt="Discord server" /></a>
<img src="https://discordapp.com/api/guilds/222078108977594368/embed.png" alt="Discord server" /> <a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/v/discord.js.svg?maxAge=3600" alt="NPM version" /></a>
</a> <a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600" alt="NPM downloads" /></a>
<a href="https://www.npmjs.com/package/discord.js"> <a href="https://travis-ci.org/hydrabolt/discord.js"><img src="https://travis-ci.org/hydrabolt/discord.js.svg" alt="Build status" /></a>
<img src="https://img.shields.io/npm/v/discord.js.svg?maxAge=3600" alt="NPM version" /> <a href="https://david-dm.org/hydrabolt/discord.js"><img src="https://img.shields.io/david/hydrabolt/discord.js.svg?maxAge=3600" alt="Dependencies" /></a>
</a>
<a href="https://www.npmjs.com/package/discord.js">
<img src="https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600" alt="NPM downloads" />
</a>
<a href="https://travis-ci.org/hydrabolt/discord.js">
<img src="https://travis-ci.org/hydrabolt/discord.js.svg" alt="Build status" />
</a>
<a href="https://david-dm.org/hydrabolt/discord.js">
<img src="https://img.shields.io/david/hydrabolt/discord.js.svg?maxAge=3600" alt="Dependencies" />
</a>
</p> </p>
<p> <p>
<a href="https://nodei.co/npm/discord.js/"> <a href="https://nodei.co/npm/discord.js/"><img src="https://nodei.co/npm/discord.js.png?downloads=true&stars=true" alt="NPM info" /></a>
<img src="https://nodei.co/npm/discord.js.png?downloads=true&stars=true" alt="NPM info" />
</a>
</p> </p>
</div> </div>

View File

@@ -1,30 +1,16 @@
<div align="center"> <div align="center">
<p> <p>
<a href="https://discord.js.org"> <a href="https://discord.js.org"><img src="https://i.imgur.com/StEGtEh.png" width="546" alt="discord.js" /></a>
<img src="https://i.imgur.com/StEGtEh.png" width="546" alt="discord.js" />
</a>
</p> </p>
<p> <p>
<a href="https://discord.gg/bRCvFy9"> <a href="https://discord.gg/bRCvFy9"><img src="https://discordapp.com/api/guilds/222078108977594368/embed.png" alt="Discord server" /></a>
<img src="https://discordapp.com/api/guilds/222078108977594368/embed.png" alt="Discord server" /> <a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/v/discord.js.svg?maxAge=3600" alt="NPM version" /></a>
</a> <a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600" alt="NPM downloads" /></a>
<a href="https://www.npmjs.com/package/discord.js"> <a href="https://travis-ci.org/hydrabolt/discord.js"><img src="https://travis-ci.org/hydrabolt/discord.js.svg" alt="Build status" /></a>
<img src="https://img.shields.io/npm/v/discord.js.svg?maxAge=3600" alt="NPM version" /> <a href="https://david-dm.org/hydrabolt/discord.js"><img src="https://img.shields.io/david/hydrabolt/discord.js.svg?maxAge=3600" alt="Dependencies" /></a>
</a>
<a href="https://www.npmjs.com/package/discord.js">
<img src="https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600" alt="NPM downloads" />
</a>
<a href="https://travis-ci.org/hydrabolt/discord.js">
<img src="https://travis-ci.org/hydrabolt/discord.js.svg" alt="Build status" />
</a>
<a href="https://david-dm.org/hydrabolt/discord.js">
<img src="https://img.shields.io/david/hydrabolt/discord.js.svg?maxAge=3600" alt="Dependencies" />
</a>
</p> </p>
<p> <p>
<a href="https://nodei.co/npm/discord.js/"> <a href="https://nodei.co/npm/discord.js/"><img src="https://nodei.co/npm/discord.js.png?downloads=true&stars=true" alt="NPM info" /></a>
<img src="https://nodei.co/npm/discord.js.png?downloads=true&stars=true" alt="NPM info" />
</a>
</p> </p>
</div> </div>

View File

@@ -236,8 +236,8 @@ class Client extends EventEmitter {
destroy() { destroy() {
for (const t of this._timeouts) clearTimeout(t); for (const t of this._timeouts) clearTimeout(t);
for (const i of this._intervals) clearInterval(i); for (const i of this._intervals) clearInterval(i);
this._timeouts = []; this._timeouts.clear();
this._intervals = []; this._intervals.clear();
this.token = null; this.token = null;
this.email = null; this.email = null;
this.password = null; this.password = null;

View File

@@ -58,10 +58,10 @@ class ClientManager {
} }
destroy() { destroy() {
return new Promise((resolve) => { return new Promise((resolve, reject) => {
this.client.ws.destroy(); this.client.ws.destroy();
if (!this.client.user.bot) { if (!this.client.user.bot) {
this.client.rest.methods.logout().then(resolve); this.client.rest.methods.logout().then(resolve, reject);
} else { } else {
resolve(); resolve();
} }

View File

@@ -80,7 +80,7 @@ class ClientVoiceManager {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.pending.get(channel.guild.id)) throw new Error('Already connecting to this guild\'s voice server.'); if (this.pending.get(channel.guild.id)) throw new Error('Already connecting to this guild\'s voice server.');
if (!channel.permissionsFor(this.client.user).hasPermission('CONNECT')) { if (!channel.joinable) {
throw new Error('You do not have permission to join this voice channel'); throw new Error('You do not have permission to join this voice channel');
} }

View File

@@ -142,7 +142,6 @@ class VoiceWebSocket extends EventEmitter {
* Called whenever the connection to the WebSocket Server is lost * Called whenever the connection to the WebSocket Server is lost
*/ */
onClose() { onClose() {
// TODO see if the connection is open before reconnecting
if (!this.dead) this.client.setTimeout(this.connect.bind(this), this.attempts * 1000); if (!this.dead) this.client.setTimeout(this.connect.bind(this), this.attempts * 1000);
} }

View File

@@ -1,5 +1,6 @@
/** /**
* Represents a Secret Key used in encryption over voice * Represents a Secret Key used in encryption over voice
* @private
*/ */
class SecretKey { class SecretKey {
constructor(key) { constructor(key) {

View File

@@ -650,7 +650,7 @@ class Guild {
const updatedRoles = this.roles.array().map(r => ({ const updatedRoles = this.roles.array().map(r => ({
id: r.id, id: r.id,
position: r.id === role ? position : (r.position < position ? r.position : r.position + 1), position: r.id === role ? position : r.position < position ? r.position : r.position + 1,
})); }));
return this.client.rest.methods.setRolePositions(this.id, updatedRoles); return this.client.rest.methods.setRolePositions(this.id, updatedRoles);