Sends a message to a channel. Parameters ---------- channel_id: :class:`str` The id of the channel. content: Optional[:class:`str`] The content of the message. attachments: Optional[List[Union[:class:`str`, :class:`File`]]]
(
self,
channel_id: str,
*,
content: Optional[str] = None,
attachments: Optional[List[Union[str, File]]] = None,
embeds: Optional[List[Union[SendableEmbedPayload, SendableEmbed]]] = None,
replies: Optional[List[Union[MessageReplyPayload, MessageReply]]] = None,
masquerade: Optional[Union[MasqueradePayload, MessageMasquerade]] = None,
interactions: Optional[Union[MessageInteractionsPayload, MessageInteractions]] = None,
)
| 368 | ) |
| 369 | |
| 370 | async def send_message( |
| 371 | self, |
| 372 | channel_id: str, |
| 373 | *, |
| 374 | content: Optional[str] = None, |
| 375 | attachments: Optional[List[Union[str, File]]] = None, |
| 376 | embeds: Optional[List[Union[SendableEmbedPayload, SendableEmbed]]] = None, |
| 377 | replies: Optional[List[Union[MessageReplyPayload, MessageReply]]] = None, |
| 378 | masquerade: Optional[Union[MasqueradePayload, MessageMasquerade]] = None, |
| 379 | interactions: Optional[Union[MessageInteractionsPayload, MessageInteractions]] = None, |
| 380 | ) -> MessagePayload: |
| 381 | """ |
| 382 | Sends a message to a channel. |
| 383 | |
| 384 | Parameters |
| 385 | ---------- |
| 386 | channel_id: :class:`str` |
| 387 | The id of the channel. |
| 388 | content: Optional[:class:`str`] |
| 389 | The content of the message. |
| 390 | attachments: Optional[List[Union[:class:`str`, :class:`File`]]] |
| 391 | The attachments of the message. |
| 392 | embeds: Optional[List[Union[:class:`SendableEmbedPayload`, :class:`SendableEmbed`]]] |
| 393 | The embeds of the message. |
| 394 | replies: Optional[List[Union[:class:`MessageReplyPayload`, :class:`MessageReply`]]] |
| 395 | The replies of the message. |
| 396 | masquerade: Optional[Union[:class:`MasqueradePayload`, :class:`MessageMasquerade`]] |
| 397 | The masquerade of the message. |
| 398 | interactions: Optional[Union[:class:`MessageInteractionsPayload`, :class:`MessageInteractions`]] |
| 399 | The interactions of the message. |
| 400 | """ |
| 401 | data: Dict[str, Any] = {} |
| 402 | if content: |
| 403 | data["content"] = content |
| 404 | if attachments: |
| 405 | data["attachments"] = await gather(*[self.handle_attachment(attachment) for attachment in attachments]) |
| 406 | if embeds: |
| 407 | data["embeds"] = await gather(*[self.handle_embed(embed) for embed in embeds]) |
| 408 | if replies: |
| 409 | new_replies: List[MessageReplyPayload] = [] |
| 410 | for i in replies: |
| 411 | if isinstance(i, MessageReply): |
| 412 | new_replies.append(i.to_dict()) |
| 413 | else: |
| 414 | new_replies.append(i) |
| 415 | data["replies"] = new_replies |
| 416 | if masquerade: |
| 417 | data["masquerade"] = masquerade.to_dict() if isinstance(masquerade, MessageMasquerade) else masquerade |
| 418 | if interactions: |
| 419 | data["interactions"] = ( |
| 420 | interactions.to_dict() if isinstance(interactions, MessageInteractions) else interactions |
| 421 | ) |
| 422 | return await self.request("POST", f"channels/{channel_id}/messages", json=data) |
| 423 | |
| 424 | async def add_reaction(self, channel_id: str, message_id: str, emoji_id: str): |
| 425 | return await self.request("PUT", f"channels/{channel_id}/messages/{message_id}/reactions/{emoji_id}") |
no test coverage detected