add voice region getting (#1108)

* add voice region getting

* clean up this mess

* add docstrings

* Update VoiceRegion.js

* Update RESTMethods.js
This commit is contained in:
Gus Caplan
2017-01-18 18:14:44 -06:00
committed by Schuyler Cebulskie
parent ff92905848
commit 3f4cbd07dd
5 changed files with 79 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ const UserProfile = require('../../structures/UserProfile');
const ClientOAuth2Application = require('../../structures/ClientOAuth2Application');
const Channel = require('../../structures/Channel');
const Guild = require('../../structures/Guild');
const VoiceRegion = require('../../structures/VoiceRegion');
class RESTMethods {
constructor(restManager) {
@@ -47,6 +48,15 @@ class RESTMethods {
return this.rest.makeRequest('get', Constants.Endpoints.botGateway, true);
}
fetchVoiceRegions(guildID) {
const endpoint = Constants.Endpoints[guildID ? 'guildVoiceRegions' : 'voiceRegions'];
return this.rest.makeRequest('get', guildID ? endpoint(guildID) : endpoint, true).then(res => {
const regions = new Collection();
for (const region of res) regions.set(region.id, new VoiceRegion(region));
return regions;
});
}
sendMessage(channel, content, { tts, nonce, embed, disableEveryone, split, code, reply } = {}, file = null) {
return new Promise((resolve, reject) => { // eslint-disable-line complexity
if (typeof content !== 'undefined') content = this.client.resolver.resolveString(content);