mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(GuildChannel): add fetchInvites method
Backported from commit: 47bc0fc51e
PR: #2339
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user