Skip to content

Commit

Permalink
Merge branch '11.1-dev' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
amishshah committed Sep 3, 2017
2 parents 9cdd494 + 77c54a9 commit 42c195c
Show file tree
Hide file tree
Showing 81 changed files with 1,925 additions and 905 deletions.
42 changes: 21 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Packages
node_modules/
yarn.lock

# Log files
logs/
*.log

# Authentication
test/auth.json
test/auth.js
docs/deploy/deploy_key
docs/deploy/deploy_key.pub
deploy/deploy_key
deploy/deploy_key.pub

# Miscellaneous
.tmp/
.vscode/
docs/docs.json
webpack/
# Packages
node_modules/
yarn.lock

# Log files
logs/
*.log

# Authentication
test/auth.json
test/auth.js
docs/deploy/deploy_key
docs/deploy/deploy_key.pub
deploy/deploy_key
deploy/deploy_key.pub

# Miscellaneous
.tmp/
.vscode/
docs/docs.json
webpack/
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-json=false
20 changes: 15 additions & 5 deletions .tern-project
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"ecmaVersion": 6,
"ecmaVersion": 7,
"libs": [],
"loadEagerly": [
"./src/*.js"
],
"dontLoad": [
"node_modules/**"
],
"plugins": {
"node": {
"dontLoad": "node_modules/**",
"load": "",
"modules": ""
"es_modules": {},
"node": {},
"doc_comment": {
"fullDocs": true,
"strong": true
},
"webpack": {
"configPath": "./webpack.config.js",
}
}
}
36 changes: 20 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
language: node_js
node_js:
- "6"
- "7"
cache:
directories:
- node_modules
install: npm install
script:
- bash ./deploy/deploy.sh
env:
global:
- ENCRYPTION_LABEL: "af862fa96d3e"
- COMMIT_AUTHOR_EMAIL: "amishshah.2k@gmail.com"
dist: trusty
sudo: false
language: node_js
node_js:
- "6"
- "7"
cache:
directories:
- node_modules
install: npm install
script: bash ./deploy/test.sh
jobs:
include:
- stage: build
node_js: "6"
script: bash ./deploy/deploy.sh
env:
global:
- ENCRYPTION_LABEL: "af862fa96d3e"
- COMMIT_AUTHOR_EMAIL: "amishshah.2k@gmail.com"
dist: trusty
sudo: false
9 changes: 9 additions & 0 deletions browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const browser = typeof window !== 'undefined';
const webpack = !!process.env.__DISCORD_WEBPACK__;

const Discord = require('./');

module.exports = Discord;
if (browser && webpack) window.Discord = Discord; // eslint-disable-line no-undef
// eslint-disable-next-line no-console
else if (!browser) console.warn('Warning: Attempting to use browser version of Discord.js in a non-browser environment!');
20 changes: 6 additions & 14 deletions deploy/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@

set -e

function tests {
npm run lint
npm run docs:test
VERSIONED=false npm run webpack
exit 0
}

function build {
npm run lint
npm run docs
VERSIONED=false npm run webpack
}
Expand All @@ -22,10 +14,10 @@ if [[ "$TRAVIS_BRANCH" == revert-* ]]; then
exit 0
fi

# For PRs, only run tests
# For PRs, do nothing
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo -e "\e[36m\e[1mBuild triggered for PR #${TRAVIS_PULL_REQUEST} to branch \"${TRAVIS_BRANCH}\" - only running tests."
tests
echo -e "\e[36m\e[1mBuild triggered for PR #${TRAVIS_PULL_REQUEST} to branch \"${TRAVIS_BRANCH}\" - doing nothing."
exit 0
fi

# Figure out the source of the build
Expand All @@ -39,10 +31,10 @@ else
SOURCE_TYPE="branch"
fi

# For Node != 6, only run tests
# For Node != 6, do nothing
if [ "$TRAVIS_NODE_VERSION" != "6" ]; then
echo -e "\e[36m\e[1mBuild triggered with Node v${TRAVIS_NODE_VERSION} - only running tests."
tests
echo -e "\e[36m\e[1mBuild triggered with Node v${TRAVIS_NODE_VERSION} - doing nothing."
exit 0
fi

build
Expand Down
34 changes: 34 additions & 0 deletions deploy/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -e

function tests {
npm run lint
npm run docs:test
exit 0
}

