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

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

flags

The flags of this invite.

New in version 2.13.

Type:

GuildInviteFlags

roles

A list of roles that will be assigned to the users when joining, if any.

New in version 2.13.

Type:

list[Role]

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.

await fetch_target_users()[source]

This function is a coroutine.

Fetch the csv file with the target users for this invite. You must have the manage_guild or view_audit_log permissions or to be the inviter to do this.

New in version 2.13.

Raises:
  • Forbidden – You do not have permissions to see the target users.

  • HTTPException – Getting the target users failed.

Returns:

The target users for this invite.

Return type:

str

await update_target_users(*, file)[source]

This function is a coroutine.

Update the target users for this invite. You must have the manage_guild permission or to be the inviter to do this.

New in version 2.13.

file: File

The csv file containing the new user ids to target. This file must only have valid user ids separated by ``

``.

A valid file content would look like this:

710570210159099984
1081815963990761542
... other user ids
Forbidden

You do not have permissions to update the target users.

HTTPException

Updating the target users failed.

await fetch_target_users_job_status()[source]

This function is a coroutine.

Get the target users job status. You must have the manage_guild or view_audit_log permissions or be the inviter to do this.

New in version 2.13.

Raises:
  • Forbidden – You do not have permissions to get the target users job status.

  • HTTPException – Getting the target users job status failed.

Returns:

A dict containing the job status.

Key

Type

Description

status

int

The status of the job

total_users

int

The total number of targeted users

processed_users

int

The total number of processed users so far

created_at

datetime.datetime

The date when the job started

completed_at

datetime.datetime | None

The date when the job was completed, None if it’s still running

error_message

str | None

The error message of the job, if any

Status Value

Name

Description

0

UNSPECIFIED

The default value

1

PROCESSING

The job is currently being processed

2

COMPLETED

The job has been completed successfully

3

FAILED

The job has failed, see error_message field for more details

Return type:

dict[str, str | int | datetime.datetime | None]

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

GuildInviteFlags

Attributes
class disnake.GuildInviteFlags[source]

Wraps up Discord Invite flags.

x == y

Checks if two GuildInviteFlags instances are equal.

x != y

Checks if two GuildInviteFlags instances are not equal.

x <= y

Checks if a GuildInviteFlags instance is a subset of another GuildInviteFlags instance.

x >= y

Checks if a GuildInviteFlags instance is a superset of another GuildInviteFlags instance.

x < y

Checks if a GuildInviteFlags instance is a strict subset of another GuildInviteFlags instance.

x > y

Checks if a GuildInviteFlags instance is a strict superset of another GuildInviteFlags instance.

x | y, x |= y

Returns a new GuildInviteFlags instance with all enabled flags from both x and y. (Using |= will update in place).

x & y, x &= y

Returns a new GuildInviteFlags instance with only flags enabled on both x and y. (Using &= will update in place).

x ^ y, x ^= y

Returns a new GuildInviteFlags instance with only flags enabled on one of x or y, but not both. (Using ^= will update in place).

~x

Returns a new GuildInviteFlags instance with all flags from x inverted.

hash(x)

Returns the flag’s hash.

iter(x)

Returns an iterator of (name, value) pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.

Additionally supported are a few operations on class attributes.

GuildInviteFlags.y | GuildInviteFlags.z, GuildInviteFlags(y=True) | GuildInviteFlags.z

Returns a GuildInviteFlags instance with all provided flags enabled.

~GuildInviteFlags.y

Returns a GuildInviteFlags instance with all flags except y inverted from their default value.

New in version 2.13.

value

The raw value. You should query flags via the properties rather than using this raw value.

Type:

int

is_guest_invite

Returns True if this invite is a guest invite for a voice channel.

Type:

bool

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