mirror of
https://github.com/danbulant/discord.js
synced 2026-06-08 01:01:30 +00:00
feat(GuildChannel): add fetchInvites method (#2339)
* feat(GuildChannel): add fetchInvites method * fix: actually use the 'channels' endpoint
This commit is contained in:
parent
66c0512de2
commit
47bc0fc51e
1 changed files with 15 additions and 0 deletions
|
|
@ -430,6 +430,21 @@ class GuildChannel extends Channel {
|
||||||
.then(invite => new Invite(this.client, invite));
|
.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.
|
* Clones this channel.
|
||||||
* @param {Object} [options] The options
|
* @param {Object} [options] The options
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue