add lots of group dm features (#1208)

* group dm stuff

* minor doc changes
This commit is contained in:
Gus Caplan
2017-02-22 14:33:20 -06:00
committed by Amish Shah
parent 5c2086b351
commit 4c9d8d6cd7
4 changed files with 76 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ const Webhook = require('../../structures/Webhook');
const UserProfile = require('../../structures/UserProfile');
const OAuth2Application = require('../../structures/OAuth2Application');
const Channel = require('../../structures/Channel');
const GroupDMChannel = require('../../structures/GroupDMChannel');
const Guild = require('../../structures/Guild');
const VoiceRegion = require('../../structures/VoiceRegion');
@@ -246,6 +247,23 @@ class RESTMethods {
}).then(data => this.client.actions.ChannelCreate.handle(data).channel);
}
createGroupDM(options) {
const data = this.client.user.bot ?
{ access_tokens: options.accessTokens, nicks: options.nicks } :
{ recipients: options.recipients };
return this.rest.makeRequest('post', Constants.Endpoints.meChannels, true, data)
.then(res => new GroupDMChannel(this.client, res));
}
addUserToGroupDM(channel, options) {
const data = this.client.user.bot ?
{ nick: options.nick, access_token: options.accessToken } :
{ recipient: options.id };
return this.rest.makeRequest('put', Constants.Endpoints.dmChannelRecipient(channel.id, options.id), true, data)
.then(() => channel);
}
getExistingDM(recipient) {
return this.client.channels.find(channel =>
channel.recipient && channel.recipient.id === recipient.id