aboutsummaryrefslogtreecommitdiff
path: root/discord/client.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-06-20 22:11:43 -0400
committerRapptz <[email protected]>2016-06-20 22:11:43 -0400
commitc3c9db7777ce73b29682a01000409f05ae6e4a0d (patch)
tree693a10e9ee00e4e64697fa7f397721fc14a96fb9 /discord/client.py
parent[commands] Add Command.ignore_extra attribute to ignore extra arguments (diff)
downloaddiscord.py-c3c9db7777ce73b29682a01000409f05ae6e4a0d.tar.xz
discord.py-c3c9db7777ce73b29682a01000409f05ae6e4a0d.zip
Fix bug with deleting private messages.
This was due to an AttributeError occurring when getting the guild_id from the channel. PrivateChannels do not have guild_ids so they should be None.
Diffstat (limited to 'discord/client.py')
-rw-r--r--discord/client.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/discord/client.py b/discord/client.py
index e7ef7073..690a7f6d 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -911,7 +911,8 @@ class Client:
Deleting the message failed.
"""
channel = message.channel
- yield from self.http.delete_message(channel.id, message.id, channel.server.id)
+ guild_id = channel.server.id if not getattr(channel, 'is_private', True) else None
+ yield from self.http.delete_message(channel.id, message.id, guild_id)
@asyncio.coroutine
def delete_messages(self, messages):
@@ -949,7 +950,8 @@ class Client:
channel = messages[0].channel
message_ids = [m.id for m in messages]
- yield from self.http.delete_messages(channel.id, message_ids, channel.server.id)
+ guild_id = channel.server.id if not getattr(channel, 'is_private', True) else None
+ yield from self.http.delete_messages(channel.id, message_ids, guild_id)
@asyncio.coroutine
def purge_from(self, channel, *, limit=100, check=None, before=None, after=None):
@@ -1073,7 +1075,7 @@ class Client:
channel = message.channel
content = str(new_content)
- guild_id = channel.server.id if not channel.is_private else None
+ guild_id = channel.server.id if not getattr(channel, 'is_private', True) else None
data = yield from self.http.edit_message(message.id, channel.id, content, guild_id=guild_id)
return Message(channel=channel, **data)