From 3736a8c7a58967d96e49551e4bac574ecff2abd8 Mon Sep 17 00:00:00 2001 From: imp <106537315+imptype@users.noreply.github.com> Date: Thu, 21 Sep 2023 10:02:40 +0100 Subject: [PATCH 1/4] Add fetch channel webhooks method --- discohook/https.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/discohook/https.py b/discohook/https.py index 85c87a0..affee0e 100644 --- a/discohook/https.py +++ b/discohook/https.py @@ -84,6 +84,9 @@ async def unpin_channel_message(self, channel_id: str, message_id: str): async def edit_channel_message(self, channel_id: str, message_id: str, form: aiohttp.MultipartWriter): return await self.multipart("PATCH", f"/channels/{channel_id}/messages/{message_id}", form=form, use_auth=True) + async def fetch_channel_webhooks(self, channel_id: str): + return await self.request("GET", f"/channels/{channel_id}/webhooks", use_auth=True) + async def send_webhook_message(self, webhook_id: str, webhook_token: str, form: aiohttp.MultipartWriter): return await self.multipart("POST", f"/webhooks/{webhook_id}/{webhook_token}", form=form) From 46b1b0f3ec39011ed3261c9c48536c2ef8591147 Mon Sep 17 00:00:00 2001 From: imp <106537315+imptype@users.noreply.github.com> Date: Wed, 11 Oct 2023 17:39:30 +0100 Subject: [PATCH 2/4] add PartialChannel.fetch_webhooks() method --- discohook/channel.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/discohook/channel.py b/discohook/channel.py index 92c0b2a..eb08a4c 100644 --- a/discohook/channel.py +++ b/discohook/channel.py @@ -9,6 +9,7 @@ from .multipart import create_form from .params import handle_send_params, merge_fields from .view import View +from .webhook import Webhook if TYPE_CHECKING: from .client import Client @@ -321,6 +322,11 @@ async def crosspost(self, message_id: str): resp = await self.client.http.crosspost_channel_message(self.id, message_id) data = await resp.json() return Message(self.client, data) + + async def fetch_webhooks(self): + resp = await self.client.http.fetch_channel_webhooks(self.id) + data = await resp.json() + return [Webhook(self.client, i) for i in data] class Channel(PartialChannel): From 4b1065b6e6d7760630b136410801afe0048f45ed Mon Sep 17 00:00:00 2001 From: imp <106537315+imptype@users.noreply.github.com> Date: Sat, 21 Oct 2023 13:48:10 +0100 Subject: [PATCH 3/4] Removed webhook import --- discohook/channel.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/discohook/channel.py b/discohook/channel.py index eb08a4c..3c20495 100644 --- a/discohook/channel.py +++ b/discohook/channel.py @@ -9,7 +9,6 @@ from .multipart import create_form from .params import handle_send_params, merge_fields from .view import View -from .webhook import Webhook if TYPE_CHECKING: from .client import Client @@ -326,7 +325,7 @@ async def crosspost(self, message_id: str): async def fetch_webhooks(self): resp = await self.client.http.fetch_channel_webhooks(self.id) data = await resp.json() - return [Webhook(self.client, i) for i in data] + return data class Channel(PartialChannel): From 027a8610bfaff1b20bd3ce5dbd9e930a4c05bc63 Mon Sep 17 00:00:00 2001 From: imp <106537315+imptype@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:56:22 +0000 Subject: [PATCH 4/4] remove client and return resp --- discohook/channel.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/discohook/channel.py b/discohook/channel.py index 3c20495..8cdb42c 100644 --- a/discohook/channel.py +++ b/discohook/channel.py @@ -10,9 +10,6 @@ from .params import handle_send_params, merge_fields from .view import View -if TYPE_CHECKING: - from .client import Client - class PartialChannel: """ @@ -323,9 +320,7 @@ async def crosspost(self, message_id: str): return Message(self.client, data) async def fetch_webhooks(self): - resp = await self.client.http.fetch_channel_webhooks(self.id) - data = await resp.json() - return data + return await self.client.http.fetch_channel_webhooks(self.id) class Channel(PartialChannel):