Skip to content

feat: ✨ Add missing feature flags to Guild.edit #2672

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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9bb2a57
:sparkles: Add missing `Guild` feature flags
Paillat-dev Dec 17, 2024
58d5beb
:sparkles: Add `Guild.activity_feed_enabled` to know whether the acti…
Paillat-dev Dec 17, 2024
1632bce
:memo: Docs
Paillat-dev Dec 17, 2024
712b238
:memo: CHANGELOG.md
Paillat-dev Dec 17, 2024
f8cc48c
Merge branch 'master' into feat-guild-user-activity-flag
Paillat-dev Dec 18, 2024
8dd4b4f
chore: :alien: Update base max filesize to `10` Mb (#2671)
Paillat-dev Dec 18, 2024
1751e11
Merge branch 'master' into feat-guild-user-activity-flag
Paillat-dev Dec 26, 2024
e93112b
:memo: Requested changes
Paillat-dev Dec 26, 2024
3ddbead
:zap: Compute `features` only once
Paillat-dev Jan 2, 2025
18ee4c4
Merge branch 'master' into feat-guild-user-activity-flag
Paillat-dev Jan 2, 2025
9894c4e
Remove variable
Dorukyum Jan 2, 2025
9cb74b2
:recycle: change `raid_alerts` to `enable_raid_alerts`
Paillat-dev Jan 6, 2025
e61f568
Merge remote-tracking branch 'refs/remotes/origin/master' into feat-g…
Paillat-dev Jan 6, 2025
9609cc5
Merge remote-tracking branch 'origin/master' into feat-guild-user-act…
Paillat-dev Feb 16, 2025
0fb579d
Merge branch 'master' into feat-guild-user-activity-flag
Paillat-dev Mar 3, 2025
b659ffd
:ambulance: Forgot to rename `enable_raid_alerts`
Paillat-dev Mar 29, 2025
82f0ad8
Merge branch 'master' into feat-guild-user-activity-flag
Paillat-dev Mar 30, 2025
95593f2
♻️ change `enable_raid_alerts` to `disable_raid_alerts`
Dorukyum Mar 31, 2025
c73a987
fix docstring
Dorukyum Mar 31, 2025
62de13e
Merge branch 'master' into feat-guild-user-activity-flag
Paillat-dev Apr 20, 2025
2a30425
Merge branch 'master' into feat-guild-user-activity-flag
Paillat-dev May 27, 2025
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 @@ -51,6 +51,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
- Added `Message.forward_to`, `Message.snapshots`, and other related attributes.
([#2598](https://github.com/Pycord-Development/pycord/pull/2598))
- Add missing `Guild` feature flags and `Guild.edit` parameters.
([#2672](https://github.com/Pycord-Development/pycord/pull/2672))
- Added the ability to change the API's base URL with `Route.API_BASE_URL`.
([#2714](https://github.com/Pycord-Development/pycord/pull/2714))
- Added the ability to pass a `datetime.time` object to `format_dt`
Expand Down
55 changes: 45 additions & 10 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,
disable_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.
disable_raid_alerts: :class:`bool`
Whether activity alerts for the guild should be disabled.
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,12 @@ 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

features: list[GuildFeature] = self.features.copy()

if community is not MISSING:
features = self.features.copy()
if community:
if (
"rules_channel_id" in fields
Expand All @@ -1872,8 +1885,7 @@ async def edit(
features.append("COMMUNITY")
else:
raise InvalidArgument(
"community field requires both rules_channel and"
" public_updates_channel fields to be provided"
"community field requires both rules_channel and public_updates_channel fields to be provided"
)
else:
if "COMMUNITY" in features:
Expand All @@ -1883,20 +1895,43 @@ async def edit(
fields["public_updates_channel_id"] = None
features.remove("COMMUNITY")

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()
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")

if discoverable is not MISSING:
if discoverable:
if "DISCOVERABLE" not in features:
features.append("DISCOVERABLE")
else:
if "DISCOVERABLE" in features:
features.remove("DISCOVERABLE")

if disable_raid_alerts is not MISSING:
if disable_raid_alerts:
if "RAID_ALERTS_DISABLED" not in features:
features.append("RAID_ALERTS_DISABLED")
else:
if "RAID_ALERTS_DISABLED" in features:
features.remove("RAID_ALERTS_DISABLED")

if enable_activity_feed is not MISSING:
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")

if self.features != features:
fields["features"] = features

data = await http.edit_guild(self.id, reason=reason, **fields)
Expand Down
3 changes: 3 additions & 0 deletions discord/types/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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 @@ -88,6 +90,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