Skip to content

Commit

Permalink
feat(AutoMod): add support for custom_message (#954)
Browse files Browse the repository at this point in the history

Signed-off-by: Victor <[email protected]>
Co-authored-by: shiftinv <[email protected]>
Co-authored-by: arl <[email protected]>
  • Loading branch information
3 people authored Feb 26, 2023
1 parent b07051e commit 73f08a7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/954.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for :attr:`AutoModBlockMessageAction.custom_message`
23 changes: 21 additions & 2 deletions disnake/automod.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ class AutoModBlockMessageAction(AutoModAction):
.. versionadded:: 2.6
Parameters
----------
custom_message: Optional[:class:`str`]
The custom message to show to the user when the rule is triggered.
Maximum length is 150 characters.
.. versionadded:: 2.9
Attributes
----------
type: :class:`AutoModActionType`
Expand All @@ -127,11 +135,22 @@ class AutoModBlockMessageAction(AutoModAction):

_metadata: AutoModBlockMessageActionMetadata

def __init__(self) -> None:
def __init__(self, custom_message: Optional[str] = None) -> None:
super().__init__(type=AutoModActionType.block_message)

if custom_message is not None:
self._metadata["custom_message"] = custom_message

@property
def custom_message(self) -> Optional[str]:
"""Optional[:class:`str`]: The custom message to show to the user when the rule is triggered.
.. versionadded:: 2.9
"""
return self._metadata.get("custom_message")

def __repr__(self) -> str:
return f"<{type(self).__name__}>"
return f"<{type(self).__name__} custom_message={self.custom_message!r}>"


class AutoModSendAlertAction(AutoModAction):
Expand Down
2 changes: 1 addition & 1 deletion disnake/types/automod.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class AutoModBlockMessageActionMetadata(TypedDict):
...
custom_message: NotRequired[str]


class AutoModSendAlertActionMetadata(TypedDict):
Expand Down

0 comments on commit 73f08a7

Please sign in to comment.