mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(GuildChannel): add fetchInvites method (#2339)
* feat(GuildChannel): add fetchInvites method * fix: actually use the 'channels' endpoint
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user