diff --git a/src/utils/ui/msgeditor.py b/src/utils/ui/msgeditor.py index 5e1cca2..fb2d907 100644 --- a/src/utils/ui/msgeditor.py +++ b/src/utils/ui/msgeditor.py @@ -54,7 +54,10 @@ class MsgEditor(MessageUI): By default, uses the provided `formatter` callback (if provided). """ if self._formatter is not None: - await self._formatter(data) + return await self._formatter(data) + else: + return data + def copy_data(self): return copy.deepcopy(self.history[-1]) @@ -78,7 +81,8 @@ class MsgEditor(MessageUI): if 'embed' in new_data: try: - discord.Embed.from_dict(new_data['embed']) + formatted_data = copy.deepcopy(new_data) + discord.Embed.from_dict(await self.format_data(formatted_data['embed'])) except Exception as e: raise UserInputError( t(_p( @@ -445,8 +449,17 @@ class MsgEditor(MessageUI): embed_data.pop('footer', None) if (ts := timestamp_field.value): + if ts.isdigit(): + # Treat as UTC timestamp + timestamp = dt.datetime.fromtimestamp(int(ts), dt.timezone.utc) + ts = timestamp.isoformat() + to_validate = ts + elif self._formatter: + to_validate = await self._formatter(ts) + else: + to_validate = ts try: - dt.datetime.fromisoformat(ts) + dt.datetime.fromisoformat(to_validate) except ValueError: raise UserInputError( t(_p(