From 684e1142933894a8d5103cc381a748af9eb98679 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 24 Oct 2023 11:26:45 +0330 Subject: [PATCH 1/3] fix: field names updated with the real data! we were given the real data from discord-bot to update the interfaces. --- .../payload/discord_bot/base_types/guild.py | 28 ++++++++++++++++ .../payload/discord_bot/base_types/user.py | 32 +++++++++---------- .../discord_bot/chat_input_interaction.py | 8 ++--- 3 files changed, 47 insertions(+), 21 deletions(-) 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..5a8c32e 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 @@ -33,8 +33,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 +74,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: From 2b433ca651eb5bbca5140eb1c7235739505796bb Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 24 Oct 2023 11:45:32 +0330 Subject: [PATCH 2/3] fix: flake8 linter issue! --- .../rabbit_mq/payload/discord_bot/chat_input_interaction.py | 1 - 1 file changed, 1 deletion(-) 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 5a8c32e..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 From 4cd8a81958420cf0015e04bc5b2d24cb6c2a69a2 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 24 Oct 2023 11:59:38 +0330 Subject: [PATCH 3/3] update: lib version increased! --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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",