mirror of
https://github.com/MelisaDev/melisa.git
synced 2024-11-11 19:07:28 +03:00
message send method
This commit is contained in:
parent
3e82c4f78d
commit
8c7f4a8aec
2 changed files with 38 additions and 0 deletions
|
@ -277,3 +277,6 @@ class Client:
|
|||
|
||||
channel_cls = channel_types_for_converting.get(data["type"], Channel)
|
||||
return channel_cls.from_dict(data)
|
||||
|
||||
|
||||
Bot = Client
|
||||
|
|
|
@ -503,6 +503,41 @@ class MessageableChannel(Channel):
|
|||
headers={"X-Audit-Log-Reason": reason},
|
||||
)
|
||||
|
||||
async def send(
|
||||
self, content: str = None
|
||||
) -> Message:
|
||||
"""|coro|
|
||||
|
||||
Sends a message to the destination with the content given.
|
||||
|
||||
The content must be a type that can convert to a string through str(content).
|
||||
|
||||
Parameters
|
||||
----------
|
||||
content: Optional[:class:`str`]
|
||||
The content of the message to send.
|
||||
|
||||
Raises
|
||||
-------
|
||||
HTTPException
|
||||
The request to perform the action failed with other http exception.
|
||||
ForbiddenError
|
||||
You do not have the proper permissions to send the message.
|
||||
BadRequestError
|
||||
Some of specified parameters is invalid.
|
||||
"""
|
||||
|
||||
# ToDo: Add other parameters
|
||||
|
||||
content = str(content) if content is not None else None
|
||||
|
||||
return Message.from_dict(
|
||||
await self._http.post(
|
||||
f"/channels/{self.id}/messages",
|
||||
data={"content": content}
|
||||
)
|
||||
)
|
||||
|
||||
async def purge(
|
||||
self,
|
||||
limit: int = 50,
|
||||
|
|
Loading…
Reference in a new issue