Improve clarity of and optimize API.send_direct_message
authorHarmon <Harmon758@gmail.com>
Mon, 11 Jan 2021 16:40:01 +0000 (10:40 -0600)
committerHarmon <Harmon758@gmail.com>
Mon, 11 Jan 2021 16:42:56 +0000 (10:42 -0600)
tweepy/api.py

index e07f690caf013f490dc04e39c129ecab448b92eb..1f5984b49de10dbf2c65ff482d06ff0763790703 100644 (file)
@@ -461,8 +461,10 @@ class API:
                 'options': quick_reply_options
             }
         if attachment_type is not None and attachment_media_id is not None:
-            message_data['attachment'] = {'type': attachment_type}
-            message_data['attachment']['media'] = {'id': attachment_media_id}
+            message_data['attachment'] = {
+                'type': attachment_type,
+                'media': {'id': attachment_media_id}
+            }
         return bind_api(
             api=self,
             path='/direct_messages/events/new.json',