Skip to content

Commit

Permalink
Fix bug that stopped components from working (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
zunda-arrow authored Dec 10, 2022
1 parent c9a91fc commit e6d7be1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions flare/internal/event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import hikari

from flare.components import CallbackComponent, Modal
from flare.context import MessageContext, ModalContext
from flare.exceptions import SerializerError
from flare.internal import bootstrap
Expand All @@ -28,10 +29,12 @@ async def on_inter(event: hikari.InteractionCreateEvent) -> None:
ctx = MessageContext(
interaction=event.interaction,
)
assert issubclass(component, CallbackComponent)
await component(**kwargs).callback(ctx)
else:
ctx = ModalContext(interaction=event.interaction)

await component(**kwargs, _ctx=ctx).callback(ctx) # type: ignore
assert issubclass(component, Modal)
await component(**kwargs, _ctx=ctx).callback(ctx) # type: ignore


# MIT License
Expand Down
4 changes: 2 additions & 2 deletions flare/internal/serde.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def serialize(self, cookie: str, types: dict[str, t.Any], kwargs: dict[str
@abc.abstractmethod
async def deserialize(
self, custom_id: str, map: dict[str, t.Any]
) -> tuple[type[base.CallbackComponent], dict[str, t.Any]]:
) -> tuple[type[base.SupportsCallback[t.Any]], dict[str, t.Any]]:
"""
Decode a custom_id for a component.
Expand Down Expand Up @@ -220,7 +220,7 @@ async def convert_one(k: str, v: t.Any) -> None:

async def deserialize(
self, custom_id: str, map: dict[str, t.Any]
) -> tuple[type[base.CallbackComponent], dict[str, t.Any]]:
) -> tuple[type[base.SupportsCallback[t.Any]], dict[str, t.Any]]:
if self.VER is not None: # Allow for no version to disable verification
version = await get_converter(int).from_str(custom_id[0])

Expand Down

0 comments on commit e6d7be1

Please sign in to comment.