aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-10-13 04:34:14 -0400
committerRapptz <[email protected]>2015-10-13 05:39:58 -0400
commit8b03918c3d4ae7e30ee6a8bb96b746b3f0748035 (patch)
tree72ff15b580068494a1e4f466e0c2eab3e7a10f2c
parentPass kwargs to all constructors for future proofing. (diff)
downloaddiscord.py-8b03918c3d4ae7e30ee6a8bb96b746b3f0748035.tar.xz
discord.py-8b03918c3d4ae7e30ee6a8bb96b746b3f0748035.zip
Client.send_message can now accept a string ID as the destination.
-rw-r--r--discord/client.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/discord/client.py b/discord/client.py
index 51f452d9..8f6c133d 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -498,7 +498,8 @@ class Client(object):
The destination could be a :class:`Channel` or a :class:`PrivateChannel`. For convenience
it could also be a :class:`User`. If it's a :class:`User` or :class:`PrivateChannel` then it
- sends the message via private message, otherwise it sends the message to the channel.
+ sends the message via private message, otherwise it sends the message to the channel. If it's
+ a ``str`` instance, then it assumes it's a channel ID and uses that for its destination.
The content must be a type that can convert to a string through ``str(content)``.
@@ -526,8 +527,10 @@ class Client(object):
channel_id = self.private_channels[-1].id
else:
channel_id = found.id
+ elif isinstance(destination, str):
+ channel_id = destination
else:
- raise InvalidDestination('Destination must be Channel, PrivateChannel, or User')
+ raise InvalidDestination('Destination must be Channel, PrivateChannel, User, or str')
content = str(content)
mentions = self._resolve_mentions(content, mentions)