Invites

This section documents everything related to invites.

Discord Models

Invite

class disnake.Invite[source]

Represents a Discord Guild or abc.GuildChannel invite.

Depending on the way this object was created, some of the attributes can have a value of None (see table below).

x == y

Checks if two invites are equal.

x != y

Checks if two invites are not equal.

hash(x)

Returns the invite hash.

str(x)

Returns the invite URL.

The following table illustrates what methods will obtain the attributes:

If something is not in the table above, then it’s available by all methods.

code

The URL fragment used for the invite.

Type:

str

guild

The guild the invite is for. Can be None if it’s from a group direct message.

Type:

Optional[Union[Guild, Object, PartialInviteGuild]]

max_age

How long before the invite expires in seconds. A value of 0 indicates that it doesn’t expire.

Optional according to the table above.

Type:

Optional[int]

max_uses

How many times the invite can be used. A value of 0 indicates that it has unlimited uses.

Optional according to the table above.

Type:

Optional[int]

created_at

An aware UTC datetime object denoting the time the invite was created.

Optional according to the table above.

Type:

Optional[datetime.datetime]

temporary

Whether the invite grants temporary membership. If True, members who joined via this invite will be kicked upon disconnect.

Optional according to the table above.

Type:

Optional[bool]

uses

How many times the invite has been used.

Optional according to the table above.

Type:

Optional[int]

approximate_member_count

The approximate number of members in the guild.

Optional according to the table above.

Type:

Optional[int]

approximate_presence_count

The approximate number of members currently active in the guild. This includes idle, dnd, online, and invisible members. Offline members are excluded.

Optional according to the table above.

Type:

Optional[int]

expires_at

The expiration date of the invite. If the value is None when received through Client.fetch_invite() with with_expiration enabled, the invite will never expire.

New in version 2.0.

Type:

Optional[datetime.datetime]

inviter

The user who created the invite, if any.

This is None in vanity invites, for example.

Type:

Optional[User]

channel

The channel the invite is for.

Type:

Optional[Union[abc.GuildChannel, Object, PartialInviteChannel]]

target_type

The type of target for the voice channel invite.

New in version 2.0.

Type:

InviteTarget

target_user

The user whose stream to display for this invite, if any.

New in version 2.0.

Type:

Optional[User]

target_application

The embedded application the invite targets, if any.

New in version 2.0.

Type:

Optional[PartialAppInfo]

guild_scheduled_event

The guild scheduled event included in the invite, if any.

New in version 2.3.

Type:

Optional[GuildScheduledEvent]

guild_welcome_screen

The partial guild’s welcome screen, if any.

New in version 2.5.

Type:

Optional[WelcomeScreen]

property id[source]

Returns the proper code portion of the invite.

Type:

str

property url[source]

A property that retrieves the invite URL.

Type:

str

await delete(*, reason=None)[source]

This function is a coroutine.

Revokes the instant invite.

You must have manage_channels permission to do this.

Parameters:

reason (Optional[str]) – The reason for deleting this invite. Shows up on the audit log.

Raises:
  • Forbidden – You do not have permissions to revoke invites.

  • NotFound – The invite is invalid or expired.

  • HTTPException – Revoking the invite failed.

PartialInviteGuild

class disnake.PartialInviteGuild[source]

Represents a “partial” invite guild.

This model will be given when the user is not part of the guild the Invite resolves to.

x == y

Checks if two partial guilds are the same.

x != y

Checks if two partial guilds are not the same.

hash(x)

Return the partial guild’s hash.

str(x)

Returns the partial guild’s name.

name

The partial guild’s name.

Type:

str

id

The partial guild’s ID.

Type:

int

description

The partial guild’s description.

Type:

Optional[str]

features

A list of features the partial guild has. See Guild.features for more information.

Type:

List[str]

nsfw_level

The partial guild’s nsfw level.

New in version 2.4.

Type:

NSFWLevel

vanity_url_code

The partial guild’s vanity url code, if any.

New in version 2.4.

Type:

Optional[str]

verification_level

The partial guild’s verification level.

Type:

VerificationLevel

premium_subscription_count

The number of “boosts” this guild currently has.

New in version 2.5.

Type:

int

property created_at[source]

Returns the guild’s creation time in UTC.

Type:

datetime.datetime

property icon[source]

Returns the guild’s icon asset, if available.

Type:

Optional[Asset]

property banner[source]

Returns the guild’s banner asset, if available.

Type:

Optional[Asset]

property splash[source]

Returns the guild’s invite splash asset, if available.

Type:

Optional[Asset]

PartialInviteChannel

class disnake.PartialInviteChannel[source]

Represents a “partial” invite channel.

This model will be given when the user is not part of the guild the Invite resolves to.

x == y

Checks if two partial channels are the same.

x != y

Checks if two partial channels are not the same.

hash(x)

Return the partial channel’s hash.

str(x)

Returns the partial channel’s name.

Changed in version 2.5: if the channel is of type ChannelType.group, returns the name that’s rendered by the official client.

name

The partial channel’s name.

Type:

Optional[str]

id

The partial channel’s ID.

Type:

int

type

The partial channel’s type.

Type:

ChannelType

property mention[source]

The string that allows you to mention the channel.

Type:

str

property created_at[source]

Returns the channel’s creation time in UTC.

Type:

datetime.datetime

property icon[source]

Returns the channel’s icon asset if available.

New in version 2.6.

Type:

Optional[Asset]

Enumerations

InviteTarget

class disnake.InviteTarget[source]

Represents the invite type for voice channel invites.

New in version 2.0.

unknown

The invite doesn’t target anyone or anything.

stream

A stream invite that targets a user.

embedded_application

A stream invite that targets an embedded application.

Events