Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit bfe7e8b

Browse files
authored
✨ Crosspost Method (#432)
* ✨ Added crosspost_message * 💀 Removed accidental spaces * 💀 Removed accidental import
1 parent 4386e57 commit bfe7e8b

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

pincer/client.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,5 +1084,28 @@ async def sticker_packs(self) -> AsyncIterator[StickerPack]:
10841084
for pack in packs:
10851085
yield StickerPack.from_dict(pack)
10861086

1087+
async def crosspost_message(self, channel_id: int, message_id: int) -> UserMessage:
1088+
"""|coro|
1089+
Crosspost a message in a News Channel to following channels.
1090+
1091+
This endpoint requires the ``SEND_MESSAGES`` permission,
1092+
if the current user sent the message, or additionally the
1093+
``MANAGE_MESSAGES`` permission, for all other messages,
1094+
to be present for the current user.
1095+
1096+
Parameters
1097+
----------
1098+
channel_id : int
1099+
ID of the news channel that the message is in.
1100+
message_id : int
1101+
ID of the message to crosspost.
1102+
1103+
Returns
1104+
-------
1105+
:class:`~pincer.objects.message.UserMessage`
1106+
The crossposted message
1107+
"""
1108+
1109+
return await self._http.post(f"channels/{channel_id}/{message_id}/crosspost")
10871110

10881111
Bot = Client

pincer/objects/message/user_message.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,22 @@ async def from_id(
388388
msg = await client.http.get(f"channels/{channel_id}/messages/{_id}")
389389
return cls.from_dict(msg)
390390

391+
async def crosspost(self) -> UserMessage:
392+
"""|coro|
393+
Crosspost a message in a News Channel to following channels.
394+
395+
This endpoint requires the ``SEND_MESSAGES`` permission,
396+
if the current user sent the message, or additionally the
397+
``MANAGE_MESSAGES`` permission, for all other messages,
398+
to be present for the current user.
399+
400+
Returns
401+
-------
402+
:class:`~pincer.objects.message.UserMessage`
403+
The crossposted message
404+
"""
405+
return await self._client.crosspost_message(self.channel_id, self.id)
406+
391407
def __str__(self):
392408
return self.content
393409

0 commit comments

Comments
 (0)