diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index b18e972e7..3842f2b96 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -4,6 +4,7 @@ const PermissionOverwrites = require('./PermissionOverwrites'); const Permissions = require('../util/Permissions'); const Collection = require('../util/Collection'); const Constants = require('../util/Constants'); +const Invite = require('./Invite'); /** * Represents a guild channel (i.e. text channels and voice channels). @@ -332,6 +333,24 @@ class GuildChannel extends Channel { .then(channel => withTopic ? channel.setTopic(this.topic) : channel); } + /** + * Fetches a collection of invites to this guild channel. + * Resolves with a collection mapping invites by their codes. + * @returns {Promise>} + */ + fetchInvites() { + return this.client.rest.makeRequest('get', Constants.Endpoints.Channel(this.id).invites, true) + .then(data => { + const invites = new Collection(); + for (let invite of data) { + invite = new Invite(this.client, invite); + invites.set(invite.code, invite); + } + + return invites; + }); + } + /** * Deletes this channel. * @param {string} [reason] Reason for deleting this channel