From 8b03918c3d4ae7e30ee6a8bb96b746b3f0748035 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Tue, 13 Oct 2015 04:34:14 -0400 Subject: [PATCH] Client.send_message can now accept a string ID as the destination. --- discord/client.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/discord/client.py b/discord/client.py index 51f452d98..8f6c133d3 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)