From aacbf2cca89289e59c6351ab8d46b6b0b091d431 Mon Sep 17 00:00:00 2001 From: Aigachu Date: Thu, 20 Aug 2015 19:42:40 -0400 Subject: [PATCH 1/2] Added function to get channel by name. --- index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/index.js b/index.js index dcd31eea3..35c00b2f6 100644 --- a/index.js +++ b/index.js @@ -149,6 +149,16 @@ exports.Client.prototype.getChannel = function( id ) { return this.getChannels().filter( "id", id, true ); } +/** + * Returns a Channel matching the given name, or false if not found. Will return false if the Channel is not cached or not available. + * @method getChannelByName + * @param {String/Number} name The Name of the Channel + * @return {Server} The Channel matching the Name + */ +exports.Client.prototype.getChannelByName = function( name ) { + return this.getChannels().filter( "name", name, true ); +} + /** * Triggers an .on() event. * @param {String} event The event to be triggered @@ -1006,6 +1016,10 @@ exports.Client.prototype.getChannel = function( id ) { return normalChan || this.PMList.filter( "id", id, true ); } +exports.Client.prototype.getChannelByName = function( name ) { + var normalChan = this.getChannels().filter( "name", name, true ); +} + exports.Client.prototype.getUser = function( id ) { return this.getUsers().filter( "id", id, true ); } From 0366b58ca322f86a78f027439e44270ac8849835 Mon Sep 17 00:00:00 2001 From: Aigachu Date: Thu, 20 Aug 2015 19:54:40 -0400 Subject: [PATCH 2/2] Fix get channel by name function. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 35c00b2f6..ff288fd00 100644 --- a/index.js +++ b/index.js @@ -1017,7 +1017,7 @@ exports.Client.prototype.getChannel = function( id ) { } exports.Client.prototype.getChannelByName = function( name ) { - var normalChan = this.getChannels().filter( "name", name, true ); + return this.getChannels().filter( "name", name, true ); } exports.Client.prototype.getUser = function( id ) {