Use resolveChannel instead of resolveVoiceChannel for joinVoiceChannel and get rid of resolveVoiceChannel

This commit is contained in:
meew0
2016-02-01 21:30:57 +01:00
parent 6f7bd987b8
commit e66311bdf5
4 changed files with 70 additions and 86 deletions

View File

@@ -269,12 +269,11 @@ var InternalClient = (function () {
InternalClient.prototype.joinVoiceChannel = function joinVoiceChannel(chann) { InternalClient.prototype.joinVoiceChannel = function joinVoiceChannel(chann) {
var _this3 = this; var _this3 = this;
var channel = this.resolver.resolveVoiceChannel(chann); return this.resolver.resolveChannel(chann).then(function (channel) {
if (!channel) { if (!channel) {
return Promise.reject(new Error("voice channel does not exist")); return Promise.reject(new Error("voice channel does not exist"));
} }
return this.leaveVoiceChannel().then(function () { return _this3.leaveVoiceChannel().then(function () {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
var session, var session,
token, token,
@@ -312,6 +311,7 @@ var InternalClient = (function () {
}); });
}); });
}); });
});
}; };
// def createServer // def createServer

View File

@@ -236,14 +236,6 @@ var Resolver = (function () {
return null; return null;
}; };
Resolver.prototype.resolveVoiceChannel = function resolveVoiceChannel(resource) {
// resolveChannel will also work but this is more apt
if (resource instanceof _StructuresVoiceChannel2["default"]) {
return resource;
}
return null;
};
Resolver.prototype.resolveChannel = function resolveChannel(resource) { Resolver.prototype.resolveChannel = function resolveChannel(resource) {
/* /*
accepts a Message, Channel, Server, String ID, User accepts a Message, Channel, Server, String ID, User

View File

@@ -200,8 +200,7 @@ export default class InternalClient {
//def joinVoiceChannel //def joinVoiceChannel
joinVoiceChannel(chann) { joinVoiceChannel(chann) {
var channel = this.resolver.resolveVoiceChannel(chann); return this.resolver.resolveChannel(chann).then(channel => {
if (!channel) { if (!channel) {
return Promise.reject(new Error("voice channel does not exist")); return Promise.reject(new Error("voice channel does not exist"));
} }
@@ -242,6 +241,7 @@ export default class InternalClient {
}); });
}); });
}); });
});
} }
// def createServer // def createServer

View File

@@ -166,14 +166,6 @@ export default class Resolver {
return null; return null;
} }
resolveVoiceChannel(resource) {
// resolveChannel will also work but this is more apt
if (resource instanceof VoiceChannel) {
return resource;
}
return null;
}
resolveChannel(resource) { resolveChannel(resource) {
/* /*
accepts a Message, Channel, Server, String ID, User accepts a Message, Channel, Server, String ID, User