Skip to content

Commit 3bb7163

Browse files
feat: ✨ Add missing feature flags to Guild.edit (#2672)
* ✨ Add missing `Guild` feature flags * ✨ Add `Guild.activity_feed_enabled` to know whether the activity feed is enabled for the guild. * 📝 Docs * 📝 CHANGELOG.md * chore: 👽 Update base max filesize to `10` Mb (#2671) * 👽 Update base max filesize to `10` Mb * 📝 CHANGELOG.md * 📝 Requested changes * ⚡ Compute `features` only once * Remove variable * ♻️ change `raid_alerts` to `enable_raid_alerts` * 🚑 Forgot to rename `enable_raid_alerts` * ♻️ change `enable_raid_alerts` to `disable_raid_alerts` Signed-off-by: Dorukyum <[email protected]> * fix docstring Signed-off-by: Dorukyum <[email protected]> --------- Signed-off-by: Paillat <[email protected]> Signed-off-by: Dorukyum <[email protected]> Co-authored-by: Dorukyum <[email protected]>
1 parent a82f562 commit 3bb7163

File tree

3 files changed

+50
-10
lines changed

3 files changed

+50
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ These changes are available on the `master` branch, but have not yet been releas
5151
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
5252
- Added `Message.forward_to`, `Message.snapshots`, and other related attributes.
5353
([#2598](https://github.com/Pycord-Development/pycord/pull/2598))
54+
- Add missing `Guild` feature flags and `Guild.edit` parameters.
55+
([#2672](https://github.com/Pycord-Development/pycord/pull/2672))
5456
- Added the ability to change the API's base URL with `Route.API_BASE_URL`.
5557
([#2714](https://github.com/Pycord-Development/pycord/pull/2714))
5658
- Added the ability to pass a `datetime.time` object to `format_dt`.

discord/guild.py

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,9 @@ async def edit(
16631663
public_updates_channel: TextChannel | None = MISSING,
16641664
premium_progress_bar_enabled: bool = MISSING,
16651665
disable_invites: bool = MISSING,
1666+
discoverable: bool = MISSING,
1667+
disable_raid_alerts: bool = MISSING,
1668+
enable_activity_feed: bool = MISSING,
16661669
) -> Guild:
16671670
r"""|coro|
16681671
@@ -1740,6 +1743,12 @@ async def edit(
17401743
Whether the guild should have premium progress bar enabled.
17411744
disable_invites: :class:`bool`
17421745
Whether the guild should have server invites enabled or disabled.
1746+
discoverable: :class:`bool`
1747+
Whether the guild should be discoverable in the discover tab.
1748+
disable_raid_alerts: :class:`bool`
1749+
Whether activity alerts for the guild should be disabled.
1750+
enable_activity_feed: class:`bool`
1751+
Whether the guild's user activity feed should be enabled.
17431752
reason: Optional[:class:`str`]
17441753
The reason for editing this guild. Shows up on the audit log.
17451754
@@ -1861,8 +1870,12 @@ async def edit(
18611870

18621871
fields["system_channel_flags"] = system_channel_flags.value
18631872

1873+
if premium_progress_bar_enabled is not MISSING:
1874+
fields["premium_progress_bar_enabled"] = premium_progress_bar_enabled
1875+
1876+
features: list[GuildFeature] = self.features.copy()
1877+
18641878
if community is not MISSING:
1865-
features = self.features.copy()
18661879
if community:
18671880
if (
18681881
"rules_channel_id" in fields
@@ -1872,8 +1885,7 @@ async def edit(
18721885
features.append("COMMUNITY")
18731886
else:
18741887
raise InvalidArgument(
1875-
"community field requires both rules_channel and"
1876-
" public_updates_channel fields to be provided"
1888+
"community field requires both rules_channel and public_updates_channel fields to be provided"
18771889
)
18781890
else:
18791891
if "COMMUNITY" in features:
@@ -1883,20 +1895,43 @@ async def edit(
18831895
fields["public_updates_channel_id"] = None
18841896
features.remove("COMMUNITY")
18851897

1886-
fields["features"] = features
1887-
1888-
if premium_progress_bar_enabled is not MISSING:
1889-
fields["premium_progress_bar_enabled"] = premium_progress_bar_enabled
1890-
18911898
if disable_invites is not MISSING:
1892-
features = self.features.copy()
18931899
if disable_invites:
1894-
if not "INVITES_DISABLED" in features:
1900+
if "INVITES_DISABLED" not in features:
18951901
features.append("INVITES_DISABLED")
18961902
else:
18971903
if "INVITES_DISABLED" in features:
18981904
features.remove("INVITES_DISABLED")
18991905

1906+
if discoverable is not MISSING:
1907+
if discoverable:
1908+
if "DISCOVERABLE" not in features:
1909+
features.append("DISCOVERABLE")
1910+
else:
1911+
if "DISCOVERABLE" in features:
1912+
features.remove("DISCOVERABLE")
1913+
1914+
if disable_raid_alerts is not MISSING:
1915+
if disable_raid_alerts:
1916+
if "RAID_ALERTS_DISABLED" not in features:
1917+
features.append("RAID_ALERTS_DISABLED")
1918+
else:
1919+
if "RAID_ALERTS_DISABLED" in features:
1920+
features.remove("RAID_ALERTS_DISABLED")
1921+
1922+
if enable_activity_feed is not MISSING:
1923+
if enable_activity_feed:
1924+
if "ACTIVITY_FEED_ENABLED_BY_USER" not in features:
1925+
features.append("ACTIVITY_FEED_ENABLED_BY_USER")
1926+
if "ACTIVITY_FEED_DISABLED_BY_USER" in features:
1927+
features.remove("ACTIVITY_FEED_DISABLED_BY_USER")
1928+
else:
1929+
if "ACTIVITY_FEED_ENABLED_BY_USER" in features:
1930+
features.remove("ACTIVITY_FEED_ENABLED_BY_USER")
1931+
if "ACTIVITY_FEED_DISABLED_BY_USER" not in features:
1932+
features.append("ACTIVITY_FEED_DISABLED_BY_USER")
1933+
1934+
if self.features != features:
19001935
fields["features"] = features
19011936

19021937
data = await http.edit_guild(self.id, reason=reason, **fields)

discord/types/guild.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class UnavailableGuild(TypedDict):
5959
NSFWLevel = Literal[0, 1, 2, 3]
6060
PremiumTier = Literal[0, 1, 2, 3]
6161
GuildFeature = Literal[
62+
"ACTIVITY_FEED_DISABLED_BY_USER",
63+
"ACTIVITY_FEED_ENABLED_BY_USER",
6264
"ANIMATED_BANNER",
6365
"ANIMATED_ICON",
6466
"APPLICATION_COMMAND_PERMISSIONS_V2",
@@ -88,6 +90,7 @@ class UnavailableGuild(TypedDict):
8890
"PREVIEW_ENABLED",
8991
"ROLE_ICONS",
9092
"ROLE_SUBSCRIPTIONS_ENABLED",
93+
"RAID_ALERTS_DISABLED",
9194
"SEVEN_DAY_THREAD_ARCHIVE",
9295
"TEXT_IN_VOICE_ENABLED",
9396
"THREAD_DEFAULT_AUTO_ARCHIVE_DURATION",

0 commit comments

Comments
 (0)