Skip to content

Commit cdb9628

Browse files
committed
feat: ✨ Add missing feature flags to Guild.edit (Pycord-Development#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 (Pycord-Development#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]> (cherry picked from commit 3bb7163) # Conflicts: # discord/guild.py # discord/types/guild.py
1 parent 2036257 commit cdb9628

File tree

3 files changed

+49
-13
lines changed

3 files changed

+49
-13
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: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,9 @@ async def edit(
15991599
public_updates_channel: TextChannel | None | utils.Undefined = MISSING,
16001600
premium_progress_bar_enabled: bool | utils.Undefined = MISSING,
16011601
disable_invites: bool | utils.Undefined = MISSING,
1602+
discoverable: bool | utils.Undefined = MISSING,
1603+
disable_raid_alerts: bool | utils.Undefined = MISSING,
1604+
enable_activity_feed: bool | utils.Undefined = MISSING,
16021605
) -> Guild:
16031606
r"""|coro|
16041607
@@ -1676,6 +1679,12 @@ async def edit(
16761679
Whether the guild should have premium progress bar enabled.
16771680
disable_invites: :class:`bool`
16781681
Whether the guild should have server invites enabled or disabled.
1682+
discoverable: :class:`bool`
1683+
Whether the guild should be discoverable in the discover tab.
1684+
disable_raid_alerts: :class:`bool`
1685+
Whether activity alerts for the guild should be disabled.
1686+
enable_activity_feed: class:`bool`
1687+
Whether the guild's user activity feed should be enabled.
16791688
reason: Optional[:class:`str`]
16801689
The reason for editing this guild. Shows up on the audit log.
16811690
@@ -1785,8 +1794,12 @@ async def edit(
17851794

17861795
fields["system_channel_flags"] = system_channel_flags.value
17871796

1797+
if premium_progress_bar_enabled is not MISSING:
1798+
fields["premium_progress_bar_enabled"] = premium_progress_bar_enabled
1799+
1800+
features: list[GuildFeature] = self.features.copy()
1801+
17881802
if community is not MISSING:
1789-
features = self.features.copy()
17901803
if community:
17911804
if "rules_channel_id" in fields and "public_updates_channel_id" in fields:
17921805
if "COMMUNITY" not in features:
@@ -1803,20 +1816,43 @@ async def edit(
18031816
fields["public_updates_channel_id"] = None
18041817
features.remove("COMMUNITY")
18051818

1806-
fields["features"] = features
1807-
1808-
if premium_progress_bar_enabled is not MISSING:
1809-
fields["premium_progress_bar_enabled"] = premium_progress_bar_enabled
1810-
18111819
if disable_invites is not MISSING:
1812-
features = self.features.copy()
18131820
if disable_invites:
1814-
if not "INVITES_DISABLED" in features:
1821+
if "INVITES_DISABLED" not in features:
18151822
features.append("INVITES_DISABLED")
18161823
else:
18171824
if "INVITES_DISABLED" in features:
18181825
features.remove("INVITES_DISABLED")
18191826

1827+
if discoverable is not MISSING:
1828+
if discoverable:
1829+
if "DISCOVERABLE" not in features:
1830+
features.append("DISCOVERABLE")
1831+
else:
1832+
if "DISCOVERABLE" in features:
1833+
features.remove("DISCOVERABLE")
1834+
1835+
if disable_raid_alerts is not MISSING:
1836+
if disable_raid_alerts:
1837+
if "RAID_ALERTS_DISABLED" not in features:
1838+
features.append("RAID_ALERTS_DISABLED")
1839+
else:
1840+
if "RAID_ALERTS_DISABLED" in features:
1841+
features.remove("RAID_ALERTS_DISABLED")
1842+
1843+
if enable_activity_feed is not MISSING:
1844+
if enable_activity_feed:
1845+
if "ACTIVITY_FEED_ENABLED_BY_USER" not in features:
1846+
features.append("ACTIVITY_FEED_ENABLED_BY_USER")
1847+
if "ACTIVITY_FEED_DISABLED_BY_USER" in features:
1848+
features.remove("ACTIVITY_FEED_DISABLED_BY_USER")
1849+
else:
1850+
if "ACTIVITY_FEED_ENABLED_BY_USER" in features:
1851+
features.remove("ACTIVITY_FEED_ENABLED_BY_USER")
1852+
if "ACTIVITY_FEED_DISABLED_BY_USER" not in features:
1853+
features.append("ACTIVITY_FEED_DISABLED_BY_USER")
1854+
1855+
if self.features != features:
18201856
fields["features"] = features
18211857

18221858
data = await http.edit_guild(self.id, reason=reason, **fields)
@@ -2224,7 +2260,7 @@ async def templates(self) -> list[Template]:
22242260
Forbidden
22252261
You don't have permissions to get the templates.
22262262
"""
2227-
from .template import Template # noqa: PLC0415
2263+
from .template import Template
22282264

22292265
data = await self._state.http.guild_templates(self.id)
22302266
return [Template(data=d, state=self._state) for d in data]
@@ -2247,7 +2283,7 @@ async def webhooks(self) -> list[Webhook]:
22472283
You don't have permissions to get the webhooks.
22482284
"""
22492285

2250-
from .webhook import Webhook # noqa: PLC0415
2286+
from .webhook import Webhook
22512287

22522288
data = await self._state.http.guild_webhooks(self.id)
22532289
return [Webhook.from_state(d, state=self._state) for d in data]
@@ -2337,7 +2373,7 @@ async def create_template(self, *, name: str, description: str | utils.Undefined
23372373
description: :class:`str`
23382374
The description of the template.
23392375
"""
2340-
from .template import Template # noqa: PLC0415
2376+
from .template import Template
23412377

23422378
payload = {"name": name}
23432379

discord/types/guild.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ class UnavailableGuild(TypedDict):
187187
"ROLE_ICONS",
188188
"ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE",
189189
"ROLE_SUBSCRIPTIONS_ENABLED",
190-
"ROLE_SUBSCRIPTIONS_ENABLED_FOR_PURCHASE",
191-
"SERVER_PROFILES_TEST",
192190
"SEVEN_DAY_THREAD_ARCHIVE",
193191
"SHARD",
194192
"SHARED_CANVAS_FRIENDS_AND_FAMILY_TEST",

0 commit comments

Comments
 (0)