Small fixes

This commit is contained in:
abalabahaha
2016-02-18 20:49:03 -08:00
parent e4641fe701
commit 5c9865fc3c
3 changed files with 69 additions and 81 deletions

View File

@@ -55,7 +55,7 @@ A list of other Discord API libraries [can be found here](https://discordapi.com
**[Wiki](https://github.com/discord-js/discord.js/wiki)** **[Wiki](https://github.com/discord-js/discord.js/wiki)**
**[Website](http://discord-js.github.io/)** **[Website](http://hydrabolt.github.io/discord.js/)**
**[NPM](http://npmjs.com/package/discord.js)** **[NPM](http://npmjs.com/package/discord.js)**

View File

@@ -874,9 +874,13 @@ var InternalClient = (function () {
throw new Error("user not found"); throw new Error("user not found");
} }
return !!role.server.rolesOf(member).find(function (r) { var roledata = role.server.rolesOf(member);
if (roledata) {
return roledata.find(function (r) {
return r.id == role.id; return r.id == role.id;
}); });
}
return null;
}; };
//def removeMemberFromRole //def removeMemberFromRole
@@ -942,13 +946,7 @@ var InternalClient = (function () {
InternalClient.prototype.createInvite = function createInvite(chanServ, options) { InternalClient.prototype.createInvite = function createInvite(chanServ, options) {
var _this25 = this; var _this25 = this;
if (chanServ instanceof _StructuresChannel2["default"]) { chanServ = this.resolver.resolveChannel(chanServ);
// do something
} else if (chanServ instanceof _StructuresServer2["default"]) {
// do something
} else {
chanServ = this.resolver.resolveServer(chanServ) || this.resolver.resolveChannel(chanServ);
}
if (!chanServ) { if (!chanServ) {
throw new Error("couldn't resolve where"); throw new Error("couldn't resolve where");
@@ -965,14 +963,7 @@ var InternalClient = (function () {
options.xkcdpass = options.xkcd || false; options.xkcdpass = options.xkcd || false;
} }
var epoint; return this.apiRequest("post", _Constants.Endpoints.CHANNEL_INVITES(chanServ.id), true, options).then(function (res) {
if (chanServ instanceof _StructuresChannel2["default"]) {
epoint = _Constants.Endpoints.CHANNEL_INVITES(chanServ.id);
} else {
epoint = _Constants.Endpoints.SERVER_INVITES(chanServ.id);
}
return this.apiRequest("post", epoint, true, options).then(function (res) {
return new _StructuresInvite2["default"](res, _this25.channels.get("id", res.channel.id), _this25.client); return new _StructuresInvite2["default"](res, _this25.channels.get("id", res.channel.id), _this25.client);
}); });
}; };
@@ -1107,6 +1098,9 @@ var InternalClient = (function () {
this.sendWS(packet); this.sendWS(packet);
this.bot.user.status = this.idleStatus;
this.bot.user.game = this.game;
return Promise.resolve(); return Promise.resolve();
}; };

View File

@@ -723,7 +723,11 @@ export default class InternalClient {
throw new Error("user not found"); throw new Error("user not found");
} }
return !!role.server.rolesOf(member).find(r => r.id == role.id); var roledata = role.server.rolesOf(member);
if (roledata) {
return roledata.find(r => r.id == role.id);
}
return null;
} }
//def removeMemberFromRole //def removeMemberFromRole
@@ -771,13 +775,7 @@ export default class InternalClient {
// def createInvite // def createInvite
createInvite(chanServ, options) { createInvite(chanServ, options) {
if (chanServ instanceof Channel) { chanServ = this.resolver.resolveChannel(chanServ);
// do something
} else if (chanServ instanceof Server) {
// do something
} else {
chanServ = this.resolver.resolveServer(chanServ) || this.resolver.resolveChannel(chanServ);
}
if (!chanServ) { if (!chanServ) {
throw new Error("couldn't resolve where"); throw new Error("couldn't resolve where");
@@ -794,14 +792,7 @@ export default class InternalClient {
options.xkcdpass = options.xkcd || false; options.xkcdpass = options.xkcd || false;
} }
var epoint; return this.apiRequest("post", Endpoints.CHANNEL_INVITES(chanServ.id), true, options)
if (chanServ instanceof Channel) {
epoint = Endpoints.CHANNEL_INVITES(chanServ.id);
} else {
epoint = Endpoints.SERVER_INVITES(chanServ.id);
}
return this.apiRequest("post", epoint, true, options)
.then(res => new Invite(res, this.channels.get("id", res.channel.id), this.client)); .then(res => new Invite(res, this.channels.get("id", res.channel.id), this.client));
} }
@@ -931,6 +922,9 @@ export default class InternalClient {
this.sendWS(packet); this.sendWS(packet);
this.bot.user.status = this.idleStatus;
this.bot.user.game = this.game;
return Promise.resolve(); return Promise.resolve();
} }