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:

Attribute

Method

max_age

Guild.invites() with manage_guild permissions, abc.GuildChannel.invites()

max_uses

Guild.invites() with manage_guild permissions, abc.GuildChannel.invites()

created_at

Guild.invites() with manage_guild permissions, abc.GuildChannel.invites()

temporary

Guild.invites() with manage_guild permissions, abc.GuildChannel.invites()

uses

Guild.invites() with manage_guild permissions, abc.GuildChannel.invites()

approximate_member_count

Client.fetch_invite() with with_counts enabled

approximate_presence_count

Client.fetch_invite() with with_counts enabled

guild_scheduled_event

Client.fetch_invite() with valid guild_scheduled_event_id or valid event ID in URL or invite object

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

type

The type of the invite.

New in version 2.10.

Type:

InviteType

guild

The guild the invite is for. Can be None if it’s not a guild invite (see type).

Type:

Guild | Object | PartialInviteGuild | None

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:

int | None

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:

int | None

created_at

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

Optional according to the table above.

Type:

datetime.datetime | None

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:

bool | None

uses

How many times the invite has been used.

Optional according to the table above.

Type:

int | None

approximate_member_count

The approximate number of members in the guild.

Optional according to the table above.

Type:

int | None

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:

int | None

expires_at

The expiration date of the invite. If the value is None the invite will never expire.

New in version 2.0.

Type:

datetime.datetime | None

inviter

The user who created the invite, if any.

This is None in vanity invites, for example.

Type:

User | None

channel

The channel the invite is for.

Type:

abc.GuildChannel | Object | PartialInviteChannel | None

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:

User | None

target_application

The embedded application the invite targets, if any.

New in version 2.0.

Type:

PartialAppInfo | None

guild_scheduled_event

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

New in version 2.3.

Type:

GuildScheduledEvent | None

guild_welcome_screen

The partial guild’s welcome screen, if any.

New in version 2.5.

Type:

WelcomeScreen | None

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 (str | None) – 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:

str | None

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:

str | None

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:

Asset | None

property banner[source]

Returns the guild’s banner asset, if available.

Type:

Asset | None

property splash[source]

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

Type:

Asset | None

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:

str | None

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:

Asset | None

Enumerations

InviteType

class disnake.InviteType[source]

Represents the type of an invite.

New in version 2.10.

guild

Represents an invite to a guild.

group_dm

Represents an invite to a group channel.

friend

Represents a friend invite.

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