Invites¶
This section documents everything related to invites.
Discord Models¶
Invite¶
- asyncdelete
- asyncfetch_target_users
- asyncfetch_target_users_job_status
- asyncupdate_target_users
- class disnake.Invite[source]¶
Represents a Discord
Guildorabc.GuildChannelinvite.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
Guild.invites()withmanage_guildpermissions,abc.GuildChannel.invites()Guild.invites()withmanage_guildpermissions,abc.GuildChannel.invites()Guild.invites()withmanage_guildpermissions,abc.GuildChannel.invites()Guild.invites()withmanage_guildpermissions,abc.GuildChannel.invites()Guild.invites()withmanage_guildpermissions,abc.GuildChannel.invites()Client.fetch_invite()withwith_countsenabledClient.fetch_invite()withwith_countsenabledClient.fetch_invite()with validguild_scheduled_event_idor valid event ID in URL or invite objectIf something is not in the table above, then it’s available by all methods.
- type¶
The type of the invite.
New in version 2.10.
- Type:
- guild¶
The guild the invite is for. Can be
Noneif it’s not a guild invite (seetype).- Type:
Guild|Object|PartialInviteGuild|None
- max_age¶
How long before the invite expires in seconds. A value of
0indicates that it doesn’t expire.Optional according to the table above.
- max_uses¶
How many times the invite can be used. A value of
0indicates that it has unlimited uses.Optional according to the table above.
- created_at¶
An aware UTC datetime object denoting the time the invite was created.
Optional according to the table above.
- Type:
- 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.
- approximate_member_count¶
The approximate number of members in the guild.
Optional according to the table above.
- 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.
- expires_at¶
The expiration date of the invite. If the value is
Nonethe invite will never expire.New in version 2.0.
- Type:
- channel¶
The channel the invite is for.
- Type:
- target_type¶
The type of target for the voice channel invite.
New in version 2.0.
- Type:
- target_user¶
The user whose stream to display for this invite, if any.
New in version 2.0.
- target_application¶
The embedded application the invite targets, if any.
New in version 2.0.
- Type:
- guild_scheduled_event¶
The guild scheduled event included in the invite, if any.
New in version 2.3.
- Type:
- guild_welcome_screen¶
The partial guild’s welcome screen, if any.
New in version 2.5.
- Type:
- flags¶
The flags of this invite.
New in version 2.13.
- Type:
- roles¶
A list of roles that will be assigned to the users when joining, if any.
New in version 2.13.
- await delete(*, reason=None)[source]¶
This function is a coroutine.
Revokes the instant invite.
You must have
manage_channelspermission 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_guildorview_audit_logpermissions 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:
- await update_target_users(*, file)[source]¶
This function is a coroutine.
Update the target users for this invite. You must have the
manage_guildpermission 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.
- file:
- await fetch_target_users_job_status()[source]¶
This function is a coroutine.
Get the target users job status. You must have the
manage_guildorview_audit_logpermissions 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
dictcontaining the job status.Key
Type
Description
status
The status of the job
total_users
The total number of targeted users
processed_users
The total number of processed users so far
created_at
The date when the job started
completed_at
The date when the job was completed,
Noneif it’s still runningerror_message
The error message of the job, if any
Status Value
Name
Description
0UNSPECIFIEDThe default value
1PROCESSINGThe job is currently being processed
2COMPLETEDThe job has been completed successfully
3FAILEDThe job has failed, see
error_messagefield for more details- Return type:
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
Inviteresolves 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.
- features¶
A list of features the partial guild has. See
Guild.featuresfor more information.
- verification_level¶
The partial guild’s verification level.
- Type:
The number of “boosts” this guild currently has.
New in version 2.5.
- Type:
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
Inviteresolves 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.
- type¶
The partial channel’s type.
- Type:
GuildInviteFlags¶
- 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
yinverted 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: