Invite

class Invite

A Discord invite and any metadata returned for it by the current endpoint. Count, expiration, and inviter-related fields may be absent depending on how the invite was obtained and which options were requested.

Properties

Property

Type

Description

approximateMemberCount

number | null

Approximate member count at the time the invite was fetched, or null.

approximatePresenceCount

number | null

Approximate online member count, or null.

channel

InviteChannel | null

Partial target channel information included with the invite.

channelId

string | null

Channel ID the invite targets, or null.

code

string

The invite code used in discord.gg/ links.

createdAt

Date | null

When this invite was created, or null.

expiresAt

Date | null

When this invite expires, or null.

guild

InviteGuild | null

Partial target guild information included with the invite.

guildId

string | null

Guild ID the invite targets, or null.

inviter

User | null

User who created the invite when Discord includes it.

maxAge

number | null

Duration in seconds before the invite expires, or null.

maxUses

number | null

Maximum number of uses. 0 means unlimited; null means Discord omitted the field.

targetApplication

Record<string, unknown> | null

Target application metadata when Discord includes it.

targetType

number | null

Type of invite target, or null for an ordinary channel invite.

targetUser

User | null

Target user for stream or embedded-application invites.

temporary

boolean | null

Indicates whether this invite grants temporary membership, or null.

uses

number | null

Number of times this invite has been used, or null.

Methods

async Invite.delete(reason: string) → Promise<void>

Delete this invite.

Parameters:
  • reason: Audit-log reason for deleting the invite.

async Invite.fetch() → Promise<Invite>

Refetch the latest invite data from Discord.

Returns:

The updated invite object.

async Invite.fetchChannel() → Promise<GuildTextChannel | GuildVoiceChannel | null>

Fetch the full channel this invite points to. Only works for invites to the deployment’s own guild; for other servers it returns null, and invite.channel has the public details Discord includes.

async Invite.fetchGuild() → Promise<Guild | null>

Fetch the full guild this invite points to. Only works for invites to the deployment’s own guild; for other servers it returns null, and invite.guild has the public details Discord includes.