mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
feat(GuildChannel): createInvite target options (#5514)
Co-authored-by: Antonio Román <kyradiscord@gmail.com> Co-authored-by: Advaith <advaithj1@gmail.com>
This commit is contained in:
@@ -483,6 +483,14 @@ class GuildChannel extends Channel {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Data that can be resolved to an Application. This can be:
|
||||
* * An Application
|
||||
* * An Activity with associated Application
|
||||
* * A Snowflake
|
||||
* @typedef {Application|Snowflake} ApplicationResolvable
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates an invite to this guild channel.
|
||||
* @param {Object} [options={}] Options for the invite
|
||||
@@ -491,6 +499,11 @@ class GuildChannel extends Channel {
|
||||
* @param {number} [options.maxAge=86400] How long the invite should last (in seconds, 0 for forever)
|
||||
* @param {number} [options.maxUses=0] Maximum number of uses
|
||||
* @param {boolean} [options.unique=false] Create a unique invite, or use an existing one with similar settings
|
||||
* @param {UserResolvable} [options.targetUser] The user whose stream to display for this invite,
|
||||
* required if `targetType` is 1, the user must be streaming in the channel
|
||||
* @param {ApplicationResolvable} [options.targetApplication] The embedded application to open for this invite,
|
||||
* required if `targetType` is 2, the application must have the `EMBEDDED` flag
|
||||
* @param {InviteTargetType} [options.targetType] The type of the target for this voice channel invite
|
||||
* @param {string} [options.reason] Reason for creating this
|
||||
* @returns {Promise<Invite>}
|
||||
* @example
|
||||
@@ -499,7 +512,16 @@ class GuildChannel extends Channel {
|
||||
* .then(invite => console.log(`Created an invite with a code of ${invite.code}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
createInvite({ temporary = false, maxAge = 86400, maxUses = 0, unique, reason } = {}) {
|
||||
createInvite({
|
||||
temporary = false,
|
||||
maxAge = 86400,
|
||||
maxUses = 0,
|
||||
unique,
|
||||
targetUser,
|
||||
targetApplication,
|
||||
targetType,
|
||||
reason,
|
||||
} = {}) {
|
||||
return this.client.api
|
||||
.channels(this.id)
|
||||
.invites.post({
|
||||
@@ -508,6 +530,9 @@ class GuildChannel extends Channel {
|
||||
max_age: maxAge,
|
||||
max_uses: maxUses,
|
||||
unique,
|
||||
target_user_id: this.client.users.resolveID(targetUser),
|
||||
target_application_id: targetApplication?.id ?? targetApplication?.applicationID ?? targetApplication,
|
||||
target_type: targetType,
|
||||
},
|
||||
reason,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user