mirror of
https://github.com/MelisaDev/melisa.git
synced 2024-09-22 19:22:01 +03:00
hide typehints and embed add_field method
This commit is contained in:
parent
aba0aebccd
commit
c783acd340
3 changed files with 68 additions and 37 deletions
|
@ -50,6 +50,8 @@ autodoc_default_options = {
|
||||||
'show-inheritance': True
|
'show-inheritance': True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
autodoc_typehints = 'none'
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
templates_path = ['_templates']
|
templates_path = ['_templates']
|
||||||
|
|
||||||
|
|
|
@ -239,47 +239,15 @@ class Channel(APIModelBase):
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
Dict[:class:`str`, Any]
|
Channel
|
||||||
Channel object.
|
Channel object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
message = await self._http.delete(
|
data = await self._http.delete(
|
||||||
f"/channels/{self.id}", headers={"X-Audit-Log-Reason": reason}
|
f"/channels/{self.id}", headers={"X-Audit-Log-Reason": reason}
|
||||||
)
|
)
|
||||||
|
|
||||||
return message
|
return Channel.from_dict(data)
|
||||||
|
|
||||||
async def create_webhook(
|
|
||||||
self,
|
|
||||||
*,
|
|
||||||
name: Optional[str] = None,
|
|
||||||
reason: Optional[str] = None,
|
|
||||||
):
|
|
||||||
"""|coro|
|
|
||||||
Creates a new webhook and returns a webhook object on success.
|
|
||||||
Requires the ``MANAGE_WEBHOOKS`` permission.
|
|
||||||
|
|
||||||
An error will be returned if a webhook name (`name`) is not valid.
|
|
||||||
A webhook name is valid if:
|
|
||||||
|
|
||||||
* It does not contain the substring 'clyde' (case-insensitive)
|
|
||||||
* It follows the nickname guidelines in the Usernames
|
|
||||||
and Nicknames documentation, with an exception that
|
|
||||||
webhook names can be up to 80 characters
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
name: Optional[:class:`str`]
|
|
||||||
Name of the webhook (1-80 characters)
|
|
||||||
reason: Optional[:class:`str`]
|
|
||||||
The reason for create the webhook. Shows up on the audit log.
|
|
||||||
"""
|
|
||||||
|
|
||||||
await self._http.post(
|
|
||||||
f"/channels/{self.id}/webhooks",
|
|
||||||
headers={"name": name, "X-Audit-Log-Reason": reason},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class MessageableChannel(Channel):
|
class MessageableChannel(Channel):
|
||||||
"""A subclass of ``Channel`` with methods that are only available for channels,
|
"""A subclass of ``Channel`` with methods that are only available for channels,
|
||||||
|
@ -569,7 +537,9 @@ class MessageableChannel(Channel):
|
||||||
embeds = []
|
embeds = []
|
||||||
|
|
||||||
content = str(content) if content is not None else None
|
content = str(content) if content is not None else None
|
||||||
embeds.append(embed.to_dict()) if embed is not None else None
|
|
||||||
|
if embed is not None:
|
||||||
|
embeds.append(embed.to_dict())
|
||||||
|
|
||||||
for _embed in embeds:
|
for _embed in embeds:
|
||||||
if embed.total_length() > 6000:
|
if embed.total_length() > 6000:
|
||||||
|
@ -745,6 +715,37 @@ class TextChannel(MessageableChannel):
|
||||||
"""
|
"""
|
||||||
return await super().edit(**kwargs)
|
return await super().edit(**kwargs)
|
||||||
|
|
||||||
|
async def create_webhook(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
name: Optional[str] = None,
|
||||||
|
reason: Optional[str] = None,
|
||||||
|
):
|
||||||
|
"""|coro|
|
||||||
|
Creates a new webhook and returns a webhook object on success.
|
||||||
|
Requires the ``MANAGE_WEBHOOKS`` permission.
|
||||||
|
|
||||||
|
An error will be returned if a webhook name (`name`) is not valid.
|
||||||
|
A webhook name is valid if:
|
||||||
|
|
||||||
|
* It does not contain the substring 'clyde' (case-insensitive)
|
||||||
|
* It follows the nickname guidelines in the Usernames
|
||||||
|
and Nicknames documentation, with an exception that
|
||||||
|
webhook names can be up to 80 characters
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
name: Optional[:class:`str`]
|
||||||
|
Name of the webhook (1-80 characters)
|
||||||
|
reason: Optional[:class:`str`]
|
||||||
|
The reason for create the webhook. Shows up on the audit log.
|
||||||
|
"""
|
||||||
|
|
||||||
|
await self._http.post(
|
||||||
|
f"/channels/{self.id}/webhooks",
|
||||||
|
headers={"name": name, "X-Audit-Log-Reason": reason},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Thread(MessageableChannel):
|
class Thread(MessageableChannel):
|
||||||
"""A subclass of ``Channel`` for threads with all the same attributes."""
|
"""A subclass of ``Channel`` for threads with all the same attributes."""
|
||||||
|
|
|
@ -184,7 +184,7 @@ class EmbedField(APIModelBase):
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
value: str
|
value: str
|
||||||
inline: APINullable[str] = None
|
inline: APINullable[bool] = False
|
||||||
|
|
||||||
|
|
||||||
@dataclass(repr=False)
|
@dataclass(repr=False)
|
||||||
|
@ -372,6 +372,34 @@ class Embed(APIModelBase):
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def add_field(self, name: str, value: str, *, inline: bool = False):
|
||||||
|
"""
|
||||||
|
Adds a field to the embed object.
|
||||||
|
|
||||||
|
This function returns the class instance to allow for fluent-style chaining.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
name: :class:`str`
|
||||||
|
The name of the field.
|
||||||
|
value: :class:`str`
|
||||||
|
The value of the field.
|
||||||
|
inline: :class:`bool`
|
||||||
|
Whether the field should be displayed inline.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
Embed
|
||||||
|
This embed.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if self.fields is None:
|
||||||
|
self.fields = []
|
||||||
|
|
||||||
|
self.fields.append(EmbedField(name=name, value=value, inline=inline))
|
||||||
|
|
||||||
|
return self
|
||||||
|
|
||||||
def total_length(self) -> int:
|
def total_length(self) -> int:
|
||||||
"""Get the total character count of the embed.
|
"""Get the total character count of the embed.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue