Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support INVITES_DISABLED guild feature #718

Merged
merged 10 commits into from
Sep 7, 2022
1 change: 1 addition & 0 deletions changelog/718.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for modifying the ``INVITES_DISABLED`` guild feature using :func:`Guild.edit`.
22 changes: 20 additions & 2 deletions disnake/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class Guild(Hashable):
- ``HAS_DIRECTORY_ENTRY``: Guild is listed in a student hub.
- ``HUB``: Guild is a student hub.
- ``INVITE_SPLASH``: Guild's invite page can have a special splash.
- ``INVITES_DISABLED``: Guild has disabled invite usage, preventing users from joining.
- ``LINKED_TO_HUB``: Guild is linked to a student hub.
- ``MEMBER_VERIFICATION_GATE_ENABLED``: Guild has Membership Screening enabled.
- ``MONETIZATION_ENABLED``: Guild has enabled monetization.
Expand Down Expand Up @@ -1746,6 +1747,7 @@ async def edit(
splash: Optional[AssetBytes] = MISSING,
discovery_splash: Optional[AssetBytes] = MISSING,
community: bool = MISSING,
invites_disabled: bool = MISSING,
afk_channel: Optional[VoiceChannel] = MISSING,
owner: Snowflake = MISSING,
afk_timeout: int = MISSING,
Expand Down Expand Up @@ -1829,6 +1831,14 @@ async def edit(
community: :class:`bool`
Whether the guild should be a Community guild. If set to ``True``\\, both ``rules_channel``
and ``public_updates_channel`` parameters are required.
invites_disabled: :class:`bool`
Whether the guild can be joined.
onerandomusername marked this conversation as resolved.
Show resolved Hide resolved

This is only available to guilds that contain ``COMMUNITY``
in :attr:`Guild.features`.


.. versionadded:: 2.6
afk_channel: Optional[:class:`VoiceChannel`]
The new channel that is the AFK channel. Could be ``None`` for no AFK channel.
afk_timeout: :class:`int`
Expand Down Expand Up @@ -1974,7 +1984,7 @@ async def edit(

fields["system_channel_flags"] = system_channel_flags.value

if community is not MISSING:
if community is not MISSING or invites_disabled is not MISSING:
# If we don't have complete feature information for the guild,
# it is possible to disable or enable other features that we didn't intend to touch.
# To enable or disable a feature, we will need to provide all of the existing features in advance.
Expand All @@ -1985,7 +1995,7 @@ async def edit(
features = set(self.features)
if community is not MISSING:
if not isinstance(community, bool):
raise TypeError("community must be a bool instance")
raise TypeError("community must be a bool")
if community:
if "rules_channel_id" in fields and "public_updates_channel_id" in fields:
features.add("COMMUNITY")
Expand All @@ -1996,6 +2006,14 @@ async def edit(
else:
features.discard("COMMUNITY")

if invites_disabled is not MISSING:
if not isinstance(invites_disabled, bool):
raise TypeError("invites_disabled must be a bool")
if invites_disabled:
features.add("INVITES_DISABLED")
else:
features.discard("INVITES_DISABLED")

fields["features"] = list(features)

if premium_progress_bar_enabled is not MISSING:
Expand Down
1 change: 1 addition & 0 deletions disnake/types/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class _GuildOptional(TypedDict, total=False):
"HAS_DIRECTORY_ENTRY",
"HUB",
"INVITE_SPLASH",
"INVITES_DISABLED",
"LINKED_TO_HUB",
"MEMBER_PROFILES", # not sure what this does, if anything
"MEMBER_VERIFICATION_GATE_ENABLED",
Expand Down