# For revert branches, do nothing
if [[ "$TRAVIS_BRANCH" == revert-* ]]; then
echo -e "\e[36m\e[1mTest triggered for reversion branch \"${TRAVIS_BRANCH}\" - doing nothing."
exit 0
fi

# For PRs
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo -e "\e[36m\e[1mTest triggered for PR #${TRAVIS_PULL_REQUEST} to branch \"${TRAVIS_BRANCH}\" - only running tests."
tests
fi

# Figure out the source of the test
if [ -n "$TRAVIS_TAG" ]; then
echo -e "\e[36m\e[1mTest triggered for tag \"${TRAVIS_TAG}\"."
else
echo -e "\e[36m\e[1mTest triggered for branch \"${TRAVIS_BRANCH}\"."
fi

# For Node != 6
if [ "$TRAVIS_NODE_VERSION" != "6" ]; then
echo -e "\e[36m\e[1mTest triggered with Node v${TRAVIS_NODE_VERSION} - only running tests."
tests
fi
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
## [View the documentation here.](https://discord.js.org/#/docs)
## [View the documentation here.](https://discord.js.org/#/docs)
6 changes: 1 addition & 5 deletions docs/examples/greeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ client.on('ready', () => {

// Create an event listener for new guild members
client.on('guildMemberAdd', member => {
// Send the message to the guilds default channel (usually #general), mentioning the member
member.guild.defaultChannel.send(`Welcome to the server, ${member}!`);

// If you want to send the message to a designated channel on a server instead
// you can do the following:
// Send the message to a designated channel on a server:
const channel = member.guild.channels.find('name', 'member-log');
// Do nothing if the channel wasn't found on this server
if (!channel) return;
Expand Down
12 changes: 8 additions & 4 deletions docs/general/updating.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 11.2.0
v11.2.0 fixes a lot of bugs we encountered along the 11.1.0 release, as well as support for new features such as Message Attachments and UserGuildSettings.
See [the changelog](https://github.com/hydrabolt/discord.js/releases/tag/11.2.0) for a full list of changes, including information about deprecations.

# Version 11.1.0
v11.1.0 features improved voice and gateway stability, as well as support for new features such as audit logs and searching for messages.
See [the changelog](https://github.com/hydrabolt/discord.js/releases/tag/11.1.0) for a full list of changes, including
Expand Down Expand Up @@ -118,9 +122,9 @@ The guild parameter that has been dropped from the guild-related events can stil

## Dates and timestamps
All dates/timestamps on the structures have been refactored to have a consistent naming scheme and availability.
All of them are named similarly to this:
**Date:** `Message.createdAt`
**Timestamp:** `Message.createdTimestamp`
All of them are named similarly to this:
**Date:** `Message.createdAt`
**Timestamp:** `Message.createdTimestamp`
See the docs for each structure to see which date/timestamps are available on them.


Expand Down Expand Up @@ -149,7 +153,7 @@ A couple more important details:
* `Client.servers.length` ==> `client.guilds.size` (all instances of `server` are now `guild`)

## No more callbacks!
Version 9 eschews callbacks in favour of Promises. This means all code relying on callbacks must be changed.
Version 9 eschews callbacks in favour of Promises. This means all code relying on callbacks must be changed.
For example, the following code:

```js
Expand Down
14 changes: 7 additions & 7 deletions docs/general/welcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</div>

# Welcome!
Welcome to the discord.js v11.1.0 documentation.
v11.1.0 features improved voice and gateway stability, as well as support for new features such as audit logs and searching for messages.
Welcome to the discord.js v11.2.0 documentation.
v11.2.0 fixes a lot of bugs we encountered along the 11.1.0 release, as well as support for new features such as Message Attachments and UserGuildSettings.

## About
discord.js is a powerful [node.js](https://nodejs.org) module that allows you to interact with the
Expand All @@ -30,11 +30,11 @@ discord.js is a powerful [node.js](https://nodejs.org) module that allows you to
- 100% coverage of the Discord API

## Installation
**Node.js 6.0.0 or newer is required.**
**Node.js 6.0.0 or newer is required.**
Ignore any warnings about unmet peer dependencies, as they're all optional.

Without voice support: `npm install discord.js --save`
With voice support ([node-opus](https://www.npmjs.com/package/node-opus)): `npm install discord.js node-opus --save`
Without voice support: `npm install discord.js --save`
With voice support ([node-opus](https://www.npmjs.com/package/node-opus)): `npm install discord.js node-opus --save`
With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discord.js opusscript --save`

### Audio engines
Expand Down Expand Up @@ -79,8 +79,8 @@ client.login('your token');

## Contributing
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
[documentation](https://discord.js.org/#/docs).
See [the contribution guide](https://github.com/hydrabolt/discord.js/blob/master/CONTRIBUTING.md) if you'd like to submit a PR.
[documentation](https://discord.js.org/#/docs).
See [the contribution guide](https://github.com/hydrabolt/discord.js/blob/master/.github/CONTRIBUTING.md) if you'd like to submit a PR.

## Help
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/voice.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Voice in discord.js can be used for many things, such as music bots, recording o
In discord.js, you can use voice by connecting to a `VoiceChannel` to obtain a `VoiceConnection`, where you can start streaming and receiving audio.

To get started, make sure you have:
* ffmpeg - `npm install --global ffmpeg-binaries`
* ffmpeg - `npm install ffmpeg-binaries`
* an opus encoder, choose one from below:
* `npm install opusscript`
* `npm install node-opus`
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/web.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The usage of the API isn't any different from using it in Node.js.
client.on('message', msg => {
const guildTag = msg.channel.type === 'text' ? `[${msg.guild.name}]` : '[DM]';
const channelTag = msg.channel.type === 'text' ? `[#${msg.channel.name}]` : '';
console.log(`${guildTag}${channelTag} ${msg.author.username}#${msg.author.discriminator}: ${msg.content}`);
console.log(`${guildTag}${channelTag} ${msg.author.tag}: ${msg.content}`);
});
client.login('some crazy token');
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord.js",
"version": "11.1.0",
"version": "11.2.0",
"description": "A powerful library for interacting with the Discord API",
"main": "./src/index",
"types": "./typings/index.d.ts",
Expand Down Expand Up @@ -34,26 +34,26 @@
"dependencies": {
"long": "^3.2.0",
"prism-media": "^0.0.1",
"snekfetch": "^3.1.0",
"tweetnacl": "^0.14.0",
"ws": "^2.0.0"
"snekfetch": "^3.3.0",
"tweetnacl": "^1.0.0",
"ws": "^3.1.0"
},
"peerDependencies": {
"bufferutil": "^3.0.0",
"bufferutil": "^3.0.2",
"erlpack": "hammerandchisel/erlpack",
"node-opus": "^0.2.5",
"node-opus": "^0.2.6",
"opusscript": "^0.0.3",
"sodium": "^2.0.1",
"libsodium-wrappers": "^0.5.1",
"uws": "^0.14.1"
"libsodium-wrappers": "^0.5.4",
"uws": "^0.14.5"
},
"devDependencies": {
"@types/node": "^7.0.0",
"@types/node": "^7.0.43",
"discord.js-docgen": "hydrabolt/discord.js-docgen",
"eslint": "^3.19.0",
"parallel-webpack": "^1.6.0",
"uglify-js": "mishoo/UglifyJS2#harmony",
"webpack": "^2.2.0"
"eslint": "^4.6.0",
"parallel-webpack": "^2.1.0",
"uglifyjs-webpack-plugin": "^1.0.0-beta.1",
"webpack": "^3.5.5"
},
"engines": {
"node": ">=6.0.0"
Expand Down
10 changes: 5 additions & 5 deletions src/client/Client.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const os = require('os');
const EventEmitter = require('events').EventEmitter;
const EventEmitter = require('events');
const Constants = require('../util/Constants');
const Permissions = require('../util/Permissions');
const Util = require('../util/Util');
Expand Down Expand Up @@ -120,6 +119,7 @@ class Client extends EventEmitter {
*/
this.presences = new Collection();

Object.defineProperty(this, 'token', { writable: true });
if (!this.token && 'CLIENT_TOKEN' in process.env) {
/**
* Authorization token for the logged in user/bot
Expand Down Expand Up @@ -249,7 +249,7 @@ class Client extends EventEmitter {
* @readonly
*/
get browser() {
return os.platform() === 'browser';
return typeof window !== 'undefined';
}

/**
Expand Down Expand Up @@ -419,9 +419,9 @@ class Client extends EventEmitter {
*/
setTimeout(fn, delay, ...args) {
const timeout = setTimeout(() => {
fn();
fn(...args);
this._timeouts.delete(timeout);
}, delay, ...args);
}, delay);
this._timeouts.add(timeout);
return timeout;
}
Expand Down

0 comments on commit 42c195c

Please sign in to comment.