diff --git a/setup.py b/setup.py index 57d9e2b..553d962 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="tc-messageBroker", - version="1.6.1", + version="1.6.2", author="Mohammad Amin Dadgar, RnDAO", maintainer="Mohammad Amin Dadgar", maintainer_email="dadgaramin96@gmail.com", diff --git a/tc_messageBroker/rabbit_mq/payload/discord_bot/base_types/guild.py b/tc_messageBroker/rabbit_mq/payload/discord_bot/base_types/guild.py index 2b83bfe..fcf4857 100644 --- a/tc_messageBroker/rabbit_mq/payload/discord_bot/base_types/guild.py +++ b/tc_messageBroker/rabbit_mq/payload/discord_bot/base_types/guild.py @@ -1,3 +1,6 @@ +from typing import Any + + class Guild: def __init__( self, @@ -9,6 +12,11 @@ def __init__( shard_id: int | None = None, splash: str | None = None, banner: str | None = None, + channels: list[str] | None = None, + members: list[str] | None = None, + roles: list[str] | None = None, + commands: Any | None = None, + bans: Any | None = None, description: str | None = None, verification_level: int | None = None, vanity_url_code: str | None = None, @@ -46,6 +54,11 @@ def __init__( self.icon = icon self.features = features self.available = available + self.members = members + self.channels = channels + self.roles = roles + self.commands = commands + self.bans = bans self.shard_id = shard_id self.splash = splash self.banner = banner @@ -92,6 +105,11 @@ def from_dict(cls, guild_dict: dict) -> "Guild": name=guild_dict.get("name"), icon=guild_dict.get("icon"), features=guild_dict.get("features", []), + channels=guild_dict.get("channels"), + members=guild_dict.get("members"), + roles=guild_dict.get("roles"), + commands=guild_dict.get("commands"), + bans=guild_dict.get("bans"), available=guild_dict.get("available"), shard_id=guild_dict.get("shardId"), splash=guild_dict.get("splash"), @@ -232,5 +250,15 @@ def to_dict(self) -> dict: data["safetyAlertsChannelId"] = self.safety_alerts_channel_id if self.owner_id is not None: data["ownerId"] = self.owner_id + if self.channels is not None: + data["channels"] = self.channels # type: ignore + if self.members is not None: + data["members"] = self.members # type: ignore + if self.roles is not None: + data["roles"] = self.roles # type: ignore + if self.commands is not None: + data["commands"] = self.commands + if self.bans is not None: + data["bans"] = self.bans return data diff --git a/tc_messageBroker/rabbit_mq/payload/discord_bot/base_types/user.py b/tc_messageBroker/rabbit_mq/payload/discord_bot/base_types/user.py index d1f73c5..2ca238c 100644 --- a/tc_messageBroker/rabbit_mq/payload/discord_bot/base_types/user.py +++ b/tc_messageBroker/rabbit_mq/payload/discord_bot/base_types/user.py @@ -56,20 +56,20 @@ def from_dict(cls, data: dict) -> "User": id=data["id"], created_at=created_at, client=data.get("client"), - default_avatar_url=data.get("default_avatar_url"), + default_avatar_url=data.get("defaultAvatarURL"), partial=data.get("partial"), - created_timestamp=data.get("created_timestamp"), + created_timestamp=data.get("createdTimestamp"), discriminator=data.get("discriminator"), bot=data.get("bot"), avatar=data.get("avatar"), - avatar_decoration=data.get("avatar_decoration"), + avatar_decoration=data.get("avatarDecoration"), banner=data.get("banner"), - accent_color=data.get("accent_color"), - display_name=data.get("display_name"), - dm_channel=data.get("dm_channel"), + accent_color=data.get("accentColor"), + display_name=data.get("displayName"), + dm_channel=data.get("dmChannel"), flags=data.get("flags"), - global_name=data.get("global_name"), - hex_accent_color=data.get("hex_accent_color"), + global_name=data.get("globalName"), + hex_accent_color=data.get("hexAccentColor"), system=data.get("system"), tag=data.get("tag"), username=data.get("username"), @@ -84,20 +84,20 @@ def to_dict(self) -> dict: "id": self.id, "created_at": created_at, "client": self.client, - "default_avatar_url": self.default_avatar_url, + "defaultAvatarURL": self.default_avatar_url, "partial": self.partial, - "created_timestamp": self.created_timestamp, + "createdTimestamp": self.created_timestamp, "discriminator": self.discriminator, "bot": self.bot, "avatar": self.avatar, - "avatar_decoration": self.avatar_decoration, + "avatarDecoration": self.avatar_decoration, "banner": self.banner, - "accent_color": self.accent_color, - "display_name": self.display_name, - "dm_channel": self.dm_channel, + "accentColor": self.accent_color, + "displayName": self.display_name, + "dmChannel": self.dm_channel, "flags": self.flags, - "global_name": self.global_name, - "hex_accent_color": self.hex_accent_color, + "globalName": self.global_name, + "hexAccentColor": self.hex_accent_color, "system": self.system, "tag": self.tag, "username": self.username, diff --git a/tc_messageBroker/rabbit_mq/payload/discord_bot/chat_input_interaction.py b/tc_messageBroker/rabbit_mq/payload/discord_bot/chat_input_interaction.py index bc244fc..3634981 100644 --- a/tc_messageBroker/rabbit_mq/payload/discord_bot/chat_input_interaction.py +++ b/tc_messageBroker/rabbit_mq/payload/discord_bot/chat_input_interaction.py @@ -1,7 +1,6 @@ from datetime import datetime from typing import Any -from .base_types.flags import PermissionsBitField from .base_types.guild import Guild from .base_types.user import User @@ -33,8 +32,8 @@ def __init__( command_id: str | None = None, command_name: str | None = None, command_type: dict | None = None, - command_guild_id: dict | None = None, - member_permissions: PermissionsBitField | None = None, + command_guild_id: str | None = None, + member_permissions: str | None = None, options: dict | None = None, version: int | None = None, ) -> None: @@ -74,12 +73,10 @@ def __init__( @classmethod def from_dict(self, data: dict) -> "ChatInputCommandInteraction": member_permissions = data.get("memberPermissions") - if member_permissions is not None: - member_permissions = PermissionsBitField.from_dict(member_permissions) created_at = data.get("createdAt") if created_at is not None: - created_at = datetime.fromisoformat(created_at) + created_at = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%S.%fZ") guild = data.get("guild") if guild is not None: