Added guildChannel.createInvite();

This commit is contained in:
Amish Shah
2016-08-28 20:32:32 +01:00
parent 9f1475f358
commit ba3d104619
6 changed files with 219 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ const getStructure = name => require(`../../structures/${name}`);
const User = getStructure('User');
const GuildMember = getStructure('GuildMember');
const Role = getStructure('Role');
const Invite = getStructure('Invite');
class RESTMethods {
constructor(restManager) {
@@ -496,6 +497,19 @@ class RESTMethods {
getChannelPinnedMessages(channel) {
return this.rest.makeRequest('get', `${Constants.Endpoints.channel(channel.id)}/pins`, true);
}
createChannelInvite(channel, options) {
return new Promise((resolve, reject) => {
const payload = {};
payload.temporary = options.temporary;
payload.max_age = options.maxAge;
payload.max_uses = options.maxUses;
this.rest.makeRequest('post', `${Constants.Endpoints.channelInvites(channel.id)}`, true, payload)
.then(invite => resolve(new Invite(this.rest.client, invite)))
.catch(reject);
});
}
}
module.exports = RESTMethods;