mirror of
https://github.com/MelisaDev/melisa.git
synced 2024-11-11 19:07:28 +03:00
migrate create webhook to channel
This commit is contained in:
parent
e4373467b6
commit
9a89817b37
2 changed files with 34 additions and 34 deletions
|
@ -249,6 +249,40 @@ class Channel(APIModelBase):
|
|||
|
||||
return message
|
||||
|
||||
async def create_webhook(
|
||||
self,
|
||||
*,
|
||||
channel_id: Optional[Snowflake] = None,
|
||||
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
|
||||
----------
|
||||
channel_id: Optional[:class:`~melisa.utils.types.snowflake.Snowflake`]
|
||||
The channel id this webhook is for, if any
|
||||
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/{channel_id}/webhooks",
|
||||
headers={"name": name, "X-Audit-Log-Reason": reason},
|
||||
)
|
||||
|
||||
|
||||
class MessageableChannel(Channel):
|
||||
"""A subclass of ``Channel`` with methods that are only available for channels,
|
||||
|
|
|
@ -86,40 +86,6 @@ class Webhook(APIModelBase):
|
|||
source_channel: APINullable[Channel] = None
|
||||
url: APINullable[str] = None
|
||||
|
||||
async def create(
|
||||
self,
|
||||
*,
|
||||
channel_id: Optional[Snowflake] = None,
|
||||
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
|
||||
----------
|
||||
channel_id: Optional[:class:`~melisa.utils.types.snowflake.Snowflake`]
|
||||
The channel id this webhook is for, if any
|
||||
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/{channel_id}/webhooks",
|
||||
headers={"name": name, "X-Audit-Log-Reason": reason},
|
||||
)
|
||||
|
||||
async def delete(
|
||||
self,
|
||||
*,
|
||||
|
|
Loading…
Reference in a new issue