Skip to content

Commit 2979e9e

Browse files
committed
fix(general): Deprecated Member.mute and added Member.timeout and member.remove_timeout
1 parent 06b0656 commit 2979e9e

File tree

5 files changed

+61
-9
lines changed

5 files changed

+61
-9
lines changed

discord/member.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,58 @@ def voice(self):
652652
def communication_disabled_until(self) -> Optional[datetime.datetime]:
653653
return datetime.datetime.fromisoformat(self._communication_disabled_until) if self._communication_disabled_until else None
654654

655+
@utils.deprecated('Member.timeout')
655656
async def mute(self, until: datetime.datetime, *, reason: Optional[str] = None):
656657
await self.edit(communication_disabled_until=until, reason=reason)
657658

659+
async def timeout(self, until: datetime.datetime, *, reason: Optional[str] = None) -> None:
660+
"""|coro|
661+
662+
A shortcut method to timeout a member.
663+
664+
The :attr:`~Permissions.moderate_members` permission is needed to do this.
665+
666+
Parameters
667+
-----------
668+
until: :class:`datetime.datetime`
669+
Until when the member should be timeouted
670+
671+
.. note::
672+
This can be max 28 days from current time!
673+
674+
reason: Optional[:class:`str`]
675+
The reason for sending the member to timeout - Shows up in the audit-log
676+
677+
Raises
678+
-------
679+
Forbidden:
680+
The bot missing access to timeout this member
681+
HTTPException:
682+
Timeouting the member failed
683+
"""
684+
await self.edit(communication_disabled_until=until, reason=reason)
685+
686+
async def remove_timeout(self, *, reason: Optional[str] = None) -> None:
687+
"""|coro|
688+
689+
A shortcut method to remove a member from timeout.
690+
691+
The :attr:`~Permissions.moderate_members` permission is needed to do this.
692+
693+
Parameters
694+
-----------
695+
reason: Optional[:class:`str`]
696+
The reason for removing the member from timeout - Shows up in the audit-log
697+
698+
Raises
699+
-------
700+
Forbidden:
701+
The bot missing access to remove this member from timeout
702+
HTTPException:
703+
Removing the member from timeout failed
704+
"""
705+
await self.edit(communication_disabled_until=None, reason=reason)
706+
658707
async def ban(self, **kwargs):
659708
"""|coro|
660709
@@ -796,7 +845,7 @@ async def edit(self, *, reason: Optional[str] = None, **fields):
796845
except KeyError:
797846
pass
798847
else:
799-
if communication_disabled_until is not None:
848+
if communication_disabled_until:
800849
payload['communication_disabled_until'] = communication_disabled_until.isoformat()
801850
else:
802851
payload['communication_disabled_until'] = None
File renamed without changes.

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
# Add any paths that contain custom static files (such as style sheets) here,
174174
# relative to this directory. They are copied after the builtin static files,
175175
# so a file named "default.css" will overwrite the builtin "default.css".
176-
html_static_path = ['_static', './_templates/style.css']
176+
html_static_path = ['_static']
177177

178178
def setup(app: 'App'):
179-
app.add_css_file('./_templates/style.css')
179+
app.add_css_file('style.css')

docs/index.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@
4141
New features are also implemented. It's not an extension!
4242
The name only comes from the fact that the original purpose of the library was to add support for message components and we haven't found a better one yet.
4343

44-
.. figure:: https://github.com/mccoderpy/discord.py-message-components/raw/main/images/rtd-logo-wordmark-light.png
45-
:name: discord.py-message-components documentation
46-
:alt: Link to the documentation of discord.py-message-components
47-
:align: center
48-
:target: https://discordpy-message-components.readthedocs.io/en/developer/
44+
.. |PyPI| image:: https://cdn.discordapp.com/emojis/854380926548967444.png?v=1
45+
:alt: PyPI Logo
46+
:width: 30px
47+
:target: https://pypi.org
4948

50-
**Read the Documentation** `here <https://discordpy-message-components.readthedocs.io/en/developer/>`_
49+
.. centered::
50+
**Visit on** |PyPI| **PyPI** `here <https://pypi.org/project/discord.py-message-components>`_
5151

5252

5353
discord.py-message-components is a modern, easy to use, feature-rich, and async ready API wrapper

docs/intro.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ For a Debian-based system, the following command will get these dependencies:
4848
4949
**Remember to check your permissions!**
5050

51+
Installing the developer version
52+
---------------------------------
53+
5154
To install the developer (alpha/beta) version from the `developer-branch <https://github.com/mccoderpy/discord.py-message-components/tree/developer>`_ use:
5255

5356
.. code-block:: sh

0 commit comments

Comments
 (0)