From 0c38d47ef6ac1e0009edfb5016b17c5e465ea9da Mon Sep 17 00:00:00 2001 From: Brussell Date: Sun, 8 May 2016 11:47:22 -0500 Subject: [PATCH] Added support for new game objects (#332) bot.setStreaming(name, url, type, callback); added logic for Internal setStatus updated to check if string or object --- docs/docs_client.rst | 13 ++++++++++++- lib/Client/Client.js | 6 ++++++ lib/Client/InternalClient.js | 4 +--- src/Client/Client.js | 4 ++++ src/Client/InternalClient.js | 4 +--- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/docs/docs_client.rst b/docs/docs_client.rst index 7d82fcb00..ec9184d99 100644 --- a/docs/docs_client.rst +++ b/docs/docs_client.rst @@ -440,7 +440,7 @@ setStatus(status, `game`, `callback`) Sets the Discord Status of the Client - **status** - `String`, either ``online, here, active, available`` or ``idle, away`` -- **game** - `String`, Name of game being played, or `null` to clear +- **game** - `String`, Name of game being played, or `Object` with the properties `name` `url` `type`, or `null` to clear - **callback** - `function` taking the following: - **error** - error if any occurred @@ -467,6 +467,17 @@ Sets the Discord Status of the Client - **callback** - `function` taking the following: - **error** - error if any occurred +setStreaming(name, url, type `callback`) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Sets the Discord Status of the Client + +- **name** - `String`, Name of game being played +- **url** - `String`, URL that it will link to +- **type** - `Number`, `1` indicates streaming +- **callback** - `function` taking the following: + - **error** - error if any occurred + setChannelTopic(channel, topic, `callback`) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/Client/Client.js b/lib/Client/Client.js index cb9688405..6e5b74371 100644 --- a/lib/Client/Client.js +++ b/lib/Client/Client.js @@ -1112,6 +1112,12 @@ var Client = (function (_EventEmitter) { return this.setStatus(null, game, callback); }; + Client.prototype.setStreaming = function setStreaming(name, url, type) { + var callback = arguments.length <= 3 || arguments[3] === undefined ? function () /*err, {}*/{} : arguments[3]; + + return this.setStatus(null, { name: name, url: url, type: type }, callback); + }; + //def forceFetchUsers Client.prototype.forceFetchUsers = function forceFetchUsers(callback) { diff --git a/lib/Client/InternalClient.js b/lib/Client/InternalClient.js index 11e50f945..1d6108717 100644 --- a/lib/Client/InternalClient.js +++ b/lib/Client/InternalClient.js @@ -1385,9 +1385,7 @@ var InternalClient = (function () { this.idleStatus = this.idleStatus || null; //undefined } - this.game = game === null ? null : !game ? this.game || null : { - name: game - }; + this.game = game === null ? null : !game ? this.game || null : typeof game === "string" ? { name: game } : game; var packet = { op: 3, diff --git a/src/Client/Client.js b/src/Client/Client.js index a0cf66b73..cf02c4f8d 100644 --- a/src/Client/Client.js +++ b/src/Client/Client.js @@ -1094,6 +1094,10 @@ export default class Client extends EventEmitter { return this.setStatus(null, game, callback); } + setStreaming(name, url, type, callback = (/*err, {}*/) => { }) { + return this.setStatus(null, {name: name, url: url, type: type}, callback); + } + //def forceFetchUsers forceFetchUsers(callback){ return this.internal.forceFetchUsers().then(callback); diff --git a/src/Client/InternalClient.js b/src/Client/InternalClient.js index 970fc2745..bb895cfe9 100644 --- a/src/Client/InternalClient.js +++ b/src/Client/InternalClient.js @@ -1166,9 +1166,7 @@ export default class InternalClient { this.idleStatus = this.idleStatus || null; //undefined } - this.game = game === null ? null : !game ? this.game || null : { - name: game - }; + this.game = game === null ? null : !game ? this.game || null : typeof game === "string" ? {name: game} : game; var packet = { op: 3,