Added guild.fetchInvites()

This commit is contained in:
Amish Shah
2016-08-28 20:59:56 +01:00
parent 1dba048d2e
commit b44a3770d9
3 changed files with 24 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@@ -518,6 +518,21 @@ class RESTMethods {
.catch(reject);
});
}
getGuildInvites(guild) {
return new Promise((resolve, reject) => {
this.rest.makeRequest('get', Constants.Endpoints.guildInvites(guild.id), true)
.then(inviteItems => {
const invites = new Collection();
for (const inviteItem of inviteItems) {
const invite = new Invite(this.rest.client, inviteItem);
invites.set(invite.code, invite);
}
resolve(invites);
})
.catch(reject);
});
}
}
module.exports = RESTMethods;

View File

@@ -552,6 +552,14 @@ class Guild {
return this.client.rest.methods.getGuildBans(this);
}
/**
* Fetch a Collection of invites to this Guild. Resolves with a Collection mapping invites by their codes.
* @returns {Promise<Collection<String, Invite>, Error>}
*/
fetchInvites() {
return this.client.rest.methods.getGuildInvites(this);
}
/**
* Gets the URL to this guild's icon (if it has one, otherwise it returns null)
* @type {?String}