@@ -1156,6 +1156,22 @@ async def edit(
11561156 * ,
11571157 content : Optional [str ] = ...,
11581158 embed : Optional [Embed ] = ...,
1159+ file : Optional [File ] = ...,
1160+ attachments : List [Attachment ] = ...,
1161+ suppress : bool = ...,
1162+ delete_after : Optional [float ] = ...,
1163+ allowed_mentions : Optional [AllowedMentions ] = ...,
1164+ view : Optional [View ] = ...,
1165+ ) -> Message :
1166+ ...
1167+
1168+ @overload
1169+ async def edit (
1170+ self ,
1171+ * ,
1172+ content : Optional [str ] = ...,
1173+ embed : Optional [Embed ] = ...,
1174+ files : Optional [List [File ]] = ...,
11591175 attachments : List [Attachment ] = ...,
11601176 suppress : bool = ...,
11611177 delete_after : Optional [float ] = ...,
@@ -1170,6 +1186,7 @@ async def edit(
11701186 * ,
11711187 content : Optional [str ] = ...,
11721188 embeds : List [Embed ] = ...,
1189+ file : File = ...,
11731190 attachments : List [Attachment ] = ...,
11741191 suppress : bool = ...,
11751192 delete_after : Optional [float ] = ...,
@@ -1183,6 +1200,8 @@ async def edit(
11831200 content : Optional [str ] = MISSING ,
11841201 embed : Optional [Embed ] = MISSING ,
11851202 embeds : List [Embed ] = MISSING ,
1203+ file : Sequence [File ] = MISSING ,
1204+ files : List [Sequence [File ]] = MISSING ,
11861205 attachments : List [Attachment ] = MISSING ,
11871206 suppress : bool = MISSING ,
11881207 delete_after : Optional [float ] = None ,
@@ -1211,6 +1230,10 @@ async def edit(
12111230 To remove all embeds ``[]`` should be passed.
12121231
12131232 .. versionadded:: 2.0
1233+ file: Sequence[:class:`File`]
1234+ A new file to add to the message.
1235+ files: List[Sequence[:class:`File`]]
1236+ New files to add to the message.
12141237 attachments: List[:class:`Attachment`]
12151238 A list of attachments to keep in the message. If ``[]`` is passed
12161239 then all attachments are removed.
@@ -1244,7 +1267,9 @@ async def edit(
12441267 Tried to suppress a message without permissions or
12451268 edited a message's content or embed that isn't yours.
12461269 ~discord.InvalidArgument
1247- You specified both ``embed`` and ``embeds``
1270+ You specified both ``embed`` and ``embeds``,
1271+ specified both ``file`` and ``files``, or either``file``
1272+ or ``files`` were of the wrong type.
12481273 """
12491274
12501275 payload : Dict [str , Any ] = {}
@@ -1289,8 +1314,42 @@ async def edit(
12891314 payload ['components' ] = view .to_components ()
12901315 else :
12911316 payload ['components' ] = []
1317+
1318+ if file is not MISSING and files is not MISSING :
1319+ raise InvalidArgument ('cannot pass both file and files parameter to edit()' )
1320+
1321+ if file is not MISSING :
1322+ if not isinstance (file , File ):
1323+ raise InvalidArgument ('file parameter must be File' )
12921324
1293- data = await self ._state .http .edit_message (self .channel .id , self .id , ** payload )
1325+ try :
1326+ data = await self ._state .http .edit_files (
1327+ self .channel .id ,
1328+ self .id ,
1329+ files = [file ],
1330+ ** payload ,
1331+ )
1332+ finally :
1333+ file .close ()
1334+
1335+ elif files is not MISSING :
1336+ if len (files ) > 10 :
1337+ raise InvalidArgument ('files parameter must be a list of up to 10 elements' )
1338+ elif not all (isinstance (file , File ) for file in files ):
1339+ raise InvalidArgument ('files parameter must be a list of File' )
1340+
1341+ try :
1342+ data = await self ._state .http .edit_files (
1343+ self .channel .id ,
1344+ self .id ,
1345+ files = files ,
1346+ ** payload ,
1347+ )
1348+ finally :
1349+ for f in files :
1350+ f .close ()
1351+ else :
1352+ data = await self ._state .http .edit_message (self .channel .id , self .id , ** payload )
12941353 message = Message (state = self ._state , channel = self .channel , data = data )
12951354
12961355 if view and not view .is_finished ():
0 commit comments