Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fetch channel webhooks method #28

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions discohook/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -321,6 +318,9 @@ 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):
return await self.client.http.fetch_channel_webhooks(self.id)


class Channel(PartialChannel):
Expand Down
3 changes: 3 additions & 0 deletions discohook/https.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down