update docs and channel delete

This commit is contained in:
grey-cat-1908 2022-03-27 17:03:46 +03:00
parent bda6b2244d
commit 076a8ccdf3
5 changed files with 85 additions and 16 deletions

View file

@ -3,16 +3,47 @@
Melisa Models Guild
===========================
Channel
--------
ChannelType
~~~~~~~~~~~~~
.. autoclass:: ChannelType()
VideoQualityModes
~~~~~~~~~~~~~~~~~~
.. autoclass:: VideoQualityModes()
Channel
~~~~~~~
.. attributetable:: Channel
.. autoclass:: Channel()
:inherited-members:
TextChannel
~~~~~~~~~~~~~
.. attributetable:: TextChannel
.. autoclass:: TextChannel()
:inherited-members:
Guild
----
------
DefaultMessageNotificationLevel
~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: DefaultMessageNotificationLevel()
ExplicitContentFilterLevel
~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: ExplicitContentFilterLevel()
@ -22,7 +53,7 @@ MFALevel
.. autoclass:: MFALevel()
VerificationLevel
~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~
.. autoclass:: VerificationLevel()
@ -37,7 +68,7 @@ PremiumTier
.. autoclass:: PremiumTier()
SystemChannelFlags
~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~
.. autoclass:: SystemChannelFlags()
@ -48,14 +79,13 @@ GuildFeatures
Guild
~~~~~
.. attributetable:: Guild
.. autoclass:: Guild()
:inherited-members:
UnavailableGuild
~~~~~
~~~~~~~~~~~~~~~~
.. attributetable:: UnavailableGuild
.. autoclass:: UnavailableGuild()

View file

@ -27,4 +27,5 @@ User
.. attributetable:: User
.. autoclass:: User()
:inherited-members:

View file

@ -2,3 +2,4 @@
# Full MIT License can be found in `LICENSE.txt` at the project root.
from .guild import *
from .channel import *

View file

@ -34,7 +34,7 @@ class ChannelType(IntEnum):
GUILD_STORE:
A channel in which game developers can sell their game on Discord
GUILD_NEWS_THREAD:
A temporary sub-channel within a `GUILD_NEWS` channel
A temporary sub-channel within a **GUILD_NEWS** channel
GUILD_PUBLIC_THREAD:
A temporary sub-channel within a GUILD_TEXT channel
GUILD_PRIVATE_THREAD:
@ -115,6 +115,42 @@ class Channel(APIModelBase):
def mention(self):
return f"<#{self.id}>"
async def delete(
self,
*,
reason: Optional[str] = None
) -> Dict[str, Any]:
"""|coro|
Delete a channel, or close a private message.
Deleting a category does not delete its child channels;
they will have their parent_id removed.
Parameters
----------
reason: Optional[:class:`str`]
The reason of the delete channel operation.
Raises
-------
NotFoundError
If channel is not found.
ForbiddenError
You do not have proper permissions to do the actions required.
Returns
-------
Dict[:class:`str`, Any]
Channel object.
"""
message = await self._http.delete(
f"/channels/{self.id}",
headers={"X-Audit-Log-Reason": reason}
)
return message
class TextChannel(Channel):
"""A subclass of ``Channel`` representing text channels with all the same attributes."""
@ -128,6 +164,7 @@ class TextChannel(Channel):
around: Optional[Union[int, str, Snowflake]] = None,
) -> AsyncIterator[Dict[str, Any]]:
"""|coro|
Returns a list of messages in this channel.
Examples
@ -193,6 +230,7 @@ class TextChannel(Channel):
message_id: Optional[Snowflake, int, str],
) -> Dict[str, Any]:
"""|coro|
Returns a specific message in the channel.
Parameters
@ -223,6 +261,7 @@ class TextChannel(Channel):
self, messages: List[Snowflake], *, reason: Optional[str] = None
):
"""|coro|
Delete multiple messages in a single request.
This method will not delete messages older than 2 weeks.
@ -239,7 +278,7 @@ class TextChannel(Channel):
if any message provided is older than that or if any duplicate message IDs are provided.
ForbiddenError
You do not have proper permissions to do the actions required.
(You must have `MANAGE_MESSAGES` permission)
(You must have **MANAGE_MESSAGES** permission)
"""
await self._http.post(
f"channels/{self.id}/messages/bulk-delete",
@ -251,6 +290,7 @@ class TextChannel(Channel):
self, message_id: Optional[Snowflake, str, int], *, reason: Optional[str] = None
):
"""|coro|
Deletes only one specified message.
Parameters
@ -268,7 +308,7 @@ class TextChannel(Channel):
If message is not found.
ForbiddenError
You do not have proper permissions to do the actions required.
(You must have `MANAGE_MESSAGES` permission)
(You must have **MANAGE_MESSAGES** permission)
"""
await self._http.delete(
f"channels/{self.id}/messages/{message_id}",
@ -285,6 +325,7 @@ class TextChannel(Channel):
reason: Optional[str] = None,
):
"""|coro|
Purges a list of messages that meet the criteria specified in parameters.
This method will not delete messages older than 2 weeks.
@ -307,7 +348,7 @@ class TextChannel(Channel):
if any message provided is older than that or if any duplicate message IDs are provided.
ForbiddenError
You do not have proper permissions to do the actions required.
(You must have `MANAGE_MESSAGES` permission)
(You must have **MANAGE_MESSAGES** permission)
"""
iterator = self.history(

View file

@ -166,14 +166,10 @@ class User(APIModelBase):
@property
def premium(self) -> Optional[PremiumTypes]:
"""APINullable[:class:`~melisa.models.user.user.PremiumTypes`]: The
user their premium type in a usable enum.
"""
return None if self.premium_type is None else PremiumTypes(self.premium_type)
@property
def flags(self) -> Optional[UserFlags]:
"""Flags of user"""
return None if self.flags is None else UserFlags(self.flags)
def __str__(self):