From 9a89817b379ecf9c3d3965da694927c3b9778bbf Mon Sep 17 00:00:00 2001 From: TheMisterSenpai Date: Wed, 13 Apr 2022 16:54:09 +0300 Subject: [PATCH] migrate create webhook to channel --- melisa/models/guild/channel.py | 34 ++++++++++++++++++++++++++++++++++ melisa/models/guild/webhook.py | 34 ---------------------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/melisa/models/guild/channel.py b/melisa/models/guild/channel.py index 59034d6..d0b5d5c 100644 --- a/melisa/models/guild/channel.py +++ b/melisa/models/guild/channel.py @@ -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, diff --git a/melisa/models/guild/webhook.py b/melisa/models/guild/webhook.py index adbcffe..132fdb6 100644 --- a/melisa/models/guild/webhook.py +++ b/melisa/models/guild/webhook.py @@ -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, *,