diff --git a/lib/Client.js b/lib/Client.js index 29b5bb38f..c6cbb5903 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -1148,6 +1148,12 @@ var Client = (function () { var self = this; var server = this.getServer("id", data.id); + if (data.unavailable) { + self.trigger("unavailable", data); + self.debug("Server ID" + +" has been marked unavailable by Discord. It was not cached."); + return; + } + if (!server) { server = new Server(data, this); this.serverCache.push(server); diff --git a/src/Client.js b/src/Client.js index f0a0aba1f..58ad78c49 100644 --- a/src/Client.js +++ b/src/Client.js @@ -1048,6 +1048,12 @@ class Client { var self = this; var server = this.getServer("id", data.id); + if(data.unavailable){ + self.trigger("unavailable", data); + self.debug("Server ID" + + " has been marked unavailable by Discord. It was not cached."); + return; + } + if (!server) { server = new Server(data, this); this.serverCache.push(server); diff --git a/test/bot.1.js b/test/bot.1.js index 464caec86..a79a36505 100644 --- a/test/bot.1.js +++ b/test/bot.1.js @@ -30,6 +30,14 @@ mybot.on("message", function (message) { mybot.on("ready", function () { console.log("im ready"); +}); + +mybot.on("debug", function(info){ + console.log(info); +}) + +mybot.on("unavailable", function(info){ + console.log("warning!", info); }) function dump(msg) {