From 8d6ece0b3526891a217672a0d8b8d01c3b5a470a Mon Sep 17 00:00:00 2001 From: hydrabolt Date: Tue, 1 Sep 2015 22:30:34 +0100 Subject: [PATCH] Whoops, compiled the changes this time :P --- lib/Client.js | 4 +++- lib/PMChannel.js | 5 +++++ lib/channel.js | 5 +++++ lib/message.js | 7 +++++++ package.json | 2 +- test/bot.1.js | 7 +++++++ 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index e12f5a0ee..77a34e10c 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -139,7 +139,9 @@ var Client = (function () { if (err) { self.state = 4; //set state to disconnected self.trigger("disconnected"); - self.websocket.close(); + if (self.websocket) { + self.websocket.close(); + } callback(err); reject(err); } else { diff --git a/lib/PMChannel.js b/lib/PMChannel.js index ae44d3d60..7c30a7c34 100644 --- a/lib/PMChannel.js +++ b/lib/PMChannel.js @@ -53,6 +53,11 @@ var PMChannel = (function () { return null; } + }, { + key: "isPrivate", + get: function get() { + return true; + } }]); return PMChannel; diff --git a/lib/channel.js b/lib/channel.js index f94925f0c..dfb4f72d8 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -71,6 +71,11 @@ var Channel = (function () { get: function get() { return this.server.client; } + }, { + key: "isPrivate", + get: function get() { + return false; + } }]); return Channel; diff --git a/lib/message.js b/lib/message.js index 24c54fbb3..3dd4ddcae 100644 --- a/lib/message.js +++ b/lib/message.js @@ -4,6 +4,8 @@ var _createClass = (function () { function defineProperties(target, props) { for function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +var PMChannel = require("./PMChannel.js"); + var Message = (function () { function Message(data, channel, mentions, author) { _classCallCheck(this, Message); @@ -64,6 +66,11 @@ var Message = (function () { get: function get() { return this.author; } + }, { + key: "isPrivate", + get: function get() { + return this.channel.isPrivate; + } }]); return Message; diff --git a/package.json b/package.json index 0bbf81be0..120e83fcc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord.js", - "version": "3.2.0", + "version": "3.2.1", "description": "A way to interface with the Discord API", "main": "./lib/index.js", "scripts": { diff --git a/test/bot.1.js b/test/bot.1.js index 253e50c50..9293b401d 100644 --- a/test/bot.1.js +++ b/test/bot.1.js @@ -27,6 +27,13 @@ mybot.on("message", function (message) { } }); +mybot.on("ready", function(){ + console.log("im ready"); + setInterval(function(){ + console.log(mybot.websocket.state, "state"); + }, 2000); +}) + function dump(msg) { console.log(msg); }