Skip to content

Commit 943c6ba

Browse files
FayeDelEepyElvyra
andauthored
fix: Edit Embed msg serialisation and refactor msg edit return (#561)
* fix: Edit message Embed instantiation serialisation and include proper message return on edit helper method. * refactor: Refactor embed serialisation from model to helper method. This is because this is caused via the Helper method. Co-authored-by: EdVraz <88881326+EdVraz@users.noreply.github.com>
1 parent 03051fd commit 943c6ba

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

interactions/api/models/message.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,12 @@ async def edit(
383383
# _file = None if file is None else file
384384

385385
if embeds is MISSING:
386-
_embeds = self.embeds
387-
else:
388-
_embeds: list = (
389-
[]
390-
if not embeds
391-
else (
392-
[embed._json for embed in embeds]
393-
if isinstance(embeds, list)
394-
else [embeds._json]
395-
)
396-
)
386+
embeds = self.embeds
387+
_embeds: list = (
388+
[]
389+
if not embeds
390+
else ([embed._json for embed in embeds] if isinstance(embeds, list) else [embeds._json])
391+
)
397392
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions
398393
_message_reference: dict = {} if message_reference is MISSING else message_reference._json
399394
if not components:
@@ -413,12 +408,13 @@ async def edit(
413408
components=_components,
414409
)
415410

416-
await self._client.edit_message(
411+
_dct = await self._client.edit_message(
417412
channel_id=int(self.channel_id),
418413
message_id=int(self.id),
419414
payload=payload._json,
420415
)
421-
return payload
416+
417+
return Message(**_dct) if not _dct.get("code") else payload
422418

423419
async def reply(
424420
self,

0 commit comments

Comments
 (0)