Simplify and fix config scanning

This commit is contained in:
BreadTube 2025-09-26 04:00:55 +09:00 committed by Corentin
commit 486cb82773
3 changed files with 82 additions and 84 deletions

View file

@ -251,6 +251,7 @@ class User: # TODO : complete attributes
username: str
discriminator: str
global_name: str | None
bot: bool
@staticmethod
def from_dict(info: dict) -> User:
@ -258,7 +259,8 @@ class User: # TODO : complete attributes
id=int(info['id']),
username=info['username'],
discriminator=info['discriminator'],
global_name=info.get('global_name'))
global_name=info.get('global_name'),
bot=info.get('bot', False))
class AttachmentFlags(IntFlag):
@ -421,7 +423,7 @@ class Message: # TODO : complete attributes
id=int(info['id']),
channel_id=int(info['channel_id']),
author=(User.from_dict(info['author']) if info.get('webhook_id') is None else User(
id=info['webhook_id'], username='webhook', discriminator='webhook', global_name=None)),
id=info['webhook_id'], username='webhook', discriminator='webhook', global_name=None, bot=False)),
content=info['content'],
timestamp=datetime.fromisoformat(info['timestamp']),
edited_timestamp=datetime.fromisoformat(edited_timestamp) if edited_timestamp is not None else None,