From dc94f8ca0c645cbcc4d3242ad9de2bd78e8a529f Mon Sep 17 00:00:00 2001 From: TheMisterSenpai Date: Fri, 15 Apr 2022 17:52:33 +0300 Subject: [PATCH] feat(webhook): add modify --- melisa/models/guild/webhook.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/melisa/models/guild/webhook.py b/melisa/models/guild/webhook.py index 968b4ed..ee810d8 100644 --- a/melisa/models/guild/webhook.py +++ b/melisa/models/guild/webhook.py @@ -87,7 +87,7 @@ class Webhook(APIModelBase): url: APINullable[str] = UNDEFINED async def delete( - self, *, webhook_id: Optional[Snowflake] = None, reason: Optional[str] = None + self, *, reason: Optional[str] = None ): """|coro| Delete a webhook permanently. Requires the ``MANAGE_WEBHOOKS`` permission. @@ -95,12 +95,31 @@ class Webhook(APIModelBase): Parameters ---------- - webhook_id: Optional[:class:`~melisa.utils.types.snowflake.Snowflake`] - ID of the webhook you want to delete reason: Optional[:class:`str`] The reason for delete the webhook. Shows up on the audit log. """ await self._http.delete( - f"/webhooks/{webhook_id}", + f"/webhooks/{self.id}", headers={"X-Audit-Log-Reason": reason}, ) + + async def modify( + self, *, name: Optional[str] = None, channel_id: Optional[Snowflake] = None, reason: Optional[str] = None + ): + """|coro| + Modify a webhook. Requires the ``MANAGE_WEBHOOKS permission``. Returns the updated webhook object on success. + + Parameters + ---------- + name: Optional[:class:`str`] + The default name of the webhook + channel_id: Optional[:class:`~.melisa.utils.snowflake.Snowflake`] + The new channel id this webhook should be moved to + reason: Optional[:class:`str`] + The reason for modify the webhook. Shows up on the audit log. + """ + + await self._http.patch( + f"/webhooks/{self.id}", + headers={"name": name, "channel_id": channel_id, "X-Audit-Log-Reason": reason}, + )