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

Added Guild Feature INVITES_DISABLED #1613

Merged
merged 8 commits into from
Sep 6, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ class Guild(Hashable):
The channel that denotes the AFK channel. ``None`` if it doesn't exist.
id: :class:`int`
The guild's ID.
invites_disabled: :class:`bool`
Indicates if the guild invites are disabled.
owner_id: :class:`int`
The guild owner's ID. Use :attr:`Guild.owner` instead.
unavailable: :class:`bool`
Expand Down Expand Up @@ -217,6 +219,7 @@ class Guild(Hashable):
student-run servers for your school or university.
- ``INTERNAL_EMPLOYEE_ONLY``: Indicates that only users with the staff badge can join the guild.
- ``INVITE_SPLASH``: Guild's invite page can have a special splash.
- ``INVITES_DISABLED``: Guild Invites are disabled.
- ``LINKED_TO_HUB``: 'Guild is linked to a hub.
- ``MEMBER_PROFILES``: Unknown.
- ``MEMBER_VERIFICATION_GATE_ENABLED``: Guild has Membership Screening enabled.
Expand Down Expand Up @@ -1018,6 +1021,11 @@ def created_at(self) -> datetime.datetime:
""":class:`datetime.datetime`: Returns the guild's creation time in UTC."""
return utils.snowflake_time(self.id)

@property
def invites_disabled(self) -> bool:
""":class:`bool`: Returns a boolean indicating if the guild invites are disabled"""
Lulalaby marked this conversation as resolved.
Show resolved Hide resolved
return "INVITES_DISABLED" in self.features

def get_member_named(self, name: str, /) -> Optional[Member]:
"""Returns the first member found that matches the name provided.

Expand Down Expand Up @@ -1619,6 +1627,7 @@ async def edit(
rules_channel: Optional[TextChannel] = MISSING,
public_updates_channel: Optional[TextChannel] = MISSING,
premium_progress_bar_enabled: bool = MISSING,
disable_invites: bool = MISSING
) -> Guild:
r"""|coro|

Expand Down Expand Up @@ -1696,6 +1705,8 @@ async def edit(
public updates channel.
premium_progress_bar_enabled: :class:`bool`
Whether the guild should have premium progress bar enabled.
disable_invites: :class:`bool`
Whether the guild should have server invites enabled or disabled.
reason: Optional[:class:`str`]
The reason for editing this guild. Shows up on the audit log.

Expand Down Expand Up @@ -1823,6 +1834,16 @@ async def edit(
if premium_progress_bar_enabled is not MISSING:
fields["premium_progress_bar_enabled"] = premium_progress_bar_enabled

if disable_invites is not MISSING:
if disable_invites:
if not "INVITES_DISABLED" in self.features:
self.features.append("INVITES_DISABLED")
else:
if "INVITES_DISABLED" in self.features:
self.features.remove("INVITES_DISABLED")

fields["features"] = self.features
martinbndr marked this conversation as resolved.
Show resolved Hide resolved

data = await http.edit_guild(self.id, reason=reason, **fields)
return Guild(data=data, state=self._state)

Expand Down