Browse Source

bugfix - properly send embed when using multipart-form for attachments

also fix sending an embed on edit
feature/docs
Andrei 8 years ago
parent
commit
21d54969e7
  1. 7
      disco/api/client.py
  2. 4
      disco/types/message.py

7
disco/api/client.py

@ -1,4 +1,5 @@
import six
import json
from disco.api.http import Routes, HTTPClient
from disco.util.logging import LoggingClass
@ -98,7 +99,7 @@ class APIClient(LoggingClass):
payload['embed'] = embed.to_dict()
if attachment:
r = self.http(Routes.CHANNELS_MESSAGES_CREATE, dict(channel=channel), data=payload, files={
r = self.http(Routes.CHANNELS_MESSAGES_CREATE, dict(channel=channel), data={'payload_json': json.dumps(payload)}, files={
'file': (attachment[0], attachment[1])
})
else:
@ -106,10 +107,10 @@ class APIClient(LoggingClass):
return Message.create(self.client, r.json())
def channels_messages_modify(self, channel, message, content):
def channels_messages_modify(self, channel, message, content, embed=None):
r = self.http(Routes.CHANNELS_MESSAGES_MODIFY,
dict(channel=channel, message=message),
json={'content': content})
json={'content': content, 'embed': embed.to_dict()})
return Message.create(self.client, r.json())
def channels_messages_delete(self, channel, message):

4
disco/types/message.py

@ -254,7 +254,7 @@ class Message(SlottedModel):
"""
return self.channel.send_message(*args, **kwargs)
def edit(self, content):
def edit(self, *args, **kwargs):
"""
Edit this message.
@ -268,7 +268,7 @@ class Message(SlottedModel):
:class:`Message`
The edited message object.
"""
return self.client.api.channels_messages_modify(self.channel_id, self.id, content)
return self.client.api.channels_messages_modify(self.channel_id, self.id, *args, **kwargs)
def delete(self):
"""

Loading…
Cancel
Save