mirror of
https://github.com/danbulant/discord.js
synced 2026-07-10 21:50:59 +00:00
Use resolveChannel instead of resolveVoiceChannel for joinVoiceChannel and get rid of resolveVoiceChannel
This commit is contained in:
parent
6f7bd987b8
commit
e66311bdf5
4 changed files with 70 additions and 86 deletions
|
|
@ -269,12 +269,11 @@ var InternalClient = (function () {
|
|||
InternalClient.prototype.joinVoiceChannel = function joinVoiceChannel(chann) {
|
||||
var _this3 = this;
|
||||
|
||||
var channel = this.resolver.resolveVoiceChannel(chann);
|
||||
|
||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||
if (!channel) {
|
||||
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) {
|
||||
var session,
|
||||
token,
|
||||
|
|
@ -312,6 +311,7 @@ var InternalClient = (function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// def createServer
|
||||
|
|
|
|||
|
|
@ -236,14 +236,6 @@ var Resolver = (function () {
|
|||
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) {
|
||||
/*
|
||||
accepts a Message, Channel, Server, String ID, User
|
||||
|
|
|
|||
|
|
@ -200,8 +200,7 @@ export default class InternalClient {
|
|||
|
||||
//def joinVoiceChannel
|
||||
joinVoiceChannel(chann) {
|
||||
var channel = this.resolver.resolveVoiceChannel(chann);
|
||||
|
||||
return this.resolver.resolveChannel(chann).then(channel => {
|
||||
if (!channel) {
|
||||
return Promise.reject(new Error("voice channel does not exist"));
|
||||
}
|
||||
|
|
@ -242,6 +241,7 @@ export default class InternalClient {
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// def createServer
|
||||
|
|
|
|||
|
|
@ -166,14 +166,6 @@ export default class Resolver {
|
|||
return null;
|
||||
}
|
||||
|
||||
resolveVoiceChannel(resource) {
|
||||
// resolveChannel will also work but this is more apt
|
||||
if (resource instanceof VoiceChannel) {
|
||||
return resource;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
resolveChannel(resource) {
|
||||
/*
|
||||
accepts a Message, Channel, Server, String ID, User
|
||||
|
|
|
|||
Loading…
Reference in a new issue