Merge branch 'master' into indev-prism

This commit is contained in:
Amish Shah
2017-01-14 21:00:13 +00:00
9 changed files with 45 additions and 25 deletions

View File

@@ -7,7 +7,6 @@ cache:
- node_modules - node_modules
install: npm install install: npm install
script: script:
- npm run lint
- bash ./deploy/deploy.sh - bash ./deploy/deploy.sh
env: env:
global: global:

View File

@@ -4,34 +4,44 @@
set -e set -e
function tests { function tests {
npm run lint
npm run test-docs npm run test-docs
VERSIONED=false npm run web-dist VERSIONED=false npm run web-dist
exit 0 exit 0
} }
function build { function build {
npm run lint
npm run docs npm run docs
VERSIONED=false npm run web-dist VERSIONED=false npm run web-dist
} }
# Only run tests for PRs # For revert branches, do nothing
if [[ "$TRAVIS_BRANCH" == revert-* ]]; then
echo -e "\e[36m\e[1mBuild triggered for reversion branch \"${TRAVIS_BRANCH}\" - doing nothing."
exit 0
fi
# For PRs, only run tests
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then 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." echo -e "\e[36m\e[1mBuild triggered for PR #${TRAVIS_PULL_REQUEST} to branch \"${TRAVIS_BRANCH}\" - only running tests."
tests tests
fi fi
# Figure out the source of the build # Figure out the source of the build
if [ -n "$TRAVIS_TAG" ]; then if [ -n "$TRAVIS_TAG" ]; then
echo -e "\e[36m\e[1mBuild triggered for tag \"$TRAVIS_TAG\"." echo -e "\e[36m\e[1mBuild triggered for tag \"${TRAVIS_TAG}\"."
SOURCE=$TRAVIS_TAG SOURCE=$TRAVIS_TAG
SOURCE_TYPE="tag"
else else
echo -e "\e[36m\e[1mBuild triggered for branch \"$TRAVIS_BRANCH\"." echo -e "\e[36m\e[1mBuild triggered for branch \"${TRAVIS_BRANCH}\"."
SOURCE=$TRAVIS_BRANCH SOURCE=$TRAVIS_BRANCH
SOURCE_TYPE="branch"
fi fi
# Only run tests for Node versions other than 6 # For Node != 6, only run tests
if [ "$TRAVIS_NODE_VERSION" != "6" ]; then if [ "$TRAVIS_NODE_VERSION" != "6" ]; then
echo -e "\e[36m\e[1mBuild triggered with Node v$TRAVIS_NODE_VERSION - only running tests." echo -e "\e[36m\e[1mBuild triggered with Node v${TRAVIS_NODE_VERSION} - only running tests."
tests tests
fi fi
@@ -64,7 +74,7 @@ cd out
git add . git add .
git config user.name "Travis CI" git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL" git config user.email "$COMMIT_AUTHOR_EMAIL"
git commit -m "Docs build: ${SHA}" || true git commit -m "Docs build for ${SOURCE_TYPE} ${SOURCE}: ${SHA}" || true
git push $SSH_REPO $TARGET_BRANCH git push $SSH_REPO $TARGET_BRANCH
# Clean up... # Clean up...
@@ -84,5 +94,5 @@ cd out
git add . git add .
git config user.name "Travis CI" git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL" git config user.email "$COMMIT_AUTHOR_EMAIL"
git commit -m "Webpack build: ${SHA}" || true git commit -m "Webpack build for ${SOURCE_TYPE} ${SOURCE}: ${SHA}" || true
git push $SSH_REPO $TARGET_BRANCH git push $SSH_REPO $TARGET_BRANCH

View File

@@ -31,7 +31,7 @@
"homepage": "https://github.com/hydrabolt/discord.js#readme", "homepage": "https://github.com/hydrabolt/discord.js#readme",
"runkitExampleFilename": "./docs/examples/ping.js", "runkitExampleFilename": "./docs/examples/ping.js",
"dependencies": { "dependencies": {
"@types/node": "^6.0.0", "@types/node": "^7.0.0",
"long": "^3.2.0", "long": "^3.2.0",
"pako": "^1.0.0", "pako": "^1.0.0",
"prism-media": "hydrabolt/prism-media#master", "prism-media": "hydrabolt/prism-media#master",
@@ -47,10 +47,10 @@
}, },
"devDependencies": { "devDependencies": {
"discord.js-docgen": "hydrabolt/discord.js-docgen", "discord.js-docgen": "hydrabolt/discord.js-docgen",
"eslint": "^3.12.0", "eslint": "^3.13.0",
"parallel-webpack": "^1.6.0", "parallel-webpack": "^1.6.0",
"uglify-js": "mishoo/UglifyJS2#harmony", "uglify-js": "mishoo/UglifyJS2#harmony",
"webpack": "2.2.0-rc.3" "webpack": "2.2.0-rc.4"
}, },
"engines": { "engines": {
"node": ">=6.0.0" "node": ">=6.0.0"

View File

@@ -354,6 +354,7 @@ class ClientDataResolver {
*/ */
/** /**
* Resolves a ColorResolvable into a color number
* @param {ColorResolvable} color Color to resolve * @param {ColorResolvable} color Color to resolve
* @returns {number} A color * @returns {number} A color
*/ */
@@ -363,11 +364,13 @@ class ClientDataResolver {
} else if (color instanceof Array) { } else if (color instanceof Array) {
color = (color[0] << 16) + (color[1] << 8) + color[2]; color = (color[0] << 16) + (color[1] << 8) + color[2];
} }
if (color < 0 || color > 0xFFFFFF) { if (color < 0 || color > 0xFFFFFF) {
throw new RangeError('Color must be within the range 0 - 16777215 (0xFFFFFF).'); throw new RangeError('Color must be within the range 0 - 16777215 (0xFFFFFF).');
} else if (color && isNaN(color)) { } else if (color && isNaN(color)) {
throw new TypeError('Unable to convert color to a number.'); throw new TypeError('Unable to convert color to a number.');
} }
return color; return color;
} }
@@ -376,7 +379,7 @@ class ClientDataResolver {
* @returns {number} A color * @returns {number} A color
*/ */
resolveColor(color) { resolveColor(color) {
return ClientDataResolver.resolveColor(color); return this.constructor.resolveColor(color);
} }
} }

View File

@@ -12,6 +12,8 @@ class GuildDeleteAction extends Action {
let guild = client.guilds.get(data.id); let guild = client.guilds.get(data.id);
if (guild) { if (guild) {
for (const channel of guild.channels.values()) channel.stopTyping(true);
if (guild.available && data.unavailable) { if (guild.available && data.unavailable) {
// guild is unavailable // guild is unavailable
guild.available = false; guild.available = false;

View File

@@ -6,20 +6,22 @@ class GuildSync extends Action {
const guild = client.guilds.get(data.id); const guild = client.guilds.get(data.id);
if (guild) { if (guild) {
data.presences = data.presences || []; if (data.presences) {
for (const presence of data.presences) { for (const presence of data.presences) guild._setPresence(presence.user.id, presence);
guild._setPresence(presence.user.id, presence);
} }
data.members = data.members || []; if (data.members) {
for (const syncMember of data.members) { for (const syncMember of data.members) {
const member = guild.members.get(syncMember.user.id); const member = guild.members.get(syncMember.user.id);
if (member) { if (member) {
guild._updateMember(member, syncMember); guild._updateMember(member, syncMember);
} else { } else {
guild._addMember(syncMember, false); guild._addMember(syncMember, false);
}
} }
} }
if ('large' in data) guild.large = data.large;
} }
} }
} }

View File

@@ -36,6 +36,10 @@ class PresenceUpdateHandler extends AbstractHandler {
client.emit(Constants.Events.GUILD_MEMBER_AVAILABLE, member); client.emit(Constants.Events.GUILD_MEMBER_AVAILABLE, member);
} }
if (member) { if (member) {
if (client.listenerCount(Constants.Events.PRESENCE_UPDATE) === 0) {
guild._setPresence(user.id, data);
return;
}
const oldMember = cloneObject(member); const oldMember = cloneObject(member);
if (member.presence) { if (member.presence) {
oldMember.frozenPresence = cloneObject(member.presence); oldMember.frozenPresence = cloneObject(member.presence);

View File

@@ -250,7 +250,7 @@ class TextBasedChannel {
count: count || 1, count: count || 1,
interval: this.client.setInterval(() => { interval: this.client.setInterval(() => {
this.client.rest.methods.sendTyping(this.id); this.client.rest.methods.sendTyping(this.id);
}, 4000), }, 9000),
}); });
this.client.rest.methods.sendTyping(this.id); this.client.rest.methods.sendTyping(this.id);
} else { } else {

Submodule typings updated: 14c4b674cf...3dbeb51fd2