mirror of
https://github.com/danbulant/discord.js
synced 2026-05-30 04:41:11 +00:00
feat(GuildChannel): add fetchInvites method
Backported from commit: 47bc0fc51e
PR: #2339
This commit is contained in:
parent
dd7eedbd48
commit
99041671f0
1 changed files with 19 additions and 0 deletions
|
|
@ -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<Collection<string, Invite>>}
|
||||
*/
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue