Skip to content

feat(invite): implement community invites#1511

Open
Snipy7374 wants to merge 16 commits intoDisnakeDev:masterfrom
Snipy7374:feat/community_invites
Open

feat(invite): implement community invites#1511
Snipy7374 wants to merge 16 commits intoDisnakeDev:masterfrom
Snipy7374:feat/community_invites

Conversation

@Snipy7374
Copy link
Copy Markdown
Collaborator

Summary

Checklist

  • If code changes were made, then they have been tested
    • I have updated the documentation to reflect the changes
    • I have formatted the code properly by running uv run nox -s lint
    • I have type-checked the code by running uv run nox -s pyright
  • This PR fixes an issue
  • This PR adds something new (e.g. new method or parameters)
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@Snipy7374 Snipy7374 added t: enhancement New feature t: api support Support of Discord API features s: needs review Issue/PR is awaiting reviews labels Mar 8, 2026
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community bot commented Mar 8, 2026

Documentation build overview

📚 disnake | 🛠️ Build #31713062 | 📁 Comparing dffc5e9 against latest (664d0a7)


🔍 Preview build

Show files changed (50 files in total): 📝 50 modified | ➕ 0 added | ➖ 0 deleted
File Status
faq.html 📝 modified
genindex.html 📝 modified
index.html 📝 modified
whats_new.html 📝 modified
api/abc.html 📝 modified
api/activities.html 📝 modified
api/app_commands.html 📝 modified
api/app_info.html 📝 modified
api/audit_logs.html 📝 modified
api/automod.html 📝 modified
api/channels.html 📝 modified
api/clients.html 📝 modified
api/components.html 📝 modified
api/emoji.html 📝 modified
api/entitlements.html 📝 modified
api/events.html 📝 modified
api/exceptions.html 📝 modified
api/guild_scheduled_events.html 📝 modified
api/guilds.html 📝 modified
api/integrations.html 📝 modified
api/interactions.html 📝 modified
api/invites.html 📝 modified
api/localization.html 📝 modified
api/members.html 📝 modified
api/messages.html 📝 modified
api/misc.html 📝 modified
api/permissions.html 📝 modified
api/roles.html 📝 modified
api/skus.html 📝 modified
api/soundboard.html 📝 modified
api/stage_instances.html 📝 modified
api/stickers.html 📝 modified
api/subscriptions.html 📝 modified
api/ui.html 📝 modified
api/users.html 📝 modified
api/utilities.html 📝 modified
api/voice.html 📝 modified
api/webhooks.html 📝 modified
api/widgets.html 📝 modified
ext/tasks/index.html 📝 modified
ext/commands/api/app_commands.html 📝 modified
ext/commands/api/bots.html 📝 modified
ext/commands/api/checks.html 📝 modified
ext/commands/api/cogs.html 📝 modified
ext/commands/api/context.html 📝 modified
ext/commands/api/converters.html 📝 modified
ext/commands/api/exceptions.html 📝 modified
ext/commands/api/help_commands.html 📝 modified
ext/commands/api/misc.html 📝 modified
ext/commands/api/prefix_commands.html 📝 modified

Copy link
Copy Markdown
Contributor

@Enegg Enegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review NOW

Comment thread disnake/abc.py Outdated
Comment thread disnake/abc.py Outdated
Comment thread disnake/abc.py Outdated
Comment thread disnake/flags.py Outdated
Comment thread disnake/invite.py Outdated
Comment thread disnake/abc.py Outdated
Comment thread disnake/types/invite.py
Comment on lines +66 to +67
created_at: datetime
completed_at: datetime | None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, do we use datetime in TypedDicts anywhere else?
What's the reason some of those are str and some datetime?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is that the ones with str are to annotate the payload returned by the dAPI, the ones with datetime are for our users because I thought this endpoint didn't need its whole class to represent the model, a dict is sufficient IMO, so that's why I defined another typed dict, so our users will know the types and the keys in code too

Comment thread disnake/invite.py
self.flags = GuildInviteFlags._from_value(data.get("flags", 0))
self.roles = [
Role(
guild=self.guild,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a type error on this line

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know but idk what to do, when could guild even be none, only if not cached in theory, Role needs it tho

Comment thread disnake/invite.py Outdated
Comment thread disnake/invite.py
Comment on lines +731 to +738
return {
"status": data["status"],
"total_users": data["total_users"],
"processed_users": data["processed_users"],
"created_at": parse_time(data["created_at"]),
"completed_at": parse_time(data["completed_at"]),
"error_message": data["error_message"],
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a small NamedTuple or a dataclass, I think it's unprecedented to return a dict from a public method

Copy link
Copy Markdown
Collaborator Author

@Snipy7374 Snipy7374 Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For an endpoint it's unprecedented yes, I did it because for this specific endpoint it doesn't make sense to me to have a whole class, so yeah I'll switch to a NamedTuple

Snipy7374 and others added 15 commits March 8, 2026 16:57
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com>
Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com>
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com>
Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com>
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com>
Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com>
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com>
Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com>
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com>
Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com>
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com>
Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com>
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com>
Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com>
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com>
Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com>
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com>
Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com>
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com>
Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com>
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com>
Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com>
Comment thread disnake/abc.py

.. versionadded:: 2.3

roles: :class:`list`\[:class:`.Role`] | :data:`None`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
roles: :class:`list`\[:class:`.Role`] | :data:`None`
roles: :class:`~collections.abc.Collection`\[:class:`.Role`] | :data:`None`

Comment thread disnake/invite.py
self.guild_scheduled_event: GuildScheduledEvent | None = None

self.flags = GuildInviteFlags._from_value(data.get("flags", 0))
self.roles = [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since invites are Hashable, .roles should probably be an immutable sequence (tuple)

Comment thread disnake/invite.py

Fetch the csv file with the target users for this invite.
You must have the :attr:`~Permissions.manage_guild` or :attr:`~Permissions.view_audit_log`
permissions or to be the inviter to do this.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
permissions or to be the inviter to do this.
permissions or be the inviter to do this.

Comment thread disnake/invite.py
"""|coro|

Update the target users for this invite.
You must have the :attr:`~Permissions.manage_guild` permission or to be the inviter to do this.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You must have the :attr:`~Permissions.manage_guild` permission or to be the inviter to do this.
You must have the :attr:`~Permissions.manage_guild` permission or be the inviter to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s: needs review Issue/PR is awaiting reviews t: api support Support of Discord API features t: enhancement New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

implement community invites

2 participants