Skip to content

Commit

Permalink
fix: correct emoji parsing and component -> modal (#1283)
Browse files Browse the repository at this point in the history
* fix: three fixes

* feat: add myself lol
  • Loading branch information
mAxYoLo01 authored Feb 17, 2023
1 parent b8fe5c4 commit 9317dc4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions interactions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
MessageType,
MFALevel,
Modal,
modal_callback,
ModalCommand,
ModalContext,
MODEL_TO_CONVERTER,
Expand Down Expand Up @@ -527,6 +528,7 @@
"Missing",
"MISSING",
"Modal",
"modal_callback",
"ModalCommand",
"ModalContext",
"MODEL_TO_CONVERTER",
Expand Down Expand Up @@ -678,6 +680,7 @@
# Jimmy-Blue -- Contributor
# Kigstn -- Contributor
# leestarb -- Contributor
# mAxYoLo01 -- Contributor
# Nanrech -- Contributor
# silasary -- Contributor
# Toricane -- Contributor
Expand Down
2 changes: 2 additions & 0 deletions interactions/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@
MemberConverter,
MessageableChannelConverter,
MessageConverter,
modal_callback,
ModalCommand,
ModalContext,
MODEL_TO_CONVERTER,
Expand Down Expand Up @@ -457,6 +458,7 @@
"MessageType",
"MFALevel",
"Modal",
"modal_callback",
"ModalCommand",
"ModalContext",
"MODEL_TO_CONVERTER",
Expand Down
14 changes: 6 additions & 8 deletions interactions/models/discord/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@

import discord_typings

from interactions.client.const import (
ACTION_ROW_MAX_ITEMS,
MISSING,
)
from interactions.client.const import ACTION_ROW_MAX_ITEMS, MISSING
from interactions.client.mixins.serialization import DictSerializationMixin
from interactions.models.discord.emoji import PartialEmoji
from interactions.models.discord.emoji import process_emoji
from interactions.models.discord.enums import ButtonStyle, ComponentType, ChannelType
from interactions.models.discord.emoji import PartialEmoji, process_emoji
from interactions.models.discord.enums import ButtonStyle, ChannelType, ComponentType

__all__ = (
"BaseComponent",
Expand Down Expand Up @@ -245,10 +241,12 @@ def __init__(

@classmethod
def from_dict(cls, data: discord_typings.ButtonComponentData) -> "Button":
emoji = process_emoji(data.get("emoji"))
emoji = PartialEmoji.from_dict(emoji) if emoji else None
return cls(
style=ButtonStyle(data["style"]),
label=data.get("label"),
emoji=process_emoji(data.get("emoji")),
emoji=emoji,
custom_id=data.get("custom_id"),
url=data.get("url"),
disabled=data.get("disabled", False),
Expand Down
2 changes: 2 additions & 0 deletions interactions/models/internal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
LocalisedName,
LocalizedDesc,
LocalizedName,
modal_callback,
ModalCommand,
OptionType,
slash_command,
Expand Down Expand Up @@ -156,6 +157,7 @@
"MemberConverter",
"MessageableChannelConverter",
"MessageConverter",
"modal_callback",
"ModalCommand",
"ModalContext",
"MODEL_TO_CONVERTER",
Expand Down
1 change: 1 addition & 0 deletions interactions/models/internal/application_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"LocalisedName",
"LocalizedDesc",
"LocalizedName",
"modal_callback",
"ModalCommand",
"OptionType",
"slash_command",
Expand Down
2 changes: 1 addition & 1 deletion interactions/models/internal/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ def target(self) -> None | Message | User | Member:
return self.resolved.get(self.target_id)


class ComponentContext(InteractionContext):
class ComponentContext(InteractionContext, ModalMixin):
values: list[str]
"""The values of the SelectMenu component, if any."""
custom_id: str
Expand Down

0 comments on commit 9317dc4

Please sign in to comment.