Skip to content

Commit

Permalink
Merge pull request #51 from TogetherCrew/fix/hivemind-interaction-pay…
Browse files Browse the repository at this point in the history
…loads

Fix/hivemind interaction payloads
  • Loading branch information
cyri113 authored Jan 10, 2024
2 parents 798c80f + d405f99 commit ca0ac99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="tc-messageBroker",
version="1.6.3",
version="1.6.4",
author="Mohammad Amin Dadgar, RnDAO",
maintainer="Mohammad Amin Dadgar",
maintainer_email="[email protected]",
Expand Down
15 changes: 4 additions & 11 deletions tc_messageBroker/rabbit_mq/payload/payload_microservices.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,40 @@
from .discord_bot.base_types.interaction_callback_data import InteractionCallbackData
from .discord_bot.chat_input_interaction import ChatInputCommandInteraction
from .discord_bot.create_followup_message_data import FollowUpMessageData
from .discord_bot.edit_webhook_data import InteractionResponseEditData
from .discord_bot.interaction_response import InteractionResponse


class DiscordBotInteractionResponseCreatePayload:
def __init__(
self,
type: int,
data: InteractionCallbackData | None = None,
interaction: ChatInputCommandInteraction | None = None,
data: InteractionResponse | None = None,
) -> None:
"""
to set right values please refer to
https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
"""
self.type = type
self.data = data
self.interaction = interaction

@classmethod
def from_dict(cls, d: dict) -> "DiscordBotInteractionResponseCreatePayload":
interaction = d.get("interaction")
data = d.get("data")
type = d.get("type")

if interaction is not None:
interaction = ChatInputCommandInteraction.from_dict(interaction)

if data is not None:
data = InteractionCallbackData.from_dict(data)

if type is not None:
type = int(type)
data = InteractionResponse.from_dict(data)

return cls(
type=type,
data=data,
interaction=interaction,
)

def to_dict(self):
return {"type": self.type, "data": self.data, "interaction": self.interaction}
return {"data": self.data.to_dict(), "interaction": self.interaction}


class DiscordBotInteractionResponseEditPayload:
Expand Down

0 comments on commit ca0ac99

Please sign in to comment.