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: ✨ Add missing feature flags to Guild.edit #2672

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ These changes are available on the `master` branch, but have not yet been releas
`Permissions.use_external_sounds`, and
`Permissions.view_creator_monetization_analytics`.
([#2620](https://github.com/Pycord-Development/pycord/pull/2620))
- Add missing `Guild` feature flags and `Guild.edit` parameters.
([#2672](https://github.com/Pycord-Development/pycord/pull/2672))

### Fixed

Expand Down
58 changes: 52 additions & 6 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,9 @@ async def edit(
public_updates_channel: TextChannel | None = MISSING,
premium_progress_bar_enabled: bool = MISSING,
disable_invites: bool = MISSING,
discoverable: bool = MISSING,
Paillat-dev marked this conversation as resolved.
Show resolved Hide resolved
raid_alerts: bool = MISSING,
enable_activity_feed: bool = MISSING,
) -> Guild:
r"""|coro|

Expand Down Expand Up @@ -1740,6 +1743,12 @@ async def edit(
Whether the guild should have premium progress bar enabled.
disable_invites: :class:`bool`
Whether the guild should have server invites enabled or disabled.
discoverable: :class:`bool`
Whether the guild should be discoverable in the discover tab.
raid_alerts: :class:`bool`
Whether activity alerts for the guild should be enabled.
enable_activity_feed: class:`bool`
Whether the guild's user activity feed should be enabled.
reason: Optional[:class:`str`]
The reason for editing this guild. Shows up on the audit log.

Expand Down Expand Up @@ -1861,8 +1870,11 @@ async def edit(

fields["system_channel_flags"] = system_channel_flags.value

if premium_progress_bar_enabled is not MISSING:
fields["premium_progress_bar_enabled"] = premium_progress_bar_enabled

if community is not MISSING:
features = self.features.copy()
features: list[str] = fields.get("features", self.features.copy())
if community:
if (
"rules_channel_id" in fields
Expand All @@ -1885,20 +1897,54 @@ async def edit(

fields["features"] = features

if premium_progress_bar_enabled is not MISSING:
fields["premium_progress_bar_enabled"] = premium_progress_bar_enabled

if disable_invites is not MISSING:
features = self.features.copy()
features = fields.get("features", self.features.copy())
if disable_invites:
if not "INVITES_DISABLED" in features:
if "INVITES_DISABLED" not in features:
features.append("INVITES_DISABLED")
else:
if "INVITES_DISABLED" in features:
features.remove("INVITES_DISABLED")

fields["features"] = features

if discoverable is not MISSING:
features = fields.get("features", self.features.copy())
if discoverable:
if "DISCOVERABLE" not in features:
features.append("DISCOVERABLE")
else:
if "DISCOVERABLE" in features:
features.remove("DISCOVERABLE")

fields["features"] = features

if raid_alerts is not MISSING:
features = fields.get("features", self.features.copy())
if raid_alerts:
if "RAID_ALERTS_DISABLED" in features:
features.remove("RAID_ALERTS_DISABLED")
else:
if "RAID_ALERTS_DISABLED" not in features:
features.append("RAID_ALERTS_DISABLED")

fields["features"] = features

if enable_activity_feed is not MISSING:
features = fields.get("features", self.features.copy())
if enable_activity_feed:
if "ACTIVITY_FEED_ENABLED_BY_USER" not in features:
features.append("ACTIVITY_FEED_ENABLED_BY_USER")
if "ACTIVITY_FEED_DISABLED_BY_USER" in features:
features.remove("ACTIVITY_FEED_DISABLED_BY_USER")
else:
if "ACTIVITY_FEED_ENABLED_BY_USER" in features:
features.remove("ACTIVITY_FEED_ENABLED_BY_USER")
if "ACTIVITY_FEED_DISABLED_BY_USER" not in features:
features.append("ACTIVITY_FEED_DISABLED_BY_USER")

fields["features"] = features

Paillat-dev 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
3 changes: 3 additions & 0 deletions discord/types/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class UnavailableGuild(TypedDict):
NSFWLevel = Literal[0, 1, 2, 3]
PremiumTier = Literal[0, 1, 2, 3]
GuildFeature = Literal[
"ACTIVITY_FEED_DISABLED_BY_USER",
"ACTIVITY_FEED_ENABLED_BY_USER",
"ANIMATED_BANNER",
"ANIMATED_ICON",
"APPLICATION_COMMAND_PERMISSIONS_V2",
Expand Down Expand Up @@ -87,6 +89,7 @@ class UnavailableGuild(TypedDict):
"PREVIEW_ENABLED",
"ROLE_ICONS",
"ROLE_SUBSCRIPTIONS_ENABLED",
"RAID_ALERTS_DISABLED",
"SEVEN_DAY_THREAD_ARCHIVE",
"TEXT_IN_VOICE_ENABLED",
"THREAD_DEFAULT_AUTO_ARCHIVE_DURATION",
Expand Down
Loading