Add a backwards-compatible getter for the first voice connection, thanks @qeled

This commit is contained in:
meew0
2016-04-06 15:00:14 +02:00
parent 877eaab3c1
commit bf78c441dd
4 changed files with 33 additions and 1 deletions

View File

@@ -1199,6 +1199,16 @@ var Client = (function (_EventEmitter) {
return this.internal.voiceConnections; return this.internal.voiceConnections;
} }
/**
* The first voice connection the bot has connected to. Available for backwards compatibility.
* @type {VoiceConnection} first voice connection
*/
}, {
key: "voiceConnection",
get: function get() {
return this.internal.voiceConnection;
}
/** /**
* Unix timestamp of when the Client first emitted the `ready `event. Only available after `ready` event has been emitted. * Unix timestamp of when the Client first emitted the `ready `event. Only available after `ready` event has been emitted.
* @type {Number} timestamp of ready time * @type {Number} timestamp of ready time

View File

@@ -385,6 +385,9 @@ var InternalClient = (function () {
}); });
}; };
// Backwards-compatible utility getter method for the first voice connection
// Thanks to #q (@qeled) for suggesting this
// def forceFetchUsers // def forceFetchUsers
InternalClient.prototype.forceFetchUsers = function forceFetchUsers() { InternalClient.prototype.forceFetchUsers = function forceFetchUsers() {
@@ -1670,7 +1673,7 @@ var InternalClient = (function () {
self.servers.add(server); self.servers.add(server);
client.emit("serverCreated", server); client.emit("serverCreated", server);
if (server.large && server.members.length < server.memberCount) { if (server.large && server.members.length < server.memberCount) {
self.sendWS({op: 8, d: {guild_id: server.id, query: "", limit: 0}}); self.sendWS({ op: 8, d: { guild_id: server.id, query: "", limit: 0 } });
} }
} else { } else {
client.emit("warn", "server was unavailable, could not create"); client.emit("warn", "server was unavailable, could not create");
@@ -2210,6 +2213,11 @@ var InternalClient = (function () {
get: function get() { get: function get() {
return this.userAgentInfo; return this.userAgentInfo;
} }
}, {
key: "voiceConnection",
get: function get() {
return this.voiceConnections[0];
}
}]); }]);
return InternalClient; return InternalClient;

View File

@@ -165,6 +165,14 @@ export default class Client extends EventEmitter {
return this.internal.voiceConnections; return this.internal.voiceConnections;
} }
/**
* The first voice connection the bot has connected to. Available for backwards compatibility.
* @type {VoiceConnection} first voice connection
*/
get voiceConnection() {
return this.internal.voiceConnection;
}
/** /**
* Unix timestamp of when the Client first emitted the `ready `event. Only available after `ready` event has been emitted. * Unix timestamp of when the Client first emitted the `ready `event. Only available after `ready` event has been emitted.
* @type {Number} timestamp of ready time * @type {Number} timestamp of ready time

View File

@@ -305,6 +305,12 @@ export default class InternalClient {
}); });
} }
// Backwards-compatible utility getter method for the first voice connection
// Thanks to #q (@qeled) for suggesting this
get voiceConnection() {
return this.voiceConnections[0];
}
// def forceFetchUsers // def forceFetchUsers
forceFetchUsers() { forceFetchUsers() {
this.sendWS({ this.sendWS({