From 159602b3596afbba56311852e0833265c8454083 Mon Sep 17 00:00:00 2001 From: abalabahaha Date: Thu, 25 Feb 2016 18:27:33 -0800 Subject: [PATCH] createInvite forgot to Promise properly --- lib/Client/InternalClient.js | 32 ++++++++++++++------------------ src/Client/InternalClient.js | 33 +++++++++++++++------------------ 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/lib/Client/InternalClient.js b/lib/Client/InternalClient.js index 0b2fc19e1..6a24c611a 100644 --- a/lib/Client/InternalClient.js +++ b/lib/Client/InternalClient.js @@ -976,25 +976,21 @@ var InternalClient = (function () { InternalClient.prototype.createInvite = function createInvite(chanServ, options) { var _this26 = this; - chanServ = this.resolver.resolveChannel(chanServ); + return this.resolver.resolveChannel(chanServ).then(function (channel) { + if (!options) { + options = { + validate: null + }; + } else { + options.max_age = options.maxAge || 0; + options.max_uses = options.maxUses || 0; + options.temporary = options.temporary || false; + options.xkcdpass = options.xkcd || false; + } - if (!chanServ) { - throw new Error("couldn't resolve where"); - } - - if (!options) { - options = { - validate: null - }; - } else { - options.max_age = options.maxAge || 0; - options.max_uses = options.maxUses || 0; - options.temporary = options.temporary || false; - options.xkcdpass = options.xkcd || false; - } - - return this.apiRequest("post", _Constants.Endpoints.CHANNEL_INVITES(chanServ.id), true, options).then(function (res) { - return new _StructuresInvite2["default"](res, _this26.channels.get("id", res.channel.id), _this26.client); + return _this26.apiRequest("post", _Constants.Endpoints.CHANNEL_INVITES(channel.id), true, options).then(function (res) { + return new _StructuresInvite2["default"](res, _this26.channels.get("id", res.channel.id), _this26.client); + }); }); }; diff --git a/src/Client/InternalClient.js b/src/Client/InternalClient.js index 314e0d05e..dd6f6dde7 100644 --- a/src/Client/InternalClient.js +++ b/src/Client/InternalClient.js @@ -786,25 +786,22 @@ export default class InternalClient { // def createInvite createInvite(chanServ, options) { - chanServ = this.resolver.resolveChannel(chanServ); + return this.resolver.resolveChannel(chanServ) + .then(channel => { + if (!options) { + options = { + validate: null + }; + } else { + options.max_age = options.maxAge || 0; + options.max_uses = options.maxUses || 0; + options.temporary = options.temporary || false; + options.xkcdpass = options.xkcd || false; + } - if (!chanServ) { - throw new Error("couldn't resolve where"); - } - - if (!options) { - options = { - validate: null - }; - } else { - options.max_age = options.maxAge || 0; - options.max_uses = options.maxUses || 0; - options.temporary = options.temporary || false; - options.xkcdpass = options.xkcd || false; - } - - return this.apiRequest("post", Endpoints.CHANNEL_INVITES(chanServ.id), true, options) - .then(res => new Invite(res, this.channels.get("id", res.channel.id), this.client)); + return this.apiRequest("post", Endpoints.CHANNEL_INVITES(channel.id), true, options) + .then(res => new Invite(res, this.channels.get("id", res.channel.id), this.client)); + }); } //def deleteInvite