Invite

Represents a Discord Invite.

Attributes

approximate_online_count : int

The approximate amount of online users at the respective guild (or group channel). Defaults to 0.

approximate_user_count : int

The approximate amount of users at the respective guild (or group channel). Defaults to 0.

channel : None, Channel

The channel where the invite redirects. If it is announcements or store channel, then the invite is a lurk invite. If channel data was not sent with the invite's, then this attribute is set as None.

code : str

The invite's unique identifier.

created_at : DateTime

When the invite was created. Defaults to Discord epoch.

flags : InviteFlag

The invite's flags.

guild : None, Guild

The guild the invite is for. If not included or if the invite's channel is a group channel, then set as None.

inviter : ClientUserBase

The creator of the invite. If not included, then set as ZEROUSER.

max_age : None, int

The time in seconds after the invite will expire. Defaults to None.

If the invite was created with max age as 0, then this value will be negative instead of the expected 0.

max_uses : None, int

How much times the invite can be used. Defaults to None.

If the invite has no use limit, then this value is set as 0.

target_application : None, Application

The invite's target application.

target_type : InviteTargetType

The invite's target type.

target_user : None, ClientUserBase

The target of the invite if applicable.

temporary : bool

Whether this invite only grants temporary membership.

When the user goes offline, they get kicked, except if they got a role meanwhile.

type : InviteType

The invite's type.

uses : None, int

The amount how much times the invite was used. Defaults to None.

Properties

channel_id

Returns the invite's channel's identifier.

guild_id

Returns the invite's guild's identifier.

Returns

guild_id : int

id

Compatibility property with other Discord entities.

Returns

id : int = 0

inviter_id

Returns the invite's creator's identifier.

Returns

user_id : int

nsfw_level

Returns the invite's guild's nsfw level if applicable.

Deprecated and will be removed in 2024 February.

Returns

stage : NsfwLevel

partial

Returns whether the invite is partial.

Since it is not possible to check whether the invite is up to date, it will always return True for non-template invites.

Returns

partial : bool

stage

Returns the invite's stage.

Deprecated and will be removed in 2024 February.

Returns

stage : None, InviteStage

target_application_id

Returns the invite's target application's identifier.

Returns

target_application_id : int

target_user_id

Returns the invite's target user's identifier.

Returns

target_user_id : int

url

Returns the invite's url.

This function is a shared property of Invite-s.

Returns

url : str

Methods

__new__(...)

Creates a partial invite with the given fields.

ParameterTypeOptionalKeyword onlyDescription
flags

InviteFlag, int

The invite's flags.

max_age

None, int

The time in seconds after the invite will expire.

max_uses

None, int

How much times the invite can be used.

target_application

None, Application

The invite's target application.

target_type

InviteTargetType, int

The invite's target type.

target_user

None, ClientUserBase

The target of the invite if applicable.

temporary

bool

Whether this invite only grants temporary membership.

Raises

TypeError

  • If a parameter's type is incorrect.

ValueError

  • If a parameter's value is incorrect.

copy()

Copies the invite returning a new partial one.

Returns

new : instance<type<self>>

copy_with(...)

Copies the invite with the given fields.

ParameterTypeOptionalKeyword onlyDescription
flags

InviteFlag, int

The invite's flags.

max_age

None, int

The time in seconds after the invite will expire.

max_uses

None, int

How much times the invite can be used.

target_application

None, Application

The invite's target application.

target_type

InviteTargetType, int

The invite's target type.

target_user

None, ClientUserBase

The target of the invite if applicable.

temporary

bool

Whether this invite only grants temporary membership.

Returns

new : instance<type<self>>

Raises

TypeError

  • If a parameter's type is incorrect.

ValueError

  • If a parameter's value is incorrect.

from_data(data)

Creates an invite from the given invite data.

ParameterTypeDescription
data

dict of (str, object) items

Invite data.

Returns

self : instance<cls>

precreate(code, ...)

Precreates an invite object with the given parameters.

ParameterTypeOptionalKeyword onlyDescription
code

str

The invite's code.

**keyword_parameters

keyword parameters

Additional predefined attributes for the invite.

approximate_online_count

int

The amount of online users at the respective guild (or group channel).

approximate_user_count

int

The amount of users at the respective guild (or group channel).

channel

None, Channel

The channel where the invite redirects.

created_at

None, DateTime

When the invite was created.

flags

InviteFlag, int

The invite's flags.

guild

None, Guild

The guild the invite is for.

invite_type

int, InviteType

The invite's type.

inviter

ClientUserBase

The creator of the invite.

max_age

None, int

The time in seconds after the invite will expire.

max_uses

None, int

How much times the invite can be used.

target_application

None, Application

The target application of the invite.

target_type

InviteTargetType, int

The invite's target type.

target_user

None, ClientUserBase

The target user of the invite.

temporary

bool

Whether this invite only grants temporary membership.

uses

None, int

The amount how much times the invite was used.

Returns

self : instance<cls>

Raises

TypeError

  • If a parameter's type is incorrect.

ValueError

  • If a parameter's value is incorrect.

to_data(...)

Converts the invite to json serializable dictionary.

ParameterTypeOptionalKeyword onlyDefaultDescription
defaults

bool

False

Whether fields with their default values should be included as well.

include_internals

bool

False

Whether internal fields, like id-s should be present as well.

Returns

data : dict of (str, object) items

_create_empty(code)

Creates an empty invite with default attributes set.

ParameterTypeDescription
code

str

Unique identifier of the invite.

Returns

self : instance<cls>

_get_hash_partial()

Returns a partial invite's hash value.

Returns

hash_value : int

_is_equal_same_type(other)

Returns whether the two types are equal.

Helper method for .__eq__

ParameterTypeDescription
other

instance<type<self>>

The other instance. Must be from the same type.

Returns

is_equal : bool

_set_attributes(data)

Sets the invite's attributes (except code).

ParameterTypeDescription
data

dict of (str, object) items

Invite data.

_set_attributes_common(data)

Sets the common attributes of the invite. Used both in ._set_attributes and ._update_attributes.

ParameterTypeDescription
data

dict of (str, object) items

Invite data.

_set_counts_only(data)

Sets the invite's counts.

ParameterTypeDescription
data

dict of (str, object) items

Received invite data.

_update_attributes(data)

Updates the invite with the given data.

ParameterTypeDescription
data

dict of (str, object) items

Invite data.

_update_attributes_partial(data)

Updates the invite's fields that are received with a partial data.

ParameterTypeDescription
data

dict of (str, object) items

Invite data.

_update_counts_only(data)

Updates the invite's counts if given.

ParameterTypeDescription
data

dict of (str, object) items

Received invite data.

__eq__()

Returns whether the two invites are equal.

__ge__()

Whether this entity's id is greater or equal than the other's.

__getattr__()

Drops a rich attribute error.

__gt__()

Whether this entity's id is greater than the other's.

__hash__()

Returns the invite's code's hash.

__le__()

Whether this entity's id is less or equal than the other's.

__lt__()

Whether this entity's id is less than the other's.

__ne__()

Returns whether the two invites are not equal.

__repr__()

Returns the representation of the invite.