Skip to content

Commit

Permalink
Merge branch 'master' into feat/voice-messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Apr 25, 2023
2 parents 59056f9 + 3847a8c commit 6d9b462
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 46 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#1983](https://github.com/Pycord-Development/pycord/pull/1983))
- Added new `application_auto_moderation_rule_create_badge` to `ApplicationFlags`.
([#1992](https://github.com/Pycord-Development/pycord/pull/1992))
- Added `custom_message` to AutoModActionMetadata.
([#2029](https://github.com/Pycord-Development/pycord/pull/2029))
- Added support for
[voice messages](https://github.com/discord/discord-api-docs/pull/6082).
([#2016](https://github.com/Pycord-Development/pycord/pull/2016))
Expand Down Expand Up @@ -66,6 +68,8 @@ These changes are available on the `master` branch, but have not yet been releas
working. ([#1999](https://github.com/Pycord-Development/pycord/pull/1999))
- Fixed `TypeError` being raised when passing `name` argument to bridge groups.
([#2000](https://github.com/Pycord-Development/pycord/pull/2000))
- Fixed `TypeError` in AutoModRule.
- ([#2029](https://github.com/Pycord-Development/pycord/pull/2029))

## [2.4.1] - 2023-03-20

Expand Down
19 changes: 18 additions & 1 deletion discord/automod.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,29 @@ class AutoModActionMetadata:
timeout_duration: :class:`datetime.timedelta`
How long the member that triggered the action should be timed out for.
Only for actions of type :attr:`AutoModActionType.timeout`.
custom_message: :class:`str`
An additional message shown to members when their message is blocked.
Maximum 150 characters.
Only for actions of type :attr:`AutoModActionType.block_message`.
"""

# maybe add a table of action types and attributes?

__slots__ = (
"channel_id",
"timeout_duration",
"custom_message",
)

def __init__(
self, channel_id: int = MISSING, timeout_duration: timedelta = MISSING
self,
channel_id: int = MISSING,
timeout_duration: timedelta = MISSING,
custom_message: str = MISSING,
):
self.channel_id: int = channel_id
self.timeout_duration: timedelta = timeout_duration
self.custom_message: str = custom_message

def to_dict(self) -> dict:
data = {}
Expand All @@ -100,6 +109,9 @@ def to_dict(self) -> dict:
if self.timeout_duration is not MISSING:
data["duration_seconds"] = self.timeout_duration.total_seconds()

if self.custom_message is not MISSING:
data["custom_message"] = self.custom_message

return data

@classmethod
Expand All @@ -113,12 +125,16 @@ def from_dict(cls, data: AutoModActionMetadataPayload):
# might need an explicit int cast
kwargs["timeout_duration"] = timedelta(seconds=duration_seconds)

if (custom_message := data.get("custom_message")) is not None:
kwargs["custom_message"] = custom_message

return cls(**kwargs)

def __repr__(self) -> str:
repr_attrs = (
"channel_id",
"timeout_duration",
"custom_message",
)
inner = []

Expand Down Expand Up @@ -352,6 +368,7 @@ class AutoModRule(Hashable):
"""

__slots__ = (
"__dict__",
"_state",
"id",
"guild_id",
Expand Down
46 changes: 2 additions & 44 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,50 +202,8 @@ class Guild(Hashable):
The guild's notification settings.
features: List[:class:`str`]
A list of features that the guild has. The features that a guild can have are
subject to arbitrary change by Discord.
They are currently as follows:
- ``ANIMATED_BANNER``: Guild can upload an animated banner.
- ``ANIMATED_ICON``: Guild can upload an animated icon.
- ``APPLICATION_COMMAND_PERMISSIONS_V2``: Guild is using the old command permissions behavior.
- ``AUTO_MODERATION``: Guild has enabled the auto moderation system.
- ``BANNER``: Guild can upload and use a banner. (i.e. :attr:`.banner`)
- ``CHANNEL_BANNER``: Guild can upload and use a channel banners.
- ``COMMERCE``: Guild can sell things using store channels, which have now been removed.
- ``COMMUNITY``: Guild is a community server.
- ``DEVELOPER_SUPPORT_SERVER``: Guild has been set as a support server on the App Directory.
- ``DISCOVERABLE``: Guild shows up in Server Discovery.
- ``FEATURABLE``: Guild can be featured in the Server Directory.
- ``HAS_DIRECTORY_ENTRY``: Unknown.
- ``HUB``: Hubs contain a directory channel that let you find school-related, student-run servers for your school or university.
- ``INTERNAL_EMPLOYEE_ONLY``: Indicates that only users with the staff badge can join the guild.
- ``INVITES_DISABLED``: Guild Invites are disabled.
- ``INVITE_SPLASH``: Guild's invite page can have a special splash.
- ``LINKED_TO_HUB``: 'Guild is linked to a hub.
- ``MEMBER_PROFILES``: Unknown.
- ``MEMBER_VERIFICATION_GATE_ENABLED``: Guild has Membership Screening enabled.
- ``MONETIZATION_ENABLED``: Guild has enabled monetization.
- ``MORE_EMOJI``: Guild has increased custom emoji slots.
- ``MORE_STICKERS``: Guild has increased custom sticker slots.
- ``NEWS``: Guild can create news channels.
- ``NEW_THREAD_PERMISSIONS``: Guild has new thread permissions.
- ``PARTNERED``: Guild is a partnered server.
- ``PREMIUM_TIER_3_OVERRIDE``: Forces the server to server boosting level 3 (specifically created by Discord Staff Member "Jethro" for their personal server).
- ``PREVIEW_ENABLED``: Guild can be viewed before being accepted via Membership Screening.
- ``ROLE_ICONS``: Guild can set an image or emoji as a role icon.
- ``ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE``: Role subscriptions are available for purchasing.
- ``ROLE_SUBSCRIPTIONS_ENABLED``: Guild is able to view and manage role subscriptions.
- ``SEVEN_DAY_THREAD_ARCHIVE``: Users can set the thread archive time to 7 days.
- ``TEXT_IN_VOICE_ENABLED``: Guild has a chat button inside voice channels that opens a dedicated text channel in a sidebar similar to thread view.
- ``THREADS_ENABLED_TESTING``: Used by bot developers to test their bots with threads in guilds with 5 or fewer members and a bot. Also gives the premium thread features.
- ``THREE_DAY_THREAD_ARCHIVE``: Users can set the thread archive time to 3 days.
- ``TICKETED_EVENTS_ENABLED``: Guild has enabled ticketed events.
- ``VANITY_URL``: Guild can have a vanity invite URL (e.g. discord.gg/discord-api).
- ``VERIFIED``: Guild is a verified server.
- ``VIP_REGIONS``: Guild has VIP voice regions.
- ``WELCOME_SCREEN_ENABLED``: Guild has enabled the welcome screen.
subject to arbitrary change by Discord. You can find a catalog of guild features
`here <https://github.com/Delitefully/DiscordLists#guild-feature-glossary>`_.
premium_tier: :class:`int`
The premium tier for this guild. Corresponds to "Nitro Server" in the official UI.
The number goes from 0 to 3 inclusive.
Expand Down
1 change: 1 addition & 0 deletions discord/types/automod.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AutoModTriggerMetadata(TypedDict, total=False):
class AutoModActionMetadata(TypedDict, total=False):
channel_id: Snowflake
duration_seconds: int
custom_message: str


class AutoModAction(TypedDict):
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r _.txt
pylint~=2.17.2
pylint~=2.17.3
pytest~=7.3.1
pytest-asyncio~=0.21.0
# pytest-order~=1.0.1
Expand Down

0 comments on commit 6d9b462

Please sign in to comment.