feat(GuildChannel): add fetchInvites method (#2339)

* feat(GuildChannel): add fetchInvites method

* fix: actually use the 'channels' endpoint
This commit is contained in:
SpaceEEC
2018-02-13 17:29:42 +01:00
committed by GitHub
parent 66c0512de2
commit 47bc0fc51e

View File

@@ -430,6 +430,21 @@ class GuildChannel extends Channel {
.then(invite => new Invite(this.client, invite));
}
/**
* Fetches a collection of invites to this guild channel.
* Resolves with a collection mapping invites by their codes.
* @returns {Promise<Collection<string, Invite>>}
*/
async fetchInvites() {
const inviteItems = await this.client.api.channels(this.id).invites.get();
const invites = new Collection();
for (const inviteItem of inviteItems) {
const invite = new Invite(this.client, inviteItem);
invites.set(invite.code, invite);
}
return invites;
}
/**
* Clones this channel.
* @param {Object} [options] The